Completed
Push — master ( b1c3d5...ab6cc4 )
by Yannick
44:42 queued 14:21
created
route-statistics-aircraft.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
 require_once('require/class.Connection.php');
8 8
 require_once('require/class.Spotter.php');
9 9
 require_once('require/class.Language.php');
10
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11
-$departure_airport = filter_input(INPUT_GET,'departure_airport',FILTER_SANITIZE_STRING);
12
-$arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING);
10
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
11
+$departure_airport = filter_input(INPUT_GET, 'departure_airport', FILTER_SANITIZE_STRING);
12
+$arrival_airport = filter_input(INPUT_GET, 'arrival_airport', FILTER_SANITIZE_STRING);
13 13
 $Spotter = new Spotter();
14 14
 $spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, "0,1", $sort);
15 15
   
16 16
 if (!empty($spotter_array))
17 17
 {
18
-	$title = sprintf(_("Most Common Aircraft between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']);
18
+	$title = sprintf(_("Most Common Aircraft between %s (%s), %s - %s (%s), %s"), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']);
19 19
 	require_once('header.php');
20 20
 	print '<div class="info column">';
21 21
 	print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>';
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	include('route-sub-menu.php');
27 27
 	print '<div class="column">';
28 28
 	print '<h2>'._("Most Common Aircraft").'</h2>';
29
-	print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']).'</p>';
29
+	print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']).'</p>';
30 30
 
31 31
 	$aircraft_array = $Spotter->countAllAircraftTypesByRoute($departure_airport, $arrival_airport);
32 32
 	if (!empty($aircraft_array))
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		print '</thead>';
42 42
 		print '<tbody>';
43 43
 		$i = 1;
44
-		foreach($aircraft_array as $aircraft_item)
44
+		foreach ($aircraft_array as $aircraft_item)
45 45
 		{
46 46
 			print '<tr>';
47 47
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
owner-detailed.php 2 patches
Spacing   +22 added lines, -22 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,29 +40,29 @@  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));
48
+	if ($year != '') $filter = array_merge($filter, array('year' => $year));
49
+	if ($month != '') $filter = array_merge($filter, array('month' => $month));
50 50
 	if ($sort != '') 
51 51
 	{
52
-		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
52
+		$spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
53 53
 		if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
54
-			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
54
+			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
55 55
 		}
56 56
 	} else {
57
-		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter);
57
+		$spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter);
58 58
 		if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
59
-			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter);
59
+			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter);
60 60
 		}
61 61
 	}
62 62
 
63 63
 	if (!empty($spotter_array))
64 64
 	{
65
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
65
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['aircraft_owner']);
66 66
 		//$ident = $spotter_array[0]['ident'];
67 67
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
68 68
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -122,23 +122,23 @@  discard block
 block discarded – undo
122 122
 		$Stats = new Stats();
123 123
 		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
124 124
 		else $flights = 0;
125
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
125
+		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner, $filter);
126 126
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
127
-		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
127
+		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner, $filter));
128 128
 		print '<div><span class="label">'._("Aircraft type").'</span>'.$aircraft_type.'</div>';
129
-		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner,$filter));
129
+		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner, $filter));
130 130
 		print '<div><span class="label">'._("Aircraft").'</span>'.$aircraft_registration.'</div>';
131
-		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner,$filter));
131
+		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner, $filter));
132 132
 		print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
133
-		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
133
+		$airlines = count($Spotter->countAllAirlinesByOwner($owner, $filter));
134 134
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
135
-		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
135
+		$duration = $Spotter->getFlightDurationByOwner($owner, $filter);
136 136
 		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
137 137
 		print '</div>';
138 138
 	
139 139
 		include('owner-sub-menu.php');
140 140
 		print '<div class="table column">';
141
-		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>';
141
+		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>';
142 142
 
143 143
 		include('table-output.php'); 
144 144
 		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
 	if ($sort != '') 
51 55
 	{
52 56
 		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -64,8 +68,12 @@  discard block
 block discarded – undo
64 68
 	{
65 69
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
66 70
 		//$ident = $spotter_array[0]['ident'];
67
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
68
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
71
+		if (isset($spotter_array[0]['latitude'])) {
72
+			$latitude = $spotter_array[0]['latitude'];
73
+		}
74
+		if (isset($spotter_array[0]['longitude'])) {
75
+			$longitude = $spotter_array[0]['longitude'];
76
+		}
69 77
 		require_once('header.php');
70 78
 		/*
71 79
 		if (isset($globalArchive) && $globalArchive) {
@@ -120,9 +128,14 @@  discard block
 block discarded – undo
120 128
 		print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
121 129
 		//print '<div><span class="label">'._("Owner").'</span>'.$spotter_array[0]['aircraft_owner'].'</div>';
122 130
 		$Stats = new Stats();
123
-		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
124
-		else $flights = 0;
125
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
131
+		if ($year == '' && $month == '') {
132
+			$flights = $Stats->getStatsOwner($owner);
133
+		} else {
134
+			$flights = 0;
135
+		}
136
+		if ($flights == 0) {
137
+			$flights = $Spotter->countFlightsByOwner($owner,$filter);
138
+		}
126 139
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
127 140
 		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
128 141
 		print '<div><span class="label">'._("Aircraft type").'</span>'.$aircraft_type.'</div>';
@@ -133,7 +146,9 @@  discard block
 block discarded – undo
133 146
 		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
134 147
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
135 148
 		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
136
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
149
+		if ($duration != '0') {
150
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
151
+		}
137 152
 		print '</div>';
138 153
 	
139 154
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.
require/class.Scheduler.php 3 patches
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 	}
29 29
 
30 30
 	/**
31
-	* Add schedule data to database
32
-	* @param String $ident aircraft ident
33
-	* @param String $departure_airport_icao departure airport icao
34
-	* @param String $departure_airport_time departure airport time
35
-	* @param String $arrival_airport_icao arrival airport icao
36
-	* @param String $arrival_airport_time arrival airport time
31
+	 * Add schedule data to database
32
+	 * @param String $ident aircraft ident
33
+	 * @param String $departure_airport_icao departure airport icao
34
+	 * @param String $departure_airport_time departure airport time
35
+	 * @param String $arrival_airport_icao arrival airport icao
36
+	 * @param String $arrival_airport_time arrival airport time
37 37
 	/ @param String $source source of data
38
-	*/
38
+	 */
39 39
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
40 40
 		date_default_timezone_set('UTC');
41 41
 		$date = date("Y-m-d H:i:s",time());
@@ -51,18 +51,18 @@  discard block
 block discarded – undo
51 51
 		}
52 52
 		if ($sth->fetchColumn() > 0) {
53 53
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
54
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
55
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
54
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
55
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
56 56
 			} elseif ($arrival_airport_time == '') {
57
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
58
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
57
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
58
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
59 59
 			} elseif ($departure_airport_time == '') {
60
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
61
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
60
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
61
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
62 62
 			} else {
63
-			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
64
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
65
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
63
+				//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
64
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
65
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
66 66
 			}
67 67
 			try {
68 68
 				$sth = $this->db->prepare($query);
@@ -149,15 +149,15 @@  discard block
 block discarded – undo
149 149
 	*/
150 150
 	public function checkSchedule($ident) {
151 151
 		global $globalDBdriver;
152
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
153
-	        if ($globalDBdriver == 'mysql') {
152
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
153
+			if ($globalDBdriver == 'mysql') {
154 154
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1";
155 155
 		} else {
156 156
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident 
157 157
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
158 158
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
159 159
 		}
160
-	        $query_values = array(':ident' => $ident);
160
+			$query_values = array(':ident' => $ident);
161 161
 		 try {
162 162
 			$sth = $this->db->prepare($query);
163 163
 			$sth->execute($query_values);
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	/**
173
-	* Get flight info from Air France
174
-	* @param String $callsign The callsign
175
-	* @param String $date date we want flight number info
176
-	* @param String $carrier IATA code
177
-	* @return Flight departure and arrival airports and time
178
-	*/
173
+	 * Get flight info from Air France
174
+	 * @param String $callsign The callsign
175
+	 * @param String $date date we want flight number info
176
+	 * @param String $carrier IATA code
177
+	 * @return Flight departure and arrival airports and time
178
+	 */
179 179
 	public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
180 180
 		$Common = new Common();
181 181
 		$check_date = new Datetime($date);
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 	}
212 212
 
213 213
 	/**
214
-	* Get flight info from EasyJet
215
-	* @param String $callsign The callsign
216
-	* @param String $date date we want flight number info
217
-	* @return Flight departure and arrival airports and time
218
-	*/
214
+	 * Get flight info from EasyJet
215
+	 * @param String $callsign The callsign
216
+	 * @param String $date date we want flight number info
217
+	 * @return Flight departure and arrival airports and time
218
+	 */
219 219
 	private function getEasyJet($callsign, $date = 'NOW') {
220 220
 		global $globalTimezone;
221 221
 		$Common = new Common();
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	/**
242
-	* Get flight info from Ryanair
243
-	* @param String $callsign The callsign
244
-	* @return Flight departure and arrival airports and time
245
-	*/
242
+	 * Get flight info from Ryanair
243
+	 * @param String $callsign The callsign
244
+	 * @return Flight departure and arrival airports and time
245
+	 */
246 246
 	private function getRyanair($callsign) {
247 247
 		$Common = new Common();
248 248
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 	}
266 266
 
267 267
 	/**
268
-	* Get flight info from Swiss
269
-	* @param String $callsign The callsign
270
-	* @return Flight departure and arrival airports and time
271
-	*/
268
+	 * Get flight info from Swiss
269
+	 * @param String $callsign The callsign
270
+	 * @return Flight departure and arrival airports and time
271
+	 */
272 272
 	private function getSwiss($callsign) {
273 273
 		$Common = new Common();
274 274
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 	}
298 298
 	
299 299
 	/**
300
-	* Get flight info from British Airways API
301
-	* @param String $callsign The callsign
302
-	* @param String $date date we want flight number info
303
-	* @return Flight departure and arrival airports and time
304
-	*/
300
+	 * Get flight info from British Airways API
301
+	 * @param String $callsign The callsign
302
+	 * @param String $date date we want flight number info
303
+	 * @return Flight departure and arrival airports and time
304
+	 */
305 305
 	public function getBritishAirways($callsign, $date = 'NOW') {
306 306
 		global $globalBritishAirwaysKey;
307 307
 		$Common = new Common();
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 	}
326 326
 
327 327
 	/**
328
-	* Get flight info from Lutfhansa API
329
-	* @param String $callsign The callsign
330
-	* @param String $date date we want flight number info
331
-	* @return Flight departure and arrival airports and time
332
-	*/
328
+	 * Get flight info from Lutfhansa API
329
+	 * @param String $callsign The callsign
330
+	 * @param String $date date we want flight number info
331
+	 * @return Flight departure and arrival airports and time
332
+	 */
333 333
 	public function getLufthansa($callsign, $date = 'NOW') {
334 334
 		global $globalLufthansaKey;
335 335
 		$Common = new Common();
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 	}
360 360
 
361 361
 	/**
362
-	* Get flight info from Transavia API
363
-	* @param String $callsign The callsign
364
-	* @param String $date date we want flight number info
365
-	* @return Flight departure and arrival airports and time
366
-	*/
362
+	 * Get flight info from Transavia API
363
+	 * @param String $callsign The callsign
364
+	 * @param String $date date we want flight number info
365
+	 * @return Flight departure and arrival airports and time
366
+	 */
367 367
 	public function getTransavia($callsign, $date = 'NOW') {
368 368
 		global $globalTransaviaKey;
369 369
 		$Common = new Common();
@@ -389,10 +389,10 @@  discard block
 block discarded – undo
389 389
 	}
390 390
 
391 391
 	/**
392
-	* Get flight info from Tunisair
393
-	* @param String $callsign The callsign
394
-	* @return Flight departure and arrival airports and time
395
-	*/
392
+	 * Get flight info from Tunisair
393
+	 * @param String $callsign The callsign
394
+	 * @return Flight departure and arrival airports and time
395
+	 */
396 396
 	public function getTunisair($callsign) {
397 397
 		$Common = new Common();
398 398
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
 	}
410 410
 
411 411
 	/**
412
-	* Get flight info from Vueling
413
-	* @param String $callsign The callsign
414
-	* @return Flight departure and arrival airports and time
415
-	*/
412
+	 * Get flight info from Vueling
413
+	 * @param String $callsign The callsign
414
+	 * @return Flight departure and arrival airports and time
415
+	 */
416 416
 	public function getVueling($callsign,$date = 'NOW') {
417 417
 		$Common = new Common();
418 418
 		$check_date = new Datetime($date);
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 	}
435 435
 
436 436
 	/**
437
-	* Get flight info from Iberia
438
-	* @param String $callsign The callsign
439
-	* @param String $date date we want flight number info
440
-	* @return Flight departure and arrival airports and time
441
-	*/
437
+	 * Get flight info from Iberia
438
+	 * @param String $callsign The callsign
439
+	 * @param String $date date we want flight number info
440
+	 * @return Flight departure and arrival airports and time
441
+	 */
442 442
 	public function getIberia($callsign, $date = 'NOW') {
443 443
 		$Common = new Common();
444 444
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -468,11 +468,11 @@  discard block
 block discarded – undo
468 468
 	}
469 469
 
470 470
 	/**
471
-	* Get flight info from Star Alliance
472
-	* @param String $callsign The callsign
473
-	* @param String $date date we want flight number info
474
-	* @return Flight departure and arrival airports and time
475
-	*/
471
+	 * Get flight info from Star Alliance
472
+	 * @param String $callsign The callsign
473
+	 * @param String $date date we want flight number info
474
+	 * @return Flight departure and arrival airports and time
475
+	 */
476 476
 
477 477
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
478 478
 		$Common = new Common();
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
 
505 505
 
506 506
 	/**
507
-	* Get flight info from Alitalia
508
-	* @param String $callsign The callsign
509
-	* @param String $date date we want flight number info
510
-	* @return Flight departure and arrival airports and time
511
-	*/
507
+	 * Get flight info from Alitalia
508
+	 * @param String $callsign The callsign
509
+	 * @param String $date date we want flight number info
510
+	 * @return Flight departure and arrival airports and time
511
+	 */
512 512
 	private function getAlitalia($callsign, $date = 'NOW') {
513 513
 		$Common = new Common();
514 514
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -527,11 +527,11 @@  discard block
 block discarded – undo
527 527
 	}
528 528
 
529 529
 	/**
530
-	* Get flight info from Brussels airlines
531
-	* @param String $callsign The callsign
532
-	* @param String $date date we want flight number info
533
-	* @return Flight departure and arrival airports and time
534
-	*/
530
+	 * Get flight info from Brussels airlines
531
+	 * @param String $callsign The callsign
532
+	 * @param String $date date we want flight number info
533
+	 * @return Flight departure and arrival airports and time
534
+	 */
535 535
 	private function getBrussels($callsign, $date = 'NOW') {
536 536
 		$Common = new Common();
537 537
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -541,24 +541,24 @@  discard block
 block discarded – undo
541 541
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
542 542
 		$data = $Common->getData($url);
543 543
 		if ($data != '') {
544
-		    //echo $data;
545
-		    $parsed_json = json_decode($data,true);
546
-		    if (isset($parsed_json[0]['FromAirportCode'])) {
544
+			//echo $data;
545
+			$parsed_json = json_decode($data,true);
546
+			if (isset($parsed_json[0]['FromAirportCode'])) {
547 547
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
548 548
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
549 549
 			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
550 550
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
551 551
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
552
-		    }
552
+			}
553 553
 		}
554 554
 	}
555 555
 
556 556
 	/**
557
-	* Get flight info from FlightRadar24
558
-	* @param String $callsign The callsign
559
-	* @param String $date date we want flight number info
560
-	* @return Flight departure and arrival airports and time
561
-	*/
557
+	 * Get flight info from FlightRadar24
558
+	 * @param String $callsign The callsign
559
+	 * @param String $date date we want flight number info
560
+	 * @return Flight departure and arrival airports and time
561
+	 */
562 562
 /*
563 563
 	public function getFlightRadar24($callsign, $date = 'NOW') {
564 564
 		$Common = new Common();
@@ -587,11 +587,11 @@  discard block
 block discarded – undo
587 587
 	}
588 588
   */
589 589
 	/**
590
-	* Get flight info from Lufthansa
591
-	* @param String $callsign The callsign
592
-	* @param String $date date we want flight number info
593
-	* @return Flight departure and arrival airports and time
594
-	*/
590
+	 * Get flight info from Lufthansa
591
+	 * @param String $callsign The callsign
592
+	 * @param String $date date we want flight number info
593
+	 * @return Flight departure and arrival airports and time
594
+	 */
595 595
 
596 596
 /*	private function getLufthansa($callsign, $date = 'NOW') {
597 597
 		$Common = new Common();
@@ -619,10 +619,10 @@  discard block
 block discarded – undo
619 619
 	}
620 620
   */
621 621
 	/**
622
-	* Get flight info from flytap
623
-	* @param String $callsign The callsign
624
-	* @return Flight departure and arrival airports and time
625
-	*/
622
+	 * Get flight info from flytap
623
+	 * @param String $callsign The callsign
624
+	 * @return Flight departure and arrival airports and time
625
+	 */
626 626
 	private function getFlyTap($callsign) {
627 627
 		$Common = new Common();
628 628
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -645,10 +645,10 @@  discard block
 block discarded – undo
645 645
 	}
646 646
 
647 647
 	/**
648
-	* Get flight info from flightmapper
649
-	* @param String $callsign The callsign
650
-	* @return Flight departure and arrival airports and time
651
-	*/
648
+	 * Get flight info from flightmapper
649
+	 * @param String $callsign The callsign
650
+	 * @return Flight departure and arrival airports and time
651
+	 */
652 652
 	public function getFlightMapper($callsign) {
653 653
 		$Common = new Common();
654 654
 		$airline_icao = '';
@@ -676,11 +676,11 @@  discard block
 block discarded – undo
676 676
 				$aarr = '';
677 677
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
678 678
 				if ($n == 7) {
679
-				    $departureTime = $dhour;
680
-				    $arrivalTime = $ahour;
681
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
682
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
683
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
679
+					$departureTime = $dhour;
680
+					$arrivalTime = $ahour;
681
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
682
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
683
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
684 684
 				}
685 685
 			}
686 686
 		}
@@ -688,10 +688,10 @@  discard block
 block discarded – undo
688 688
 	}
689 689
 
690 690
 	/**
691
-	* Get flight info from flightaware
692
-	* @param String $callsign The callsign
693
-	* @return Flight departure and arrival airports and time
694
-	*/
691
+	 * Get flight info from flightaware
692
+	 * @param String $callsign The callsign
693
+	 * @return Flight departure and arrival airports and time
694
+	 */
695 695
 	public function getFlightAware($callsign) {
696 696
 		global $globalFlightAwareUsername, $globalFlightAwarePassword;
697 697
 		date_default_timezone_set('UTC');
@@ -716,11 +716,11 @@  discard block
 block discarded – undo
716 716
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
717 717
 				if (isset($flight['origin'])) {
718 718
 					return array(
719
-					    'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
720
-					    'DepartureTime' => $flight['filed_departure_time']['time'],
721
-					    'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
722
-					    'ArrivalTime' => $flight['filed_arrival_time']['time'],
723
-					    'Source' => 'website_flightaware');
719
+						'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
720
+						'DepartureTime' => $flight['filed_departure_time']['time'],
721
+						'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
722
+						'ArrivalTime' => $flight['filed_arrival_time']['time'],
723
+						'Source' => 'website_flightaware');
724 724
 				}
725 725
 			}
726 726
 		}
@@ -733,21 +733,21 @@  discard block
 block discarded – undo
733 733
 			$flight = reset($flights['flights']);
734 734
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
735 735
 				return array(
736
-				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
737
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
738
-				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
739
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
740
-				    'Source' => 'website_flightaware');
736
+					'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
737
+					'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
738
+					'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
739
+					'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
740
+					'Source' => 'website_flightaware');
741 741
 			}
742 742
 		}
743 743
 		return array();
744 744
 	}
745 745
 
746 746
 	/**
747
-	* Get flight info from CostToTravel
748
-	* @param String $callsign The callsign
749
-	* @return Flight departure and arrival airports and time
750
-	*/
747
+	 * Get flight info from CostToTravel
748
+	 * @param String $callsign The callsign
749
+	 * @return Flight departure and arrival airports and time
750
+	 */
751 751
 	public function getCostToTravel($callsign) {
752 752
 		$Common = new Common();
753 753
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 	}
771 771
 
772 772
 	/**
773
-	* Get flight info from Air Canada
774
-	* @param String $callsign The callsign
775
-	* @param String $date date we want flight number info
776
-	* @return Flight departure and arrival airports and time
777
-	*/
773
+	 * Get flight info from Air Canada
774
+	 * @param String $callsign The callsign
775
+	 * @param String $date date we want flight number info
776
+	 * @return Flight departure and arrival airports and time
777
+	 */
778 778
 	private function getAirCanada($callsign,$date = 'NOW') {
779 779
 		$Common = new Common();
780 780
 		if (class_exists("DomDocument") === FALSE) return array();
@@ -799,11 +799,11 @@  discard block
 block discarded – undo
799 799
 	}
800 800
 
801 801
 	/**
802
-	* Get flight info from Vietnam Airlines
803
-	* @param String $callsign The callsign
804
-	* @param String $date date we want flight number info
805
-	* @return Flight departure and arrival airports and time
806
-	*/
802
+	 * Get flight info from Vietnam Airlines
803
+	 * @param String $callsign The callsign
804
+	 * @param String $date date we want flight number info
805
+	 * @return Flight departure and arrival airports and time
806
+	 */
807 807
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
808 808
 		$Common = new Common();
809 809
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -825,12 +825,12 @@  discard block
 block discarded – undo
825 825
 	}
826 826
 
827 827
 	/**
828
-	* Get flight info from Air Berlin
829
-	* @param String $callsign The callsign
830
-	* @param String $date date we want flight number info
831
-	* @param String $carrier airline code
832
-	* @return Flight departure and arrival airports and time
833
-	*/
828
+	 * Get flight info from Air Berlin
829
+	 * @param String $callsign The callsign
830
+	 * @param String $date date we want flight number info
831
+	 * @param String $carrier airline code
832
+	 * @return Flight departure and arrival airports and time
833
+	 */
834 834
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
835 835
 		$Common = new Common();
836 836
 		date_default_timezone_set('UTC');
@@ -859,11 +859,11 @@  discard block
 block discarded – undo
859 859
 			$table = $Common->table2array($data);
860 860
 			$flight = $table;
861 861
 			if (isset($flight[5][4])) {
862
-			    $arrivalTime = $flight[5][4];
863
-			    $arrivalAirport = $flight[5][3];
862
+				$arrivalTime = $flight[5][4];
863
+				$arrivalAirport = $flight[5][3];
864 864
 			} else {
865
-			    $arrivalTime = '';
866
-			    $arrivalAirport = '';
865
+				$arrivalTime = '';
866
+				$arrivalAirport = '';
867 867
 			}
868 868
 		} else return array();
869 869
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
Please login to merge, or discard this patch.
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	* @param String $arrival_airport_time arrival airport time
37 37
 	/ @param String $source source of data
38 38
 	*/
39
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
39
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
40 40
 		date_default_timezone_set('UTC');
41
-		$date = date("Y-m-d H:i:s",time());
41
+		$date = date("Y-m-d H:i:s", time());
42 42
 		//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
43 43
 		//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
44 44
 		$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -46,69 +46,69 @@  discard block
 block discarded – undo
46 46
 		 try {
47 47
 			$sth = $this->db->prepare($query);
48 48
 			$sth->execute($query_values);
49
-		} catch(PDOException $e) {
49
+		} catch (PDOException $e) {
50 50
 			return "error : ".$e->getMessage();
51 51
 		}
52 52
 		if ($sth->fetchColumn() > 0) {
53 53
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
54 54
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
55
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
55
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
56 56
 			} elseif ($arrival_airport_time == '') {
57 57
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
58
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
58
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
59 59
 			} elseif ($departure_airport_time == '') {
60 60
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
61
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
61
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
62 62
 			} else {
63 63
 			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
64 64
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
65
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
65
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
66 66
 			}
67 67
 			try {
68 68
 				$sth = $this->db->prepare($query);
69 69
 				$sth->execute($query_values);
70
-			} catch(PDOException $e) {
70
+			} catch (PDOException $e) {
71 71
 				return "error : ".$e->getMessage();
72 72
 			}
73 73
 			if ($sth->fetchColumn() == 0) {
74 74
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
75 75
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
76 76
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
77
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
77
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
78 78
 				} elseif ($arrival_airport_time == '') {
79 79
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
80
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
80
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
81 81
 				} elseif ($departure_airport_time == '') {
82 82
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
83
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
83
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
84 84
 				} else {
85 85
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
86
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
86
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
87 87
 				}
88 88
 				try {
89 89
 					$sth = $this->db->prepare($query);
90 90
 					$sth->execute($query_values);
91
-				} catch(PDOException $e) {
91
+				} catch (PDOException $e) {
92 92
 					return "error : ".$e->getMessage();
93 93
 				}
94 94
 			} else {
95 95
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
96 96
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
97
-				$query_values = array(':ident' => $ident,':date' => $date);
97
+				$query_values = array(':ident' => $ident, ':date' => $date);
98 98
 				try {
99 99
 					$sth = $this->db->prepare($query);
100 100
 					$sth->execute($query_values);
101
-				} catch(PDOException $e) {
101
+				} catch (PDOException $e) {
102 102
 					return "error : ".$e->getMessage();
103 103
 				}
104 104
 			}
105 105
 		} else {
106 106
 			$query = 'INSERT INTO  routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
107
-			$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
107
+			$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
108 108
 			 try {
109 109
 				$sth = $this->db->prepare($query);
110 110
 				$sth->execute($query_values);
111
-			} catch(PDOException $e) {
111
+			} catch (PDOException $e) {
112 112
 				return "error : ".$e->getMessage();
113 113
 			}
114 114
 		}
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 	*/
122 122
 	public function getSchedule($ident) {
123 123
 		$Translation = new Translation($this->db);
124
-		$operator = $Translation->checkTranslation($ident,false);
124
+		$operator = $Translation->checkTranslation($ident, false);
125 125
 		if ($ident != $operator) {
126 126
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1";
127
-			$query_values = array(':ident' => $ident,'operator' => $operator);
127
+			$query_values = array(':ident' => $ident, 'operator' => $operator);
128 128
 		} else {
129 129
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1";
130 130
 			$query_values = array(':ident' => $ident);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		 try {
133 133
 			$sth = $this->db->prepare($query);
134 134
 			$sth->execute($query_values);
135
-		} catch(PDOException $e) {
135
+		} catch (PDOException $e) {
136 136
 			return "error : ".$e->getMessage();
137 137
 		}
138 138
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		 try {
162 162
 			$sth = $this->db->prepare($query);
163 163
 			$sth->execute($query_values);
164
-		} catch(PDOException $e) {
164
+		} catch (PDOException $e) {
165 165
 			return "error : ".$e->getMessage();
166 166
 		}
167 167
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -176,16 +176,16 @@  discard block
 block discarded – undo
176 176
 	* @param String $carrier IATA code
177 177
 	* @return Flight departure and arrival airports and time
178 178
 	*/
179
-	public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
179
+	public function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
180 180
 		$Common = new Common();
181 181
 		$check_date = new Datetime($date);
182
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
183
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
182
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
183
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
184 184
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
185 185
 		$json = $Common->getData($url);
186 186
 		var_dump($json);
187 187
 		$parsed_json = json_decode($json);
188
-		if (property_exists($parsed_json,'errors') === false) {
188
+		if (property_exists($parsed_json, 'errors') === false) {
189 189
 			//$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
190 190
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
191 191
 			//$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 			//$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
196 196
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
197 197
 
198
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
198
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
199 199
 			$DepartureAirportIata = $originiata[1];
200
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
200
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
201 201
 			$ArrivalAirportIata = $destinationiata[1];
202 202
 
203 203
 			/*
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
207 207
 			*/
208 208
 		
209
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
209
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
210 210
 		} else return array();
211 211
 	}
212 212
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 		$Common = new Common();
222 222
 		date_default_timezone_set($globalTimezone);
223 223
 		$check_date = new Datetime($date);
224
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
225
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
224
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
225
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
226 226
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
227 227
 		$json = $Common->getData($url);
228 228
 		$parsed_json = json_decode($json);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
235 235
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
236 236
 
237
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
237
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
238 238
 		} else return array();
239 239
 	}
240 240
 
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 	*/
246 246
 	private function getRyanair($callsign) {
247 247
 		$Common = new Common();
248
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
249
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
248
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
249
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
250 250
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
251 251
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
252
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
253
-		$json = $Common->getData($url,'post',$post,$headers);
252
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
253
+		$json = $Common->getData($url, 'post', $post, $headers);
254 254
 		$parsed_json = json_decode($json);
255 255
 		if (isset($parsed_json->{'flightInfo'})) {
256 256
 			$flights = $parsed_json->{'flightInfo'};
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
260 260
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
261 261
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
262
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
262
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
263 263
 			} else return array();
264 264
 		} else return array();
265 265
 	}
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 	*/
272 272
 	private function getSwiss($callsign) {
273 273
 		$Common = new Common();
274
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
275
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
274
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
275
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
276 276
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
277 277
 		$json = $Common->getData($url);
278 278
 		$parsed_json = json_decode($json);
@@ -286,12 +286,12 @@  discard block
 block discarded – undo
286 286
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
287 287
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
288 288
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
289
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
290
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
289
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
290
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
291 291
 				}
292 292
 			}
293 293
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
294
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
294
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
295 295
 			} else return array();
296 296
 		} else return array();
297 297
 	}
@@ -306,21 +306,21 @@  discard block
 block discarded – undo
306 306
 		global $globalBritishAirwaysKey;
307 307
 		$Common = new Common();
308 308
 		$check_date = new Datetime($date);
309
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
310
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
309
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
310
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
311 311
 		if ($globalBritishAirwaysKey == '') return array();
312 312
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
313 313
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
314
-		$json = $Common->getData($url,'get','',$headers);
314
+		$json = $Common->getData($url, 'get', '', $headers);
315 315
 		if ($json == '') return array();
316 316
 		$parsed_json = json_decode($json);
317 317
 		$flights = $parsed_json->{'FlightsResponse'};
318 318
 		if (count($flights) > 0) {
319 319
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
320 320
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
321
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
322
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
323
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
321
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
322
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
323
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
324 324
 		} else return array();
325 325
 	}
326 326
 
@@ -334,27 +334,27 @@  discard block
 block discarded – undo
334 334
 		global $globalLufthansaKey;
335 335
 		$Common = new Common();
336 336
 		$check_date = new Datetime($date);
337
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
338
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
337
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
338
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
339 339
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
340 340
 		$url = "https://api.lufthansa.com/v1/oauth/token";
341
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
342
-		$data = $Common->getData($url,'post',$post);
341
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
342
+		$data = $Common->getData($url, 'post', $post);
343 343
 		$parsed_data = json_decode($data);
344 344
 		if (!isset($parsed_data->{'access_token'})) return array();
345 345
 		$token = $parsed_data->{'access_token'};
346 346
 		
347 347
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
348
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
349
-		$json = $Common->getData($url,'get','',$headers);
348
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
349
+		$json = $Common->getData($url, 'get', '', $headers);
350 350
 		if ($json == '') return array();
351 351
 		$parsed_json = json_decode($json);
352 352
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
353 353
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
354
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
354
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
355 355
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
356
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
357
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
356
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
357
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
358 358
 		} else return array();
359 359
 	}
360 360
 
@@ -368,23 +368,23 @@  discard block
 block discarded – undo
368 368
 		global $globalTransaviaKey;
369 369
 		$Common = new Common();
370 370
 		$check_date = new Datetime($date);
371
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
372
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
371
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
372
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
373 373
 		if ($globalTransaviaKey == '') return array();
374 374
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
375 375
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
376 376
 		$headers = array('apikey: '.$globalTransaviaKey);
377
-		$json = $Common->getData($url,'get','',$headers);
377
+		$json = $Common->getData($url, 'get', '', $headers);
378 378
 		//echo 'result : '.$json;
379 379
 		if ($json == '') return array();
380 380
 		$parsed_json = json_decode($json);
381 381
 		
382 382
 		if (isset($parsed_json->{'data'}[0])) {
383 383
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
384
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
384
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
385 385
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
386
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
387
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
386
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
387
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
388 388
 		} else return array();
389 389
 	}
390 390
 
@@ -395,14 +395,14 @@  discard block
 block discarded – undo
395 395
 	*/
396 396
 	public function getTunisair($callsign) {
397 397
 		$Common = new Common();
398
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
399
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
398
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
399
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
400 400
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
401 401
 		$data = $Common->getData($url);
402 402
 		$table = $Common->table2array($data);
403 403
 		foreach ($table as $flight) {
404
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
405
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
404
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
405
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
406 406
 			}
407 407
 		}
408 408
 		return array();
@@ -413,21 +413,21 @@  discard block
 block discarded – undo
413 413
 	* @param String $callsign The callsign
414 414
 	* @return Flight departure and arrival airports and time
415 415
 	*/
416
-	public function getVueling($callsign,$date = 'NOW') {
416
+	public function getVueling($callsign, $date = 'NOW') {
417 417
 		$Common = new Common();
418 418
 		$check_date = new Datetime($date);
419
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
420
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
421
-		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
419
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
420
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
421
+		$final_date = str_replace('/', '%2F', $check_date->format('d/m/Y'));
422 422
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
423 423
 		$data = $Common->getData($url);
424
-		$data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data));
424
+		$data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data));
425 425
 		if ($data != '') {
426
-			preg_match('/flightOri=[A-Z]{3}/',$data,$result);
427
-			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
428
-			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
429
-			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
430
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
426
+			preg_match('/flightOri=[A-Z]{3}/', $data, $result);
427
+			$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
428
+			preg_match('/flightDest=[A-Z]{3}/', $data, $result);
429
+			$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
430
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling');
431 431
 			else return array();
432 432
 		}
433 433
 		return array();
@@ -441,27 +441,27 @@  discard block
 block discarded – undo
441 441
 	*/
442 442
 	public function getIberia($callsign, $date = 'NOW') {
443 443
 		$Common = new Common();
444
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
444
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
445 445
 		$check_date = new Datetime($date);
446
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
446
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
447 447
 		$url = "https://www.iberia.com/web/flightDetail.do";
448
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
449
-		$data = $Common->getData($url,'post',$post);
448
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
449
+		$data = $Common->getData($url, 'post', $post);
450 450
 		if ($data != '') {
451 451
 			$table = $Common->table2array($data);
452 452
 			//print_r($table);
453 453
 			if (count($table) > 0) {
454 454
 				$flight = $table;
455
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
456
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
455
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
456
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
457 457
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
458 458
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
459
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
460
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
459
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
460
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
461 461
 				if ($arrivalTime == 'Hora estimada de llegada') {
462
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
463
-				} else $arrivalTime = substr($arrivalTime,0,5);
464
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
462
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
463
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
464
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
465 465
 			}
466 466
 		}
467 467
 		return array();
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	* @return Flight departure and arrival airports and time
475 475
 	*/
476 476
 
477
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
477
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
478 478
 		$Common = new Common();
479
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
479
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
480 480
 		$check_date = new Datetime($date);
481
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
481
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
482 482
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
483 483
 		$data = $Common->getData($url);
484 484
 		if ($data != '') {
@@ -487,13 +487,13 @@  discard block
 block discarded – undo
487 487
 				$flight = $table;
488 488
 				//print_r($table);
489 489
 				if (isset($flight[25]) && isset($flight[29])) {
490
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
491
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
490
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
491
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
492 492
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
493 493
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
494
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
495
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
496
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
494
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
495
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
496
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
497 497
 				} else return array();
498 498
 			}
499 499
 			
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
 	*/
512 512
 	private function getAlitalia($callsign, $date = 'NOW') {
513 513
 		$Common = new Common();
514
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
514
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
515 515
 		$check_date = new Datetime($date);
516
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
517
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
516
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
517
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
518 518
 		$data = $Common->getData($url);
519 519
 		if ($data != '') {
520 520
 			$table = $Common->text2array($data);
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 			$ArrivalAirportIata = '';
523 523
 			$departureTime = $table[4];
524 524
 			$arrivalTime = $table[5];
525
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
525
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
526 526
 		}
527 527
 	}
528 528
 
@@ -534,21 +534,21 @@  discard block
 block discarded – undo
534 534
 	*/
535 535
 	private function getBrussels($callsign, $date = 'NOW') {
536 536
 		$Common = new Common();
537
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
537
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
538 538
 		$check_date = new Datetime($date);
539
-		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
539
+		$url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
540 540
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
541
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
541
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
542 542
 		$data = $Common->getData($url);
543 543
 		if ($data != '') {
544 544
 		    //echo $data;
545
-		    $parsed_json = json_decode($data,true);
545
+		    $parsed_json = json_decode($data, true);
546 546
 		    if (isset($parsed_json[0]['FromAirportCode'])) {
547 547
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
548 548
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
549
-			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
550
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
551
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
549
+			$departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate']));
550
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate']));
551
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
552 552
 		    }
553 553
 		}
554 554
 	}
@@ -625,21 +625,21 @@  discard block
 block discarded – undo
625 625
 	*/
626 626
 	private function getFlyTap($callsign) {
627 627
 		$Common = new Common();
628
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
629
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
628
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
629
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
630 630
 		//$check_date = new Datetime($date);
631
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
632
-		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
633
-		$data = $Common->getData($url,'post',$post);
631
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
632
+		$post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1');
633
+		$data = $Common->getData($url, 'post', $post);
634 634
 		if ($data != '') {
635 635
 			$table = $Common->table2array($data);
636
-			$departureTime = trim(substr($table[15][0],0,5));
637
-			$arrivalTime = trim(substr($table[35][0],0,5));
638
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
639
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
636
+			$departureTime = trim(substr($table[15][0], 0, 5));
637
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
638
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
639
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
640 640
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
641 641
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
642
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
642
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
643 643
 		}
644 644
 		return array();
645 645
 	}
@@ -661,10 +661,10 @@  discard block
 block discarded – undo
661 661
 			} 
662 662
 		}
663 663
 		if ($airline_icao == '') return array();
664
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
665
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
664
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
665
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
666 666
 		//$check_date = new Datetime($date);
667
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
667
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
668 668
 		$data = $Common->getData($url);
669 669
 		if ($data != '') {
670 670
 			$table = $Common->table2array($data);
@@ -674,13 +674,13 @@  discard block
 block discarded – undo
674 674
 				$darr = '';
675 675
 				$ahour = '';
676 676
 				$aarr = '';
677
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
677
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
678 678
 				if ($n == 7) {
679 679
 				    $departureTime = $dhour;
680 680
 				    $arrivalTime = $ahour;
681
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
682
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
683
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
681
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
682
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
683
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
684 684
 				}
685 685
 			}
686 686
 		}
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			$url = 'http://'.$globalFlightAwareUsername.':'.$globalFlightAwarePassword.'@flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus?ident='.$callsign;
713 713
 			$data = $Common->getData($url);
714 714
 			if ($data != '') {
715
-				$result = json_decode($data,true);
715
+				$result = json_decode($data, true);
716 716
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
717 717
 				if (isset($flight['origin'])) {
718 718
 					return array(
@@ -725,18 +725,18 @@  discard block
 block discarded – undo
725 725
 			}
726 726
 		}
727 727
 		
728
-		$url= "http://flightaware.com/live/flight/".$callsign;
728
+		$url = "http://flightaware.com/live/flight/".$callsign;
729 729
 		$data = $Common->getData($url);
730 730
 		if ($data != '') {
731
-			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:',$data,$result);
732
-			$flights = json_decode($result[1],true);
731
+			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:', $data, $result);
732
+			$flights = json_decode($result[1], true);
733 733
 			$flight = reset($flights['flights']);
734 734
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
735 735
 				return array(
736 736
 				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
737
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
737
+				    'DepartureTime' => date('H:i', $flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
738 738
 				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
739
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
739
+				    'ArrivalTime' => date('H:i', $flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
740 740
 				    'Source' => 'website_flightaware');
741 741
 			}
742 742
 		}
@@ -750,20 +750,20 @@  discard block
 block discarded – undo
750 750
 	*/
751 751
 	public function getCostToTravel($callsign) {
752 752
 		$Common = new Common();
753
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
753
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
754 754
 		//$check_date = new Datetime($date);
755 755
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
756 756
 		$data = $Common->getData($url);
757 757
 		if ($data != '') {
758 758
 			$table = $Common->table2array($data);
759 759
 			if (isset($table[11][1])) {
760
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
760
+				if (is_numeric(substr($table[11][1], 0, 1))) $departureTime = substr($table[11][1], 0, 5);
761 761
 				else $departureTime = '';
762
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
762
+				if (is_numeric(substr($table[17][1], 0, 1))) $arrivalTime = substr($table[17][1], 0, 5);
763 763
 				else $arrivalTime = '';
764
-				$DepartureAirportIata = substr($table[13][1],0,3);
765
-				$ArrivalAirportIata = substr($table[15][1],0,3);
766
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
764
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
765
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
766
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
767 767
 			}
768 768
 		}
769 769
 		return array();
@@ -775,14 +775,14 @@  discard block
 block discarded – undo
775 775
 	* @param String $date date we want flight number info
776 776
 	* @return Flight departure and arrival airports and time
777 777
 	*/
778
-	private function getAirCanada($callsign,$date = 'NOW') {
778
+	private function getAirCanada($callsign, $date = 'NOW') {
779 779
 		$Common = new Common();
780 780
 		if (class_exists("DomDocument") === FALSE) return array();
781 781
 		date_default_timezone_set('UTC');
782 782
 		$check_date = new Datetime($date);
783
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
784
-		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
785
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
783
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
784
+		$url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
785
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
786 786
 		$data = $Common->getData($url);
787 787
 		$dom = new DomDocument();
788 788
 		$dom->loadXML($data);
@@ -790,11 +790,11 @@  discard block
 block discarded – undo
790 790
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
791 791
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
792 792
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
793
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
793
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
794 794
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
795 795
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
796
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
797
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
796
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
797
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
798 798
 		} else return array();
799 799
 	}
800 800
 
@@ -806,21 +806,21 @@  discard block
 block discarded – undo
806 806
 	*/
807 807
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
808 808
 		$Common = new Common();
809
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
809
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
810 810
 		$check_date = new Datetime($date);
811
-		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
812
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
811
+		$url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
812
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
813 813
 		$data = $Common->getData($url);
814 814
 		if ($data != '') {
815 815
 			$table = $Common->table2array($data);
816 816
 			$flight = $table;
817
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
818
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
817
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
818
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
819 819
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
820 820
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
821 821
 			$departureTime = $flight[5][1];
822 822
 			$arrivalTime = $flight[23][1];
823
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
823
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
824 824
 		}
825 825
 	}
826 826
 
@@ -831,16 +831,16 @@  discard block
 block discarded – undo
831 831
 	* @param String $carrier airline code
832 832
 	* @return Flight departure and arrival airports and time
833 833
 	*/
834
-	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
834
+	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
835 835
 		$Common = new Common();
836 836
 		date_default_timezone_set('UTC');
837 837
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
838
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
838
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
839 839
 		$check_date = new Datetime($date);
840
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
841
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
842
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
843
-		$data = $Common->getData($url,'post',$post);
840
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
841
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
842
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier);
843
+		$data = $Common->getData($url, 'post', $post);
844 844
 		//echo $data;
845 845
 		$DepartureAirportIata = '';
846 846
 		$ArrivalAirportIata = '';
@@ -853,8 +853,8 @@  discard block
 block discarded – undo
853 853
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
854 854
 			else $departureAirport = '';
855 855
 		} else return array();
856
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
857
-		$data = $Common->getData($url,'post',$post);
856
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
857
+		$data = $Common->getData($url, 'post', $post);
858 858
 		if ($data != '') {
859 859
 			$table = $Common->table2array($data);
860 860
 			$flight = $table;
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 			}
883 883
 		}
884 884
 		if (isset($DepartureAirportIata)) {
885
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
885
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
886 886
 		} else return array();
887 887
 	}
888 888
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 	 * @param String $date Date
893 893
 	 * @return Array Schedules info
894 894
 	*/
895
-	public function fetchSchedule($ident,$date = 'NOW') {
895
+	public function fetchSchedule($ident, $date = 'NOW') {
896 896
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
897 897
 		//$Common = new Common();
898 898
 		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
 				// Brussels Airlines
963 963
 				case "BEL":
964 964
 				case "SN":
965
-					return $this->getBrussels($ident,$date);
965
+					return $this->getBrussels($ident, $date);
966 966
 /*
967 967
 				// Copa Airlines
968 968
 				case "CMP":
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
 				case "DS":
1062 1062
 				case "EZY":
1063 1063
 				case "EZS":
1064
-					return $this->getEasyJet($ident,$date);
1064
+					return $this->getEasyJet($ident, $date);
1065 1065
 				// Ryanair
1066 1066
 				case "FR":
1067 1067
 				case "RYR":
@@ -1113,19 +1113,19 @@  discard block
 block discarded – undo
1113 1113
 					return $this->getIberia($ident);
1114 1114
 				// Vietnam Airlines
1115 1115
 				case "HVN":
1116
-					return $this->getVietnamAirlines($ident,$date);
1116
+					return $this->getVietnamAirlines($ident, $date);
1117 1117
 				// Air Berlin
1118 1118
 				case "AB":
1119 1119
 				case "BER":
1120
-					return $this->getAirBerlin($ident,$date,'AB');
1120
+					return $this->getAirBerlin($ident, $date, 'AB');
1121 1121
 				// NIKI
1122 1122
 				case "HG":
1123 1123
 				case "NLY":
1124
-					return $this->getAirBerlin($ident,$date,'HG');
1124
+					return $this->getAirBerlin($ident, $date, 'HG');
1125 1125
 				// BelAir
1126 1126
 				case "4T":
1127 1127
 				case "BHP":
1128
-					return $this->getAirBerlin($ident,$date,'4T');
1128
+					return $this->getAirBerlin($ident, $date, '4T');
1129 1129
 				default:
1130 1130
 					if (strlen($airline_icao) == 3) {
1131 1131
 						$Spotter = new Spotter($this->db);
@@ -1134,9 +1134,9 @@  discard block
 block discarded – undo
1134 1134
 					}
1135 1135
 					// Randomly use a generic function to get hours
1136 1136
 					if (strlen($airline_icao) == 2) {
1137
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1137
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightaware');
1138 1138
 						if (count($globalSchedulesSources) > 0) {
1139
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1139
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1140 1140
 							$source = $globalSchedulesSources[$rand];
1141 1141
 							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1142 1142
 							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
Please login to merge, or discard this patch.
Braces   +180 added lines, -62 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection.');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection.');
29
+		}
28 30
 	}
29 31
 
30 32
 	/**
@@ -139,7 +141,9 @@  discard block
 block discarded – undo
139 141
 		$sth->closeCursor();
140 142
 		if (count($row) > 0) {
141 143
 			return $row;
142
-		} else return array();
144
+		} else {
145
+			return array();
146
+		}
143 147
 	}
144 148
 
145 149
 	/*
@@ -180,7 +184,9 @@  discard block
 block discarded – undo
180 184
 		$Common = new Common();
181 185
 		$check_date = new Datetime($date);
182 186
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
183
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
187
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
188
+			return array();
189
+		}
184 190
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
185 191
 		$json = $Common->getData($url);
186 192
 		var_dump($json);
@@ -207,7 +213,9 @@  discard block
 block discarded – undo
207 213
 			*/
208 214
 		
209 215
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
210
-		} else return array();
216
+		} else {
217
+			return array();
218
+		}
211 219
 	}
212 220
 
213 221
 	/**
@@ -222,7 +230,9 @@  discard block
 block discarded – undo
222 230
 		date_default_timezone_set($globalTimezone);
223 231
 		$check_date = new Datetime($date);
224 232
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
225
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
233
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
234
+			return array();
235
+		}
226 236
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
227 237
 		$json = $Common->getData($url);
228 238
 		$parsed_json = json_decode($json);
@@ -235,7 +245,9 @@  discard block
 block discarded – undo
235 245
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
236 246
 
237 247
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
238
-		} else return array();
248
+		} else {
249
+			return array();
250
+		}
239 251
 	}
240 252
 
241 253
 	/**
@@ -246,7 +258,9 @@  discard block
 block discarded – undo
246 258
 	private function getRyanair($callsign) {
247 259
 		$Common = new Common();
248 260
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
249
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
261
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
262
+			return array();
263
+		}
250 264
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
251 265
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
252 266
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -260,8 +274,12 @@  discard block
 block discarded – undo
260 274
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
261 275
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
262 276
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
263
-			} else return array();
264
-		} else return array();
277
+			} else {
278
+				return array();
279
+			}
280
+		} else {
281
+			return array();
282
+		}
265 283
 	}
266 284
 
267 285
 	/**
@@ -272,7 +290,9 @@  discard block
 block discarded – undo
272 290
 	private function getSwiss($callsign) {
273 291
 		$Common = new Common();
274 292
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
275
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
293
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
294
+			return array();
295
+		}
276 296
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
277 297
 		$json = $Common->getData($url);
278 298
 		$parsed_json = json_decode($json);
@@ -292,8 +312,12 @@  discard block
 block discarded – undo
292 312
 			}
293 313
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
294 314
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
295
-			} else return array();
296
-		} else return array();
315
+			} else {
316
+				return array();
317
+			}
318
+		} else {
319
+			return array();
320
+		}
297 321
 	}
298 322
 	
299 323
 	/**
@@ -307,12 +331,18 @@  discard block
 block discarded – undo
307 331
 		$Common = new Common();
308 332
 		$check_date = new Datetime($date);
309 333
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
310
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
311
-		if ($globalBritishAirwaysKey == '') return array();
334
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
335
+			return array();
336
+		}
337
+		if ($globalBritishAirwaysKey == '') {
338
+			return array();
339
+		}
312 340
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
313 341
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
314 342
 		$json = $Common->getData($url,'get','',$headers);
315
-		if ($json == '') return array();
343
+		if ($json == '') {
344
+			return array();
345
+		}
316 346
 		$parsed_json = json_decode($json);
317 347
 		$flights = $parsed_json->{'FlightsResponse'};
318 348
 		if (count($flights) > 0) {
@@ -321,7 +351,9 @@  discard block
 block discarded – undo
321 351
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
322 352
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
323 353
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
324
-		} else return array();
354
+		} else {
355
+			return array();
356
+		}
325 357
 	}
326 358
 
327 359
 	/**
@@ -335,19 +367,27 @@  discard block
 block discarded – undo
335 367
 		$Common = new Common();
336 368
 		$check_date = new Datetime($date);
337 369
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
338
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
339
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
370
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
371
+			return array();
372
+		}
373
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
374
+			return array();
375
+		}
340 376
 		$url = "https://api.lufthansa.com/v1/oauth/token";
341 377
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
342 378
 		$data = $Common->getData($url,'post',$post);
343 379
 		$parsed_data = json_decode($data);
344
-		if (!isset($parsed_data->{'access_token'})) return array();
380
+		if (!isset($parsed_data->{'access_token'})) {
381
+			return array();
382
+		}
345 383
 		$token = $parsed_data->{'access_token'};
346 384
 		
347 385
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
348 386
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
349 387
 		$json = $Common->getData($url,'get','',$headers);
350
-		if ($json == '') return array();
388
+		if ($json == '') {
389
+			return array();
390
+		}
351 391
 		$parsed_json = json_decode($json);
352 392
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
353 393
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -355,7 +395,9 @@  discard block
 block discarded – undo
355 395
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
356 396
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
357 397
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
358
-		} else return array();
398
+		} else {
399
+			return array();
400
+		}
359 401
 	}
360 402
 
361 403
 	/**
@@ -369,14 +411,20 @@  discard block
 block discarded – undo
369 411
 		$Common = new Common();
370 412
 		$check_date = new Datetime($date);
371 413
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
372
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
373
-		if ($globalTransaviaKey == '') return array();
414
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
415
+			return array();
416
+		}
417
+		if ($globalTransaviaKey == '') {
418
+			return array();
419
+		}
374 420
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
375 421
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
376 422
 		$headers = array('apikey: '.$globalTransaviaKey);
377 423
 		$json = $Common->getData($url,'get','',$headers);
378 424
 		//echo 'result : '.$json;
379
-		if ($json == '') return array();
425
+		if ($json == '') {
426
+			return array();
427
+		}
380 428
 		$parsed_json = json_decode($json);
381 429
 		
382 430
 		if (isset($parsed_json->{'data'}[0])) {
@@ -385,7 +433,9 @@  discard block
 block discarded – undo
385 433
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
386 434
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
387 435
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
388
-		} else return array();
436
+		} else {
437
+			return array();
438
+		}
389 439
 	}
390 440
 
391 441
 	/**
@@ -396,7 +446,9 @@  discard block
 block discarded – undo
396 446
 	public function getTunisair($callsign) {
397 447
 		$Common = new Common();
398 448
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
399
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
449
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
450
+			return array();
451
+		}
400 452
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
401 453
 		$data = $Common->getData($url);
402 454
 		$table = $Common->table2array($data);
@@ -417,7 +469,9 @@  discard block
 block discarded – undo
417 469
 		$Common = new Common();
418 470
 		$check_date = new Datetime($date);
419 471
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
420
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
472
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
473
+			return array();
474
+		}
421 475
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
422 476
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
423 477
 		$data = $Common->getData($url);
@@ -427,8 +481,11 @@  discard block
 block discarded – undo
427 481
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
428 482
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
429 483
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
430
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
431
-			else return array();
484
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
485
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
486
+			} else {
487
+				return array();
488
+			}
432 489
 		}
433 490
 		return array();
434 491
 	}
@@ -443,7 +500,9 @@  discard block
 block discarded – undo
443 500
 		$Common = new Common();
444 501
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
445 502
 		$check_date = new Datetime($date);
446
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
503
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
504
+			return array();
505
+		}
447 506
 		$url = "https://www.iberia.com/web/flightDetail.do";
448 507
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
449 508
 		$data = $Common->getData($url,'post',$post);
@@ -460,7 +519,9 @@  discard block
 block discarded – undo
460 519
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
461 520
 				if ($arrivalTime == 'Hora estimada de llegada') {
462 521
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
463
-				} else $arrivalTime = substr($arrivalTime,0,5);
522
+				} else {
523
+					$arrivalTime = substr($arrivalTime,0,5);
524
+				}
464 525
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
465 526
 			}
466 527
 		}
@@ -478,7 +539,9 @@  discard block
 block discarded – undo
478 539
 		$Common = new Common();
479 540
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
480 541
 		$check_date = new Datetime($date);
481
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
542
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
543
+			return array();
544
+		}
482 545
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
483 546
 		$data = $Common->getData($url);
484 547
 		if ($data != '') {
@@ -494,7 +557,9 @@  discard block
 block discarded – undo
494 557
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
495 558
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
496 559
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
497
-				} else return array();
560
+				} else {
561
+					return array();
562
+				}
498 563
 			}
499 564
 			
500 565
 
@@ -514,7 +579,9 @@  discard block
 block discarded – undo
514 579
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
515 580
 		$check_date = new Datetime($date);
516 581
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
517
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
582
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
583
+			return array();
584
+		}
518 585
 		$data = $Common->getData($url);
519 586
 		if ($data != '') {
520 587
 			$table = $Common->text2array($data);
@@ -538,7 +605,9 @@  discard block
 block discarded – undo
538 605
 		$check_date = new Datetime($date);
539 606
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
540 607
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
541
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
608
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
609
+			return array();
610
+		}
542 611
 		$data = $Common->getData($url);
543 612
 		if ($data != '') {
544 613
 		    //echo $data;
@@ -628,7 +697,9 @@  discard block
 block discarded – undo
628 697
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
629 698
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
630 699
 		//$check_date = new Datetime($date);
631
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
700
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
701
+			return array();
702
+		}
632 703
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
633 704
 		$data = $Common->getData($url,'post',$post);
634 705
 		if ($data != '') {
@@ -660,11 +731,15 @@  discard block
 block discarded – undo
660 731
 				$airline_icao = substr($callsign, 0, 3);
661 732
 			} 
662 733
 		}
663
-		if ($airline_icao == '') return array();
734
+		if ($airline_icao == '') {
735
+			return array();
736
+		}
664 737
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
665 738
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
666 739
 		//$check_date = new Datetime($date);
667
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
740
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
741
+			return array();
742
+		}
668 743
 		$data = $Common->getData($url);
669 744
 		if ($data != '') {
670 745
 			$table = $Common->table2array($data);
@@ -757,10 +832,16 @@  discard block
 block discarded – undo
757 832
 		if ($data != '') {
758 833
 			$table = $Common->table2array($data);
759 834
 			if (isset($table[11][1])) {
760
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
761
-				else $departureTime = '';
762
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
763
-				else $arrivalTime = '';
835
+				if (is_numeric(substr($table[11][1],0,1))) {
836
+					$departureTime = substr($table[11][1],0,5);
837
+				} else {
838
+					$departureTime = '';
839
+				}
840
+				if (is_numeric(substr($table[17][1],0,1))) {
841
+					$arrivalTime = substr($table[17][1],0,5);
842
+				} else {
843
+					$arrivalTime = '';
844
+				}
764 845
 				$DepartureAirportIata = substr($table[13][1],0,3);
765 846
 				$ArrivalAirportIata = substr($table[15][1],0,3);
766 847
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
@@ -777,16 +858,22 @@  discard block
 block discarded – undo
777 858
 	*/
778 859
 	private function getAirCanada($callsign,$date = 'NOW') {
779 860
 		$Common = new Common();
780
-		if (class_exists("DomDocument") === FALSE) return array();
861
+		if (class_exists("DomDocument") === FALSE) {
862
+			return array();
863
+		}
781 864
 		date_default_timezone_set('UTC');
782 865
 		$check_date = new Datetime($date);
783 866
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
784 867
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
785
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
868
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
869
+			return array();
870
+		}
786 871
 		$data = $Common->getData($url);
787 872
 		$dom = new DomDocument();
788 873
 		$dom->loadXML($data);
789
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
874
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
875
+			return array();
876
+		}
790 877
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
791 878
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
792 879
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -795,7 +882,9 @@  discard block
 block discarded – undo
795 882
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
796 883
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
797 884
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
798
-		} else return array();
885
+		} else {
886
+			return array();
887
+		}
799 888
 	}
800 889
 
801 890
 	/**
@@ -809,7 +898,9 @@  discard block
 block discarded – undo
809 898
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
810 899
 		$check_date = new Datetime($date);
811 900
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
812
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
901
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
902
+			return array();
903
+		}
813 904
 		$data = $Common->getData($url);
814 905
 		if ($data != '') {
815 906
 			$table = $Common->table2array($data);
@@ -838,7 +929,9 @@  discard block
 block discarded – undo
838 929
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
839 930
 		$check_date = new Datetime($date);
840 931
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
841
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
932
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
933
+			return array();
934
+		}
842 935
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
843 936
 		$data = $Common->getData($url,'post',$post);
844 937
 		//echo $data;
@@ -848,11 +941,19 @@  discard block
 block discarded – undo
848 941
 		if ($data != '') {
849 942
 			$table = $Common->table2array($data);
850 943
 			$flight = $table;
851
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
852
-			else $departureTime = '';
853
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
854
-			else $departureAirport = '';
855
-		} else return array();
944
+			if (isset($flight[5][4])) {
945
+				$departureTime = $flight[5][4];
946
+			} else {
947
+				$departureTime = '';
948
+			}
949
+			if (isset($flight[5][2])) {
950
+				$departureAirport = $flight[5][2];
951
+			} else {
952
+				$departureAirport = '';
953
+			}
954
+		} else {
955
+			return array();
956
+		}
856 957
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
857 958
 		$data = $Common->getData($url,'post',$post);
858 959
 		if ($data != '') {
@@ -865,10 +966,14 @@  discard block
 block discarded – undo
865 966
 			    $arrivalTime = '';
866 967
 			    $arrivalAirport = '';
867 968
 			}
868
-		} else return array();
969
+		} else {
970
+			return array();
971
+		}
869 972
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
870 973
 		$json = $Common->getData($url);
871
-		if ($json == '') return array();
974
+		if ($json == '') {
975
+			return array();
976
+		}
872 977
 		$parsed_json = json_decode($json);
873 978
 		$airports = $parsed_json->{'suggestList'};
874 979
 		if (count($airports) > 0) {
@@ -883,7 +988,9 @@  discard block
 block discarded – undo
883 988
 		}
884 989
 		if (isset($DepartureAirportIata)) {
885 990
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
886
-		} else return array();
991
+		} else {
992
+			return array();
993
+		}
887 994
 	}
888 995
 
889 996
 	/*
@@ -895,7 +1002,9 @@  discard block
 block discarded – undo
895 1002
 	public function fetchSchedule($ident,$date = 'NOW') {
896 1003
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
897 1004
 		//$Common = new Common();
898
-		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
1005
+		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) {
1006
+			return array();
1007
+		}
899 1008
 		$airline_icao = '';
900 1009
 		if (!is_numeric(substr($ident, 0, 3)))
901 1010
 		{
@@ -1130,18 +1239,27 @@  discard block
 block discarded – undo
1130 1239
 					if (strlen($airline_icao) == 3) {
1131 1240
 						$Spotter = new Spotter($this->db);
1132 1241
 						$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
1133
-						if (isset($airline_info[0]['iata'])) $airline_icao = $airline_info[0]['iata'];
1242
+						if (isset($airline_info[0]['iata'])) {
1243
+							$airline_icao = $airline_info[0]['iata'];
1244
+						}
1134 1245
 					}
1135 1246
 					// Randomly use a generic function to get hours
1136 1247
 					if (strlen($airline_icao) == 2) {
1137
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1248
+						if (!isset($globalSchedulesSources)) {
1249
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1250
+						}
1138 1251
 						if (count($globalSchedulesSources) > 0) {
1139 1252
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1140 1253
 							$source = $globalSchedulesSources[$rand];
1141
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1142
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1254
+							if ($source == 'flightmapper') {
1255
+								return $this->getFlightMapper($ident);
1256
+							} elseif ($source == 'costtotravel') {
1257
+								return $this->getCostToTravel($ident);
1258
+							}
1143 1259
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1144
-							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') return $this->getFlightAware($ident);
1260
+							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') {
1261
+								return $this->getFlightAware($ident);
1262
+							}
1145 1263
 						}
1146 1264
 					}
1147 1265
 			}
Please login to merge, or discard this patch.
live-geojson.php 3 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -14,23 +14,23 @@  discard block
 block discarded – undo
14 14
 $usecoord = false;
15 15
 if (isset($_GET['test'])) exit();
16 16
 if (isset($_GET['tracker'])) {
17
-    $tracker = true;
17
+	$tracker = true;
18 18
 }
19 19
 if (isset($_GET['marine'])) {
20
-    $marine = true;
20
+	$marine = true;
21 21
 }
22 22
 if ($tracker) {
23
-    require_once('require/class.Tracker.php');
24
-    require_once('require/class.TrackerLive.php');
25
-    require_once('require/class.TrackerArchive.php');
23
+	require_once('require/class.Tracker.php');
24
+	require_once('require/class.TrackerLive.php');
25
+	require_once('require/class.TrackerArchive.php');
26 26
 } elseif ($marine) {
27
-    require_once('require/class.Marine.php');
28
-    require_once('require/class.MarineLive.php');
29
-    require_once('require/class.MarineArchive.php');
27
+	require_once('require/class.Marine.php');
28
+	require_once('require/class.MarineLive.php');
29
+	require_once('require/class.MarineArchive.php');
30 30
 } else {
31
-    require_once('require/class.Spotter.php');
32
-    require_once('require/class.SpotterLive.php');
33
-    require_once('require/class.SpotterArchive.php');
31
+	require_once('require/class.Spotter.php');
32
+	require_once('require/class.SpotterLive.php');
33
+	require_once('require/class.SpotterArchive.php');
34 34
 }
35 35
 
36 36
 $begintime = microtime(true);
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 $Common = new Common();
51 51
 
52 52
 if (isset($_GET['download'])) {
53
-    if ($_GET['download'] == "true")
54
-    {
53
+	if ($_GET['download'] == "true")
54
+	{
55 55
 	header('Content-disposition: attachment; filename="flightairmap.json"');
56
-    }
56
+	}
57 57
 }
58 58
 header('Content-Type: text/javascript');
59 59
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	$usecoord = true;
132 132
 	$coord = explode(',',$_GET['coord']);
133 133
 	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
134
-	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
134
+		&& $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
135 135
 		if ($tracker) {
136 136
 			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
137 137
 		} elseif ($marine) {
@@ -635,17 +635,17 @@  discard block
 block discarded – undo
635 635
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
636 636
 				
637 637
 				if (
638
-				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
639
-				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
638
+					(isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
639
+					|| ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
640 640
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
641 641
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
642
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
643
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
644
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
645
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
646
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
647
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
648
-				    ) {
642
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
643
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
644
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
645
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
646
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
647
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
648
+					) {
649 649
 					if ($tracker) {
650 650
 						if ($from_archive || $globalArchive) {
651 651
 							$spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid']);
@@ -653,9 +653,9 @@  discard block
 block discarded – undo
653 653
 							$spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']);
654 654
 						}
655 655
 						if (((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') ||
656
-						    (!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && 
657
-						    isset($_GET['zoom']) && $_GET['zoom'] > 12 && 
658
-						    isset($spotter_item['type']) && (
656
+							(!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && 
657
+							isset($_GET['zoom']) && $_GET['zoom'] > 12 && 
658
+							isset($spotter_item['type']) && (
659 659
 							$spotter_item['type'] == 'Firetruck' ||
660 660
 							$spotter_item['type'] == 'Ambulance' ||
661 661
 							$spotter_item['type'] == 'Truck (18 Wheeler)' ||
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 							$spotter_item['type'] == 'Jeep' ||
668 668
 							$spotter_item['type'] == 'Motorcycle' ||
669 669
 							$spotter_item['type'] == 'Car'
670
-						    )
670
+							)
671 671
 						) {
672 672
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
673 673
 							$MapMatching = new MapMatching();
@@ -770,75 +770,75 @@  discard block
 block discarded – undo
770 770
 				}
771 771
 				
772 772
 				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
773
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
774
-				     && (isset($spotter_item['departure_airport']) 
775
-				        && $spotter_item['departure_airport'] != 'NA' 
776
-				        && isset($spotter_item['arrival_airport']) 
777
-				        && $spotter_item['arrival_airport'] != 'NA' 
778
-				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
779
-				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
780
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
781
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
782
-				    if (isset($spotter_item['departure_airport_latitude'])) {
773
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
774
+					 && (isset($spotter_item['departure_airport']) 
775
+						&& $spotter_item['departure_airport'] != 'NA' 
776
+						&& isset($spotter_item['arrival_airport']) 
777
+						&& $spotter_item['arrival_airport'] != 'NA' 
778
+						&& ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
779
+							|| (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
780
+					if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
781
+					else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
782
+					if (isset($spotter_item['departure_airport_latitude'])) {
783 783
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
784
-				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
784
+					} elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
785 785
 					$dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
786 786
 					if (isset($dairport[0]['latitude'])) {
787
-					    $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
787
+						$output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
788 788
 					}
789
-				    }
790
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
789
+					}
790
+					if (isset($spotter_item['arrival_airport_latitude'])) {
791 791
 					$output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].'],';
792
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
792
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
793 793
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
794 794
 					if (isset($aairport[0]['latitude'])) {
795
-					    $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],';
795
+						$output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],';
796 796
 					}
797
-				    }
798
-				    $output_air  = substr($output_air, 0, -1);
799
-				    $output_air .= ']}},';
800
-				    $output .= $output_air;
801
-				    unset($output_air);
797
+					}
798
+					$output_air  = substr($output_air, 0, -1);
799
+					$output_air .= ']}},';
800
+					$output .= $output_air;
801
+					unset($output_air);
802 802
 				}
803 803
 
804 804
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
805 805
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
806 806
 				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
807
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
808
-				     && (isset($spotter_item['arrival_airport']) 
809
-				        && $spotter_item['arrival_airport'] != 'NA' 
810
-				        && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") 
811
-				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
812
-				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
813
-				    $havedata = false;
814
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
807
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
808
+					 && (isset($spotter_item['arrival_airport']) 
809
+						&& $spotter_item['arrival_airport'] != 'NA' 
810
+						&& ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") 
811
+							|| (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
812
+							|| (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
813
+					$havedata = false;
814
+					if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
+					else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
816 816
 				    
817
-				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
818
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
817
+					//$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
818
+					if (isset($spotter_item['arrival_airport_latitude'])) {
819 819
 					//$output_dest .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']';
820 820
 					$end_lon = $spotter_item['arrival_airport_longitude'];
821 821
 					$end_lat = $spotter_item['arrival_airport_latitude'];
822 822
 					$havedata = true;
823
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
823
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
824 824
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
825 825
 					if (isset($aairport[0]['latitude'])) {
826
-					    //$output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
827
-					    $end_lon = $aairport[0]['longitude'];
828
-					    $end_lat = $aairport[0]['latitude'];
829
-					    $havedata = true;
826
+						//$output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
827
+						$end_lon = $aairport[0]['longitude'];
828
+						$end_lat = $aairport[0]['latitude'];
829
+						$havedata = true;
830 830
 					}
831
-				    }
832
-				    if ($havedata) {
831
+					}
832
+					if ($havedata) {
833 833
 					$line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon);
834 834
 					foreach ($line[0] as $coord) {
835 835
 						$output_dest .= '['.$coord[0].','.$coord[1].'],';
836 836
 					}
837 837
 					$output_dest  = substr($output_dest, 0, -1);
838
-				    }
839
-				    $output_dest .= ']}},';
840
-				    if ($havedata) $output .= $output_dest;
841
-				    unset($output_dest);
838
+					}
839
+					$output_dest .= ']}},';
840
+					if ($havedata) $output .= $output_dest;
841
+					unset($output_dest);
842 842
 				}
843 843
 			}
844 844
 			$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -64,18 +64,18 @@  discard block
 block discarded – undo
64 64
 $min = true;
65 65
 $allhistory = false;
66 66
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_STRING);
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
68
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
69
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
71
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
72
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
73
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING);
74
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
75
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
76
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
77
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
78
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'], FILTER_SANITIZE_STRING);
79 79
 
80 80
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
81 81
 	$min = true;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 $spotter_array = array();
85 85
 
86 86
 if (isset($_GET['ident'])) {
87
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
87
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
88 88
 	if ($tracker) {
89 89
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
90 90
 	} elseif ($marine) {
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 	$allhistory = true;
100 100
 } elseif (isset($_GET['flightaware_id'])) {
101
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
101
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
102 102
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
103 103
 	if (empty($spotter_array)) {
104 104
 		$from_archive = true;
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 	$allhistory = true;
108 108
 } elseif (isset($_GET['famtrack_id'])) {
109
-	$famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING));
109
+	$famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING));
110 110
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
111 111
 	$allhistory = true;
112 112
 } elseif (isset($_GET['fammarine_id'])) {
113
-	$fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING));
113
+	$fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING));
114 114
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
115 115
 	$allhistory = true;
116 116
 /*
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
 */
131 131
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min && !isset($_GET['archive'])) {
132 132
 	$usecoord = true;
133
-	$coord = explode(',',$_GET['coord']);
134
-	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
133
+	$coord = explode(',', $_GET['coord']);
134
+	if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
135 135
 	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
136 136
 		if ($tracker) {
137
-			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
137
+			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
138 138
 		} elseif ($marine) {
139
-			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
139
+			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
140 140
 		} else {
141
-			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);
141
+			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);
142 142
 		}
143 143
 	} else {
144 144
 		if ($tracker) {
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 	$from_archive = true;
154 154
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
155 155
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
156
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
157
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
158
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
159
-	$begindate = date('Y-m-d H:i:s',$begindate);
160
-	$enddate = date('Y-m-d H:i:s',$enddate);
161
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
156
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
157
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
158
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
159
+	$begindate = date('Y-m-d H:i:s', $begindate);
160
+	$enddate = date('Y-m-d H:i:s', $enddate);
161
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
162 162
 } elseif ($min) {
163 163
 	if ($tracker) {
164 164
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 #	$min = true;
171 171
 } else {
172 172
 	if ($tracker) {
173
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
173
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
174 174
 	} elseif ($marine) {
175
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
175
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
176 176
 	} else {
177
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
177
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
178 178
 	}
179 179
 }
180 180
 
181 181
 if ($usecoord) {
182 182
 	if (isset($_GET['archive'])) {
183
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
183
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
184 184
 	} else {
185 185
 		if ($tracker) {
186 186
 			$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 	if ($flightcnt == '') $flightcnt = 0;
194 194
 } else $flightcnt = 0;
195 195
 
196
-$sqltime = round(microtime(true)-$begintime,2);
196
+$sqltime = round(microtime(true) - $begintime, 2);
197 197
 
198
-$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
198
+$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
199 199
 if ($currenttime != '') $currenttime = round($currenttime/1000);
200 200
 
201 201
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		if (!empty($spotter_array) && is_array($spotter_array))
215 215
 		{
216 216
 			$output .= '"features": [';
217
-			foreach($spotter_array as $spotter_item)
217
+			foreach ($spotter_array as $spotter_item)
218 218
 			{
219 219
 				$j++;
220 220
 				unset($idistance);
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 */
272 272
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
273 273
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
274
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
275
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
274
+							if ($compress) $output .= '"c": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
275
+							else $output .= '"callsign": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
276 276
 							//'
277 277
 						} else {
278 278
 							if ($compress) $output .= '"c": "NA",';
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 						}
285 285
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
286 286
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
287
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
287
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
288 288
 						} elseif (isset($spotter_item['aircraft_type'])) {
289 289
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
290 290
 						} elseif (!$min) {
@@ -431,15 +431,15 @@  discard block
 block discarded – undo
431 431
 						if (isset($archivespeed) || $usenextlatlon) {
432 432
 							if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
433 433
 								if (isset($spotter_item['arrival_airport_latitude'])) {
434
-									$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
435
-									$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
434
+									$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
435
+									$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
436 436
 									$farr_lat = $spotter_item['arrival_airport_latitude'];
437 437
 									$farr_lon = $spotter_item['arrival_airport_longitude'];
438 438
 								} else {
439 439
 									$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
440 440
 									if (isset($aairport[0]['latitude'])) {
441
-										$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
442
-										$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
441
+										$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
442
+										$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
443 443
 										$farr_lat = $aairport[0]['latitude'];
444 444
 										$farr_lon = $aairport[0]['longitude'];
445 445
 									}
@@ -452,59 +452,59 @@  discard block
 block discarded – undo
452 452
 						if ($currenttime != '') {
453 453
 							if (strtotime($spotter_item['date']) < $currenttime) {
454 454
 								if (isset($archivespeed)) {
455
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
456
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
455
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
456
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
457 457
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
458 458
 									else {
459
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
460
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
459
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
460
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
461 461
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
462 462
 										else {
463
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
463
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
464 464
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
465 465
 										}
466 466
 									}
467 467
 								} elseif ($usenextlatlon) {
468
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
469
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
468
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
469
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
470 470
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
471 471
 									else {
472
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
473
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
472
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
473
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
474 474
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
475 475
 										else {
476
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
476
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
477 477
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
478 478
 										}
479 479
 									}
480 480
 								}
481 481
 							} else {
482 482
 								if (isset($archivespeed)) {
483
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
483
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
484 484
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
485 485
 								} elseif ($usenextlatlon) {
486
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
486
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
487 487
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
488 488
 								}
489 489
 							}
490 490
 						} else {
491 491
 							if (isset($archivespeed)) {
492
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
493
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
492
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
493
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
494 494
 								if (!isset($idistance) || $fdistance < $idistance) {
495 495
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
496 496
 								} else {
497
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed);
497
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed);
498 498
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
499 499
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
500 500
 								}
501 501
 							} elseif ($usenextlatlon) {
502
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
503
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
502
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
503
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
504 504
 								if (!isset($idistance) || $fdistance < $idistance) {
505 505
 										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
506 506
 								} else {
507
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading);
507
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading);
508 508
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
509 509
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
510 510
 								}
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 
514 514
 						if (!$min) $output .= '"image": "'.$image.'",';
515 515
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
516
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
516
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
517 517
 						}
518 518
 						if (isset($spotter_item['image_source_website'])) {
519 519
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
539 539
 						}
540 540
 						if (isset($spotter_item['acars'])) {
541
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
541
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
542 542
 						}
543 543
 						// type when not aircraft ?
544 544
 						if (isset($spotter_item['type'])) {
@@ -558,12 +558,12 @@  discard block
 block discarded – undo
558 558
 								if ($currenttime != '') {
559 559
 									if (strtotime($spotter_item['date']) < $currenttime) {
560 560
 										if (!isset($archivespeed)) $archivespeed = 1;
561
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
562
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
561
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
562
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
563 563
 										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
564 564
 										else {
565
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
566
-											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
565
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
566
+											$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
567 567
 											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
568 568
 											else {
569 569
 												$output .= $spotter_item['longitude'].', ';
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
                 
643 643
 			}
644 644
 */
645
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
645
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
646 646
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
647 647
 				
648 648
 				if (
@@ -650,11 +650,11 @@  discard block
 block discarded – undo
650 650
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
651 651
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
652 652
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
653
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
653
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
654 654
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
655
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
655
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
656 656
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
657
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
657
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
658 658
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
659 659
 				    ) {
660 660
 					if ($tracker) {
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
684 684
 							$MapMatching = new MapMatching();
685 685
 							if (isset($spotter_item['date_iso_8601'])) {
686
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date_iso_8601'])))));
686
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date_iso_8601'])))));
687 687
 							} else {
688
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date'])))));
688
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date'])))));
689 689
 							}
690 690
 							$spotter_history_array = $MapMatching->match($spotter_history_array_mm);
691 691
 						}
@@ -717,9 +717,9 @@  discard block
 block discarded – undo
717 717
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
718 718
 							}
719 719
 							$output_history .= '[';
720
-							$output_history .=  $spotter_history['longitude'].', ';
721
-							$output_history .=  $spotter_history['latitude'].', ';
722
-							$output_history .=  $spotter_history['altitude']*30.48;
720
+							$output_history .= $spotter_history['longitude'].', ';
721
+							$output_history .= $spotter_history['latitude'].', ';
722
+							$output_history .= $spotter_history['altitude']*30.48;
723 723
 							$output_history .= '],';
724 724
 							/*
725 725
 							if ($from_archive === false) {
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 								$d = true;
743 743
 							}
744 744
 							$output_history .= '[';
745
-							$output_history .=  $spotter_history['longitude'].', ';
746
-							$output_history .=  $spotter_history['latitude'];
745
+							$output_history .= $spotter_history['longitude'].', ';
746
+							$output_history .= $spotter_history['latitude'];
747 747
 							$output_history .= '],';
748 748
 							/*
749 749
 							if ($from_archive === false) {
@@ -759,9 +759,9 @@  discard block
 block discarded – undo
759 759
 						//echo $output_history;
760 760
 						if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) {
761 761
 							$output_historyd = '[';
762
-							$output_historyd .=  $spotter_item['longitude'].', ';
763
-							$output_historyd .=  $spotter_item['latitude'];
764
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
762
+							$output_historyd .= $spotter_item['longitude'].', ';
763
+							$output_historyd .= $spotter_item['latitude'];
764
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
765 765
 							$output_historyd .= '],';
766 766
 							//$output_history = $output_historyd.$output_history;
767 767
 							$output_history = $output_history.$output_historyd;
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 							$last = array_pop($spotter_history_array);
770 770
 							$latitude = $last['latitude'];
771 771
 							$longitude = $last['longitude'];
772
-							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output);
772
+							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}', '"coordinates": ['.$longitude.', '.$latitude.']}', $output);
773 773
 						}
774 774
 						
775 775
 						$output_history  = substr($output_history, 0, -1);
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 					}
781 781
 				}
782 782
 				
783
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
783
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
784 784
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
785 785
 				     && (isset($spotter_item['departure_airport']) 
786 786
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 
815 815
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
816 816
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
817
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
817
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
818 818
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
819 819
 				     && (isset($spotter_item['arrival_airport']) 
820 820
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -841,11 +841,11 @@  discard block
 block discarded – undo
841 841
 					}
842 842
 				    }
843 843
 				    if ($havedata) {
844
-					$line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon);
844
+					$line = $Common->greatCircle($spotter_item['latitude'], $spotter_item['longitude'], $end_lat, $end_lon);
845 845
 					foreach ($line[0] as $coord) {
846 846
 						$output_dest .= '['.$coord[0].','.$coord[1].'],';
847 847
 					}
848
-					$output_dest  = substr($output_dest, 0, -1);
848
+					$output_dest = substr($output_dest, 0, -1);
849 849
 				    }
850 850
 				    $output_dest .= ']}},';
851 851
 				    if ($havedata) $output .= $output_dest;
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 			$output  = substr($output, 0, -1);
856 856
 			$output .= ']';
857 857
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
858
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
858
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
859 859
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
860 860
 			$output .= '"fc": "'.$j.'"';
861 861
 		} else {
Please login to merge, or discard this patch.
Braces   +336 added lines, -136 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 $tracker = false;
13 13
 $marine = false;
14 14
 $usecoord = false;
15
-if (isset($_GET['test'])) exit();
15
+if (isset($_GET['test'])) {
16
+	exit();
17
+}
16 18
 if (isset($_GET['tracker'])) {
17 19
     $tracker = true;
18 20
 }
@@ -57,29 +59,58 @@  discard block
 block discarded – undo
57 59
 }
58 60
 header('Content-Type: text/javascript');
59 61
 
60
-if (!isset($globalJsonCompress)) $compress = true;
61
-else $compress = $globalJsonCompress;
62
+if (!isset($globalJsonCompress)) {
63
+	$compress = true;
64
+} else {
65
+	$compress = $globalJsonCompress;
66
+}
62 67
 
63 68
 $from_archive = false;
64 69
 $min = true;
65 70
 $allhistory = false;
66 71
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_STRING);
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
73
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
74
+}
75
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
76
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
77
+}
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
80
+}
81
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
83
+}
84
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
85
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
86
+}
87
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
88
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
89
+}
90
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
91
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
92
+}
93
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
94
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
97
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
100
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
101
+}
102
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
103
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
104
+}
105
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') {
106
+	$filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_STRING);
107
+}
79 108
 
80 109
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
81 110
 	$min = true;
82
-} else $min = false;
111
+} else {
112
+	$min = false;
113
+}
83 114
 
84 115
 $spotter_array = array();
85 116
 
@@ -190,24 +221,38 @@  discard block
 block discarded – undo
190 221
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
191 222
 		}
192 223
 	}
193
-	if ($flightcnt == '') $flightcnt = 0;
194
-} else $flightcnt = 0;
224
+	if ($flightcnt == '') {
225
+		$flightcnt = 0;
226
+	}
227
+	} else {
228
+	$flightcnt = 0;
229
+}
195 230
 
196 231
 $sqltime = round(microtime(true)-$begintime,2);
197 232
 
198 233
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
199
-if ($currenttime != '') $currenttime = round($currenttime/1000);
234
+if ($currenttime != '') {
235
+	$currenttime = round($currenttime/1000);
236
+}
200 237
 
201
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
202
-else $usenextlatlon = true;
203
-if ($usenextlatlon === false) $currenttime = '';
238
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
239
+	$usenextlatlon = false;
240
+} else {
241
+	$usenextlatlon = true;
242
+}
243
+if ($usenextlatlon === false) {
244
+	$currenttime = '';
245
+}
204 246
 $j = 0;
205 247
 $prev_flightaware_id = '';
206 248
 $aircrafts_shadow = array();
207 249
 $output = '{';
208 250
 	$output .= '"type": "FeatureCollection",';
209
-		if ($min) $output .= '"minimal": "true",';
210
-		else $output .= '"minimal": "false",';
251
+		if ($min) {
252
+			$output .= '"minimal": "true",';
253
+		} else {
254
+			$output .= '"minimal": "false",';
255
+		}
211 256
 		//$output .= '"fc": "'.$flightcnt.'",';
212 257
 		$output .= '"sqt": "'.$sqltime.'",';
213 258
 
@@ -252,18 +297,29 @@  discard block
 block discarded – undo
252 297
 						}
253 298
 						$output .= '"properties": {';
254 299
 						if (isset($spotter_item['flightaware_id'])) {
255
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
256
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
300
+							if ($compress) {
301
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
302
+							} else {
303
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
304
+							}
257 305
 						} elseif (isset($spotter_item['famtrackid'])) {
258
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
259
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
306
+							if ($compress) {
307
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
308
+							} else {
309
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
310
+							}
260 311
 						} elseif (isset($spotter_item['fammarine_id'])) {
261
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
262
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
312
+							if ($compress) {
313
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
314
+							} else {
315
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
316
+							}
263 317
 						}
264 318
 						$output .= '"fc": "'.$flightcnt.'",';
265 319
 						$output .= '"sqt": "'.$sqltime.'",';
266
-						if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
320
+						if (isset($begindate)) {
321
+							$output .= '"archive_date": "'.$begindate.'",';
322
+						}
267 323
 
268 324
 /*
269 325
 							if ($min) $output .= '"minimal": "true",';
@@ -271,16 +327,25 @@  discard block
 block discarded – undo
271 327
 */
272 328
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
273 329
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
274
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
275
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
330
+							if ($compress) {
331
+								$output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
332
+							} else {
333
+								$output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
334
+							}
276 335
 							//'
277 336
 						} else {
278
-							if ($compress) $output .= '"c": "NA",';
279
-							else $output .= '"callsign": "NA",';
337
+							if ($compress) {
338
+								$output .= '"c": "NA",';
339
+							} else {
340
+								$output .= '"callsign": "NA",';
341
+							}
280 342
 						}
281 343
 						if (isset($spotter_item['registration'])) {
282
-							if ($compress) $output .= '"reg": '.json_encode($spotter_item['registration']).',';
283
-							else $output .= '"registration": '.json_encode($spotter_item['registration']).',';
344
+							if ($compress) {
345
+								$output .= '"reg": '.json_encode($spotter_item['registration']).',';
346
+							} else {
347
+								$output .= '"registration": '.json_encode($spotter_item['registration']).',';
348
+							}
284 349
 						}
285 350
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
286 351
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
@@ -291,20 +356,30 @@  discard block
 block discarded – undo
291 356
 							$output .= '"aircraft_name": "NA",';
292 357
 						}
293 358
 						if (isset($spotter_item['aircraft_icao'])) {
294
-							if ($compress) $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
295
-							else $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
359
+							if ($compress) {
360
+								$output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
361
+							} else {
362
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
363
+							}
296 364
 						}
297 365
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker && !$marine) {
298
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
299
-							else {
366
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
367
+								$spotter_item['aircraft_shadow'] = '';
368
+							} else {
300 369
 								$aircraft_icao = $spotter_item['aircraft_icao'];
301
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
302
-								else {
370
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
371
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
372
+								} else {
303 373
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
304
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
305
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
306
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
307
-									else $spotter_item['aircraft_shadow'] = '';
374
+									if (count($aircraft_info) > 0) {
375
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
376
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
377
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
378
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
379
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
380
+									} else {
381
+										$spotter_item['aircraft_shadow'] = '';
382
+									}
308 383
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
309 384
 								}
310 385
 							}
@@ -312,73 +387,139 @@  discard block
 block discarded – undo
312 387
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
313 388
 							if ($tracker) {
314 389
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
315
-									if ($compress) $output .= '"as": "ambulance.png",';
316
-									else $output .= '"aircraft_shadow": "ambulance.png",';
390
+									if ($compress) {
391
+										$output .= '"as": "ambulance.png",';
392
+									} else {
393
+										$output .= '"aircraft_shadow": "ambulance.png",';
394
+									}
317 395
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
318
-									if ($compress) $output .= '"as": "police.png",';
319
-									else $output .= '"aircraft_shadow": "police.png",';
396
+									if ($compress) {
397
+										$output .= '"as": "police.png",';
398
+									} else {
399
+										$output .= '"aircraft_shadow": "police.png",';
400
+									}
320 401
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
321
-									if ($compress) $output .= '"as": "ship.png",';
322
-									else $output .= '"aircraft_shadow": "ship.png",';
402
+									if ($compress) {
403
+										$output .= '"as": "ship.png",';
404
+									} else {
405
+										$output .= '"aircraft_shadow": "ship.png",';
406
+									}
323 407
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
324
-									if ($compress) $output .= '"as": "ship.png",';
325
-									else $output .= '"aircraft_shadow": "ship.png",';
408
+									if ($compress) {
409
+										$output .= '"as": "ship.png",';
410
+									} else {
411
+										$output .= '"aircraft_shadow": "ship.png",';
412
+									}
326 413
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
327
-									if ($compress) $output .= '"as": "ship.png",';
328
-									else $output .= '"aircraft_shadow": "ship.png",';
414
+									if ($compress) {
415
+										$output .= '"as": "ship.png",';
416
+									} else {
417
+										$output .= '"aircraft_shadow": "ship.png",';
418
+									}
329 419
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
330
-									if ($compress) $output .= '"as": "truck.png",';
331
-									else $output .= '"aircraft_shadow": "truck.png",';
420
+									if ($compress) {
421
+										$output .= '"as": "truck.png",';
422
+									} else {
423
+										$output .= '"aircraft_shadow": "truck.png",';
424
+									}
332 425
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
333
-									if ($compress) $output .= '"as": "truck.png",';
334
-									else $output .= '"aircraft_shadow": "truck.png",';
426
+									if ($compress) {
427
+										$output .= '"as": "truck.png",';
428
+									} else {
429
+										$output .= '"aircraft_shadow": "truck.png",';
430
+									}
335 431
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
336
-									if ($compress) $output .= '"as": "aircraft.png",';
337
-									else $output .= '"aircraft_shadow": "aircraft.png",';
432
+									if ($compress) {
433
+										$output .= '"as": "aircraft.png",';
434
+									} else {
435
+										$output .= '"aircraft_shadow": "aircraft.png",';
436
+									}
338 437
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
339
-									if ($compress) $output .= '"as": "aircraft.png",';
340
-									else $output .= '"aircraft_shadow": "aircraft.png",';
438
+									if ($compress) {
439
+										$output .= '"as": "aircraft.png",';
440
+									} else {
441
+										$output .= '"aircraft_shadow": "aircraft.png",';
442
+									}
341 443
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
342
-									if ($compress) $output .= '"as": "helico.png",';
343
-									else $output .= '"aircraft_shadow": "helico.png",';
444
+									if ($compress) {
445
+										$output .= '"as": "helico.png",';
446
+									} else {
447
+										$output .= '"aircraft_shadow": "helico.png",';
448
+									}
344 449
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
345
-									if ($compress) $output .= '"as": "rail.png",';
346
-									else $output .= '"aircraft_shadow": "rail.png",';
450
+									if ($compress) {
451
+										$output .= '"as": "rail.png",';
452
+									} else {
453
+										$output .= '"aircraft_shadow": "rail.png",';
454
+									}
347 455
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
348
-									if ($compress) $output .= '"as": "firetruck.png",';
349
-									else $output .= '"aircraft_shadow": "firetruck.png",';
456
+									if ($compress) {
457
+										$output .= '"as": "firetruck.png",';
458
+									} else {
459
+										$output .= '"aircraft_shadow": "firetruck.png",';
460
+									}
350 461
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
351
-									if ($compress) $output .= '"as": "bus.png",';
352
-									else $output .= '"aircraft_shadow": "bus.png",';
462
+									if ($compress) {
463
+										$output .= '"as": "bus.png",';
464
+									} else {
465
+										$output .= '"aircraft_shadow": "bus.png",';
466
+									}
353 467
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
354
-									if ($compress) $output .= '"as": "phone.png",';
355
-									else $output .= '"aircraft_shadow": "phone.png",';
468
+									if ($compress) {
469
+										$output .= '"as": "phone.png",';
470
+									} else {
471
+										$output .= '"aircraft_shadow": "phone.png",';
472
+									}
356 473
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
357
-									if ($compress) $output .= '"as": "jogger.png",';
358
-									else $output .= '"aircraft_shadow": "jogger.png",';
474
+									if ($compress) {
475
+										$output .= '"as": "jogger.png",';
476
+									} else {
477
+										$output .= '"aircraft_shadow": "jogger.png",';
478
+									}
359 479
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
360
-									if ($compress) $output .= '"as": "bike.png",';
361
-									else $output .= '"aircraft_shadow": "bike.png",';
480
+									if ($compress) {
481
+										$output .= '"as": "bike.png",';
482
+									} else {
483
+										$output .= '"aircraft_shadow": "bike.png",';
484
+									}
362 485
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
363
-									if ($compress) $output .= '"as": "motorcycle.png",';
364
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
486
+									if ($compress) {
487
+										$output .= '"as": "motorcycle.png",';
488
+									} else {
489
+										$output .= '"aircraft_shadow": "motorcycle.png",';
490
+									}
365 491
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
366
-									if ($compress) $output .= '"as": "balloon.png",';
367
-									else $output .= '"aircraft_shadow": "balloon.png",';
492
+									if ($compress) {
493
+										$output .= '"as": "balloon.png",';
494
+									} else {
495
+										$output .= '"aircraft_shadow": "balloon.png",';
496
+									}
368 497
 								} else {
369
-									if ($compress) $output .= '"as": "car.png",';
370
-									else $output .= '"aircraft_shadow": "car.png",';
498
+									if ($compress) {
499
+										$output .= '"as": "car.png",';
500
+									} else {
501
+										$output .= '"aircraft_shadow": "car.png",';
502
+									}
371 503
 								}
372 504
 							} elseif ($marine) {
373
-								if ($compress) $output .= '"as": "ship.png",';
374
-								else $output .= '"aircraft_shadow": "ship.png",';
505
+								if ($compress) {
506
+									$output .= '"as": "ship.png",';
507
+								} else {
508
+									$output .= '"aircraft_shadow": "ship.png",';
509
+								}
375 510
 							} else {
376
-								if ($compress) $output .= '"as": "default.png",';
377
-								else $output .= '"aircraft_shadow": "default.png",';
511
+								if ($compress) {
512
+									$output .= '"as": "default.png",';
513
+								} else {
514
+									$output .= '"aircraft_shadow": "default.png",';
515
+								}
378 516
 							}
379 517
 						} else {
380
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
381
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
518
+							if ($compress) {
519
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
520
+							} else {
521
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
522
+							}
382 523
 						}
383 524
 						if (isset($spotter_item['airline_name'])) {
384 525
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -386,8 +527,11 @@  discard block
 block discarded – undo
386 527
 							$output .= '"airline_name": "NA",';
387 528
 						}
388 529
 						if (isset($spotter_item['departure_airport'])) {
389
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
390
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
530
+							if ($compress) {
531
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
532
+							} else {
533
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
534
+							}
391 535
 						}
392 536
 						if (isset($spotter_item['departure_airport_city'])) {
393 537
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -399,8 +543,11 @@  discard block
 block discarded – undo
399 543
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
400 544
 						}
401 545
 						if (isset($spotter_item['arrival_airport'])) {
402
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
403
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
546
+							if ($compress) {
547
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
548
+							} else {
549
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
550
+							}
404 551
 						}
405 552
 						if (isset($spotter_item['arrival_airport_city'])) {
406 553
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -419,11 +566,17 @@  discard block
 block discarded – undo
419 566
 						}
420 567
 						
421 568
 						if (isset($spotter_item['real_altitude'])) {
422
-							if ($compress) $output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
423
-							else $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
569
+							if ($compress) {
570
+								$output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
571
+							} else {
572
+								$output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
573
+							}
424 574
 						} elseif (isset($spotter_item['altitude'])) {
425
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
426
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
575
+							if ($compress) {
576
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
577
+							} else {
578
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
579
+							}
427 580
 						}
428 581
 						
429 582
 						$heading = $spotter_item['heading'];
@@ -447,19 +600,24 @@  discard block
 block discarded – undo
447 600
 							}
448 601
 						}
449 602
 						
450
-						if ($compress)$output .= '"h": "'.$heading.'",';
451
-						else $output .= '"heading": "'.$heading.'",';
603
+						if ($compress) {
604
+							$output .= '"h": "'.$heading.'",';
605
+						} else {
606
+							$output .= '"heading": "'.$heading.'",';
607
+						}
452 608
 						if ($currenttime != '') {
453 609
 							if (strtotime($spotter_item['date']) < $currenttime) {
454 610
 								if (isset($archivespeed)) {
455 611
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
456 612
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
457
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
458
-									else {
613
+									if (!isset($idistance) || $fdistance < $idistance) {
614
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
615
+									} else {
459 616
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
460 617
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
461
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
462
-										else {
618
+										if (!isset($idistance) || $fdistance < $idistance) {
619
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
620
+										} else {
463 621
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
464 622
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
465 623
 										}
@@ -467,12 +625,14 @@  discard block
 block discarded – undo
467 625
 								} elseif ($usenextlatlon) {
468 626
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
469 627
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
470
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
471
-									else {
628
+									if (!isset($idistance) || $fdistance < $idistance) {
629
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
630
+									} else {
472 631
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
473 632
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
474
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
475
-										else {
633
+										if (!isset($idistance) || $fdistance < $idistance) {
634
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
635
+										} else {
476 636
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
477 637
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
478 638
 										}
@@ -511,7 +671,9 @@  discard block
 block discarded – undo
511 671
 							}
512 672
 						}
513 673
 
514
-						if (!$min) $output .= '"image": "'.$image.'",';
674
+						if (!$min) {
675
+							$output .= '"image": "'.$image.'",';
676
+						}
515 677
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
516 678
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
517 679
 						}
@@ -519,8 +681,11 @@  discard block
 block discarded – undo
519 681
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
520 682
 						}
521 683
 						if (isset($spotter_item['squawk'])) {
522
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
523
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
684
+							if ($compress) {
685
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
686
+							} else {
687
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
688
+							}
524 689
 						}
525 690
 						if (isset($spotter_item['squawk_usage'])) {
526 691
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -542,14 +707,23 @@  discard block
 block discarded – undo
542 707
 						}
543 708
 						// type when not aircraft ?
544 709
 						if (isset($spotter_item['type'])) {
545
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
546
-							else $output .= '"type": "'.$spotter_item['type'].'"';
710
+							if ($compress) {
711
+								$output .= '"t": "'.$spotter_item['type'].'"';
712
+							} else {
713
+								$output .= '"type": "'.$spotter_item['type'].'"';
714
+							}
547 715
 						} elseif ($marine) {
548
-							if ($compress) $output .= '"t": "ship"';
549
-							else $output .= '"type": "ship"';
716
+							if ($compress) {
717
+								$output .= '"t": "ship"';
718
+							} else {
719
+								$output .= '"type": "ship"';
720
+							}
550 721
 						} else {
551
-							if ($compress) $output .= '"t": "aircraft"';
552
-							else $output .= '"type": "aircraft"';
722
+							if ($compress) {
723
+								$output .= '"t": "aircraft"';
724
+							} else {
725
+								$output .= '"type": "aircraft"';
726
+							}
553 727
 						}
554 728
 						$output .= '},';
555 729
 						$output .= '"geometry": {';
@@ -557,15 +731,19 @@  discard block
 block discarded – undo
557 731
 								$output .= '"coordinates": [';
558 732
 								if ($currenttime != '') {
559 733
 									if (strtotime($spotter_item['date']) < $currenttime) {
560
-										if (!isset($archivespeed)) $archivespeed = 1;
734
+										if (!isset($archivespeed)) {
735
+											$archivespeed = 1;
736
+										}
561 737
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
562 738
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
563
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
564
-										else {
739
+										if (!isset($idistance) || $fdistance < $idistance) {
740
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
741
+										} else {
565 742
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
566 743
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
567
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
568
-											else {
744
+											if (!isset($idistance) || $fdistance < $idistance) {
745
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
746
+											} else {
569 747
 												$output .= $spotter_item['longitude'].', ';
570 748
 												$output .= $spotter_item['latitude'];
571 749
 											}
@@ -643,7 +821,9 @@  discard block
 block discarded – undo
643 821
 			}
644 822
 */
645 823
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
646
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
824
+				if ($history == '' && isset($_COOKIE['history'])) {
825
+					$history = $_COOKIE['history'];
826
+				}
647 827
 				
648 828
 				if (
649 829
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -713,8 +893,11 @@  discard block
 block discarded – undo
713 893
 									$output_history .= ']}},';
714 894
 									$output .= $output_history;
715 895
 								}
716
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
717
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
896
+								if ($compress) {
897
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
898
+								} else {
899
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
900
+								}
718 901
 							}
719 902
 							$output_history .= '[';
720 903
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -735,10 +918,15 @@  discard block
 block discarded – undo
735 918
 							if ($d == false) {
736 919
 								if ($compress) {
737 920
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
738
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
739
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
921
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
922
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
923
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
924
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
925
+									}
740 926
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
741
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
927
+								} else {
928
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
929
+								}
742 930
 								$d = true;
743 931
 							}
744 932
 							$output_history .= '[';
@@ -761,7 +949,9 @@  discard block
 block discarded – undo
761 949
 							$output_historyd = '[';
762 950
 							$output_historyd .=  $spotter_item['longitude'].', ';
763 951
 							$output_historyd .=  $spotter_item['latitude'];
764
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
952
+							if (isset($spotter_history['altitude'])) {
953
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
954
+							}
765 955
 							$output_historyd .= '],';
766 956
 							//$output_history = $output_historyd.$output_history;
767 957
 							$output_history = $output_history.$output_historyd;
@@ -788,8 +978,11 @@  discard block
 block discarded – undo
788 978
 				        && $spotter_item['arrival_airport'] != 'NA' 
789 979
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
790 980
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
791
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
792
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
981
+				    if ($compress) {
982
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
983
+				    } else {
984
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
985
+				    }
793 986
 				    if (isset($spotter_item['departure_airport_latitude'])) {
794 987
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
795 988
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -822,8 +1015,11 @@  discard block
 block discarded – undo
822 1015
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
823 1016
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
824 1017
 				    $havedata = false;
825
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
826
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1018
+				    if ($compress) {
1019
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1020
+				    } else {
1021
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1022
+				    }
827 1023
 				    
828 1024
 				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
829 1025
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -848,7 +1044,9 @@  discard block
 block discarded – undo
848 1044
 					$output_dest  = substr($output_dest, 0, -1);
849 1045
 				    }
850 1046
 				    $output_dest .= ']}},';
851
-				    if ($havedata) $output .= $output_dest;
1047
+				    if ($havedata) {
1048
+				    	$output .= $output_dest;
1049
+				    }
852 1050
 				    unset($output_dest);
853 1051
 				}
854 1052
 			}
@@ -856,7 +1054,9 @@  discard block
 block discarded – undo
856 1054
 			$output .= ']';
857 1055
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
858 1056
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
859
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1057
+			if (isset($begindate)) {
1058
+				$output .= '"archive_date": "'.$begindate.'",';
1059
+			}
860 1060
 			$output .= '"fc": "'.$j.'"';
861 1061
 		} else {
862 1062
 			$output .= '"features": ';
Please login to merge, or discard this patch.
scripts/update_db.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
12
+	foreach ($output as $line) if (strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
13 13
 	if ($j > 1) {
14 14
 		echo "Script is already runnning...";
15 15
 		die();
Please login to merge, or discard this patch.
Braces   +30 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -29,14 +31,18 @@  discard block
 block discarded – undo
29 31
 			$update_db->update_notam();
30 32
 		}
31 33
 		$update_db->insert_last_notam_update();
32
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
34
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
35
+		echo "NOTAM are only updated once a day.\n";
36
+	}
33 37
 	if ($update_db->check_last_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
34 38
 		$update_db->update_all();
35 39
 	//	require_once(dirname(__FILE__).'/../require/class.Spotter.php');
36 40
 	//	$Spotter = new Spotter();
37 41
 	//	$Spotter->updateFieldsFromOtherTables();
38 42
 		$update_db->insert_last_update();
39
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
43
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
44
+		echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
45
+	}
40 46
 	if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) {
41 47
 		echo "Check if new airspace version exist...";
42 48
 		echo $update_db->update_airspace_fam();
@@ -45,8 +51,11 @@  discard block
 block discarded – undo
45 51
 	if (isset($globalGeoid) && $globalGeoid && $update_db->check_last_geoid_update()) {
46 52
 		echo "Check if new geoid version exist...";
47 53
 		$error = $update_db->update_geoid_fam();
48
-		if ($error == '') $update_db->insert_last_geoid_update();
49
-		else echo $error;
54
+		if ($error == '') {
55
+			$update_db->insert_last_geoid_update();
56
+		} else {
57
+			echo $error;
58
+		}
50 59
 	}
51 60
 	if (isset($globalMarine) && $globalMarine && $update_db->check_last_marine_identity_update()) {
52 61
 		echo "Check if new marine identity version exist...";
@@ -64,13 +73,17 @@  discard block
 block discarded – undo
64 73
 			//echo "Done";
65 74
 		}
66 75
 		$update_db->insert_last_owner_update();
67
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
76
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
77
+		echo "Owner are only updated every 15 days.\n";
78
+	}
68 79
 
69 80
 	if ($update_db->check_last_airlines_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
70 81
 		echo "Updating airlines...\n";
71 82
 		echo $update_db->update_airlines_fam();
72 83
 		$update_db->insert_last_airlines_update();
73
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Airlines are only updated every 15 days.\n";
84
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
85
+		echo "Airlines are only updated every 15 days.\n";
86
+	}
74 87
 
75 88
 	if (isset($globalAccidents) && $globalAccidents && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
76 89
 		require_once(dirname(__FILE__).'/../require/class.Accident.php');
@@ -79,7 +92,9 @@  discard block
 block discarded – undo
79 92
 		if ($Accident->check_last_accidents_update()) {
80 93
 			$Accident->download_update();
81 94
 			$Accident->insert_last_accidents_update();
82
-		} else echo "Accidents are updated once a day.\n";
95
+		} else {
96
+			echo "Accidents are updated once a day.\n";
97
+		}
83 98
 	}
84 99
   
85 100
 }
@@ -92,7 +107,9 @@  discard block
 block discarded – undo
92 107
 		if ($METAR->check_last_update()) {
93 108
 			$METAR->addMETARCycle();
94 109
 			$METAR->insert_last_update();
95
-		} else echo "METAR are only updated every 30 minutes.\n";
110
+		} else {
111
+			echo "METAR are only updated every 30 minutes.\n";
112
+		}
96 113
 	}
97 114
 
98 115
 	if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
@@ -100,8 +117,10 @@  discard block
 block discarded – undo
100 117
 		//$update_db->update_oneworld();
101 118
 		$update_db->update_skyteam();
102 119
 		$update_db->insert_last_schedules_update();
103
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
104
-}
120
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
121
+		echo "Schedules are only updated every 15 days.\n";
122
+	}
123
+	}
105 124
 
106 125
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
107 126
 	echo "Updating statistics and archive old data...\n";
Please login to merge, or discard this patch.
require/class.Common.php 4 patches
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 	//protected $cookies = array();
8 8
 	
9 9
 	/**
10
-	* Get data from form result
11
-	* @param String $url form URL
12
-	* @param String $type type of submit form method (get or post)
13
-	* @param String|Array $data values form post method
14
-	* @param Array $headers header to submit with the form
15
-	* @return String the result
16
-	*/
10
+	 * Get data from form result
11
+	 * @param String $url form URL
12
+	 * @param String $type type of submit form method (get or post)
13
+	 * @param String|Array $data values form post method
14
+	 * @param Array $headers header to submit with the form
15
+	 * @return String the result
16
+	 */
17 17
 	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false) {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	/**
169
-	* Convert a HTML table to an array
170
-	* @param String $data HTML page
171
-	* @return Array array of the tables in HTML page
172
-	*/
169
+	 * Convert a HTML table to an array
170
+	 * @param String $data HTML page
171
+	 * @return Array array of the tables in HTML page
172
+	 */
173 173
 	public function table2array($data) {
174 174
 		if (!is_string($data)) return array();
175 175
 		if ($data == '') return array();
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
 	}
204 204
 	
205 205
 	/**
206
-	* Convert <p> part of a HTML page to an array
207
-	* @param String $data HTML page
208
-	* @return Array array of the <p> in HTML page
209
-	*/
206
+	 * Convert <p> part of a HTML page to an array
207
+	 * @param String $data HTML page
208
+	 * @return Array array of the <p> in HTML page
209
+	 */
210 210
 	public function text2array($data) {
211 211
 		$html = str_get_html($data);
212 212
 		if ($html === false) return array();
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
 	}
222 222
 
223 223
 	/**
224
-	* Give distance between 2 coordonnates
225
-	* @param Float $lat latitude of first point
226
-	* @param Float $lon longitude of first point
227
-	* @param Float $latc latitude of second point
228
-	* @param Float $lonc longitude of second point
229
-	* @param String $unit km else no unit used
230
-	* @return Float Distance in $unit
231
-	*/
224
+	 * Give distance between 2 coordonnates
225
+	 * @param Float $lat latitude of first point
226
+	 * @param Float $lon longitude of first point
227
+	 * @param Float $latc latitude of second point
228
+	 * @param Float $lonc longitude of second point
229
+	 * @param String $unit km else no unit used
230
+	 * @return Float Distance in $unit
231
+	 */
232 232
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233 233
 		if ($lat == $latc && $lon == $lonc) return 0;
234 234
 		$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;
@@ -246,12 +246,12 @@  discard block
 block discarded – undo
246 246
 	}
247 247
 
248 248
 	/**
249
-	* Give plunge between 2 altitudes and distance
250
-	* @param Float $initial_altitude altitude of first point in m
251
-	* @param Float $final_altitude altitude of second point in m
252
-	* @param String $distance distance between two points in m
253
-	* @return Float plunge
254
-	*/
249
+	 * Give plunge between 2 altitudes and distance
250
+	 * @param Float $initial_altitude altitude of first point in m
251
+	 * @param Float $final_altitude altitude of second point in m
252
+	 * @param String $distance distance between two points in m
253
+	 * @return Float plunge
254
+	 */
255 255
 	public function plunge($initial_altitude,$final_altitude,$distance) {
256 256
 		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
257 257
 		/*
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 	}
266 266
 
267 267
 	/**
268
-	* Give azimuth between 2 coordonnates
269
-	* @param Float $lat latitude of first point
270
-	* @param Float $lon longitude of first point
271
-	* @param Float $latc latitude of second point
272
-	* @param Float $lonc longitude of second point
273
-	* @return Float Azimuth
274
-	*/
268
+	 * Give azimuth between 2 coordonnates
269
+	 * @param Float $lat latitude of first point
270
+	 * @param Float $lon longitude of first point
271
+	 * @param Float $latc latitude of second point
272
+	 * @param Float $lonc longitude of second point
273
+	 * @return Float Azimuth
274
+	 */
275 275
 	public function azimuth($lat, $lon, $latc, $lonc) {
276 276
 		$dX = $latc - $lat;
277 277
 		$dY = $lonc - $lon;
@@ -282,11 +282,11 @@  discard block
 block discarded – undo
282 282
 	
283 283
 	
284 284
 	/**
285
-	* Check is distance realistic
286
-	* @param int $timeDifference the time between the reception of both messages
287
-	* @param float $distance distance covered
288
-	* @return whether distance is realistic
289
-	*/
285
+	 * Check is distance realistic
286
+	 * @param int $timeDifference the time between the reception of both messages
287
+	 * @param float $distance distance covered
288
+	 * @return whether distance is realistic
289
+	 */
290 290
 	public function withinThreshold ($timeDifference, $distance) {
291 291
 		$x = abs($timeDifference);
292 292
 		$d = abs($distance);
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 	}
337 337
 	
338 338
 	/**
339
-	* Copy folder contents
340
-	* @param       string   $source    Source path
341
-	* @param       string   $dest      Destination path
342
-	* @return      bool     Returns true on success, false on failure
343
-	*/
339
+	 * Copy folder contents
340
+	 * @param       string   $source    Source path
341
+	 * @param       string   $dest      Destination path
342
+	 * @return      bool     Returns true on success, false on failure
343
+	 */
344 344
 	public function xcopy($source, $dest)
345 345
 	{
346 346
 		$files = glob($source.'*.*');
@@ -352,20 +352,20 @@  discard block
 block discarded – undo
352 352
 	}
353 353
 	
354 354
 	/**
355
-	* Check if an url exist
356
-	* @param	String $url url to check
357
-	* @return	bool Return true on succes false on failure
358
-	*/
355
+	 * Check if an url exist
356
+	 * @param	String $url url to check
357
+	 * @return	bool Return true on succes false on failure
358
+	 */
359 359
 	public function urlexist($url){
360 360
 		$headers=get_headers($url);
361 361
 		return stripos($headers[0],"200 OK")?true:false;
362 362
 	}
363 363
 	
364 364
 	/**
365
-	* Convert hexa to string
366
-	* @param	String $hex data in hexa
367
-	* @return	String Return result
368
-	*/
365
+	 * Convert hexa to string
366
+	 * @param	String $hex data in hexa
367
+	 * @return	String Return result
368
+	 */
369 369
 	public function hex2str($hex) {
370 370
 		$str = '';
371 371
 		$hexln = strlen($hex);
@@ -374,10 +374,10 @@  discard block
 block discarded – undo
374 374
 	}
375 375
 	
376 376
 	/**
377
-	* Convert hexa color to rgb
378
-	* @param	String $hex data in hexa
379
-	* @return	String Return result
380
-	*/
377
+	 * Convert hexa color to rgb
378
+	 * @param	String $hex data in hexa
379
+	 * @return	String Return result
380
+	 */
381 381
 	public function hex2rgb($hex) {
382 382
 		$hex = str_replace('#','',$hex);
383 383
 		return sscanf($hex, "%02x%02x%02x"); 
@@ -455,9 +455,9 @@  discard block
 block discarded – undo
455 455
 	}
456 456
 	
457 457
 	/**
458
-	* Returns list of available locales
459
-	*
460
-	* @return array
458
+	 * Returns list of available locales
459
+	 *
460
+	 * @return array
461 461
 	 */
462 462
 	public function listLocaleDir()
463 463
 	{
@@ -556,100 +556,100 @@  discard block
 block discarded – undo
556 556
 	public function remove_accents($string) {
557 557
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
558 558
 		$chars = array(
559
-		    // Decompositions for Latin-1 Supplement
560
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
561
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
562
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
563
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
564
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
565
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
566
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
567
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
568
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
569
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
570
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
571
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
572
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
573
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
574
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
575
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
576
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
577
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
578
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
579
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
580
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
581
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
582
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
583
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
584
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
585
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
586
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
587
-		    chr(195).chr(191) => 'y',
588
-		    // Decompositions for Latin Extended-A
589
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
590
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
591
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
592
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
593
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
594
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
595
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
596
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
597
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
598
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
599
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
600
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
601
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
602
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
603
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
604
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
605
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
606
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
607
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
608
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
609
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
610
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
611
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
612
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
613
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
614
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
615
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
616
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
617
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
618
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
619
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
620
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
621
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
622
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
623
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
624
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
625
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
626
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
627
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
628
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
629
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
630
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
631
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
632
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
633
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
634
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
635
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
636
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
637
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
638
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
639
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
640
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
641
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
642
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
643
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
644
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
645
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
646
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
647
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
648
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
649
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
650
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
651
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
652
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
559
+			// Decompositions for Latin-1 Supplement
560
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
561
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
562
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
563
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
564
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
565
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
566
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
567
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
568
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
569
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
570
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
571
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
572
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
573
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
574
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
575
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
576
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
577
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
578
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
579
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
580
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
581
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
582
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
583
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
584
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
585
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
586
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
587
+			chr(195).chr(191) => 'y',
588
+			// Decompositions for Latin Extended-A
589
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
590
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
591
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
592
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
593
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
594
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
595
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
596
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
597
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
598
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
599
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
600
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
601
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
602
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
603
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
604
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
605
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
606
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
607
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
608
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
609
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
610
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
611
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
612
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
613
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
614
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
615
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
616
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
617
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
618
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
619
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
620
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
621
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
622
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
623
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
624
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
625
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
626
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
627
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
628
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
629
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
630
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
631
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
632
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
633
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
634
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
635
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
636
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
637
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
638
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
639
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
640
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
641
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
642
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
643
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
644
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
645
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
646
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
647
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
648
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
649
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
650
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
651
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
652
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
653 653
 		);
654 654
 		$string = strtr($string, $chars);
655 655
 		return $string;
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 			$dfX = $first_pass[$j][0];
791 791
 			$dfDiffLong = abs($dfX - $dfPrevX);
792 792
 			if ($dfDiffLong > $dfDiffSpace &&
793
-			    (($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
793
+				(($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
794 794
 			{
795 795
 				$bHasBigDiff = true;
796 796
 			} else if ($dfDiffLong > $dfMaxSmallDiffLong) {
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
 					$dfX2 = floatval($first_pass[$k][0]);
811 811
 					$dfY2 = floatval($first_pass[$k][1]);
812 812
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
813
-					    $k+1 < count($first_pass) &&
814
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
813
+						$k+1 < count($first_pass) &&
814
+						$first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
815 815
 					{
816 816
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
817 817
 						$k++;
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
820 820
 						continue;
821 821
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
822
-					    $k+1 < $first_pass_ln &&
823
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
822
+						$k+1 < $first_pass_ln &&
823
+						$first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
824 824
 					{
825 825
 						$poNewLS[] = array(180, $first_pass[$k][1]);
826 826
 						$k++;
Please login to merge, or discard this patch.
Braces   +110 added lines, -48 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
 		} else {
38 38
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
39 39
 		}
40
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
40
+		if ($timeout == '') {
41
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
42
+		} else {
43
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
44
+		}
42 45
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
43 46
 		if ($type == 'post') {
44 47
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -51,7 +54,9 @@  discard block
 block discarded – undo
51 54
 			} else {
52 55
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
53 56
 			}
54
-		} elseif ($type != 'get' && $type != '') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
57
+		} elseif ($type != 'get' && $type != '') {
58
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
59
+		}
55 60
 		if ($headers != '') {
56 61
 			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
57 62
 		}
@@ -95,8 +100,9 @@  discard block
 block discarded – undo
95 100
 	private function curlResponseHeaderCallback($ch, $headerLine) {
96 101
 		//global $cookies;
97 102
 		$cookies = array();
98
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
99
-			$cookies[] = $cookie;
103
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
104
+					$cookies[] = $cookie;
105
+		}
100 106
 		return strlen($headerLine); // Needed by curl
101 107
 	}
102 108
 
@@ -107,7 +113,9 @@  discard block
 block discarded – undo
107 113
 		curl_setopt($ch, CURLOPT_URL, $url);
108 114
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
109 115
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
110
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
116
+		if ($referer != '') {
117
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
118
+		}
111 119
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
112 120
 			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
113 121
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
@@ -119,7 +127,9 @@  discard block
 block discarded – undo
119 127
 		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');
120 128
 		curl_setopt($ch, CURLOPT_FILE, $fp);
121 129
 		curl_exec($ch);
122
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
130
+		if (curl_errno($ch) && $globalDebug) {
131
+			echo 'Download error: '.curl_error($ch);
132
+		}
123 133
 		curl_close($ch);
124 134
 		fclose($fp);
125 135
 	}
@@ -127,12 +137,16 @@  discard block
 block discarded – undo
127 137
 	public static function gunzip($in_file,$out_file_name = '') {
128 138
 		//echo $in_file.' -> '.$out_file_name."\n";
129 139
 		$buffer_size = 4096; // read 4kb at a time
130
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
140
+		if ($out_file_name == '') {
141
+			$out_file_name = str_replace('.gz', '', $in_file);
142
+		}
131 143
 		if ($in_file != '' && file_exists($in_file)) {
132 144
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
133
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
134
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
135
-			else {
145
+			if (function_exists('gzopen')) {
146
+				$file = gzopen($in_file,'rb');
147
+			} elseif (function_exists('gzopen64')) {
148
+				$file = gzopen64($in_file,'rb');
149
+			} else {
136 150
 				echo 'gzopen not available';
137 151
 				die;
138 152
 			}
@@ -148,11 +162,14 @@  discard block
 block discarded – undo
148 162
 	public static function bunzip2($in_file,$out_file_name = '') {
149 163
 		//echo $in_file.' -> '.$out_file_name."\n";
150 164
 		$buffer_size = 4096; // read 4kb at a time
151
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
165
+		if ($out_file_name == '') {
166
+			$out_file_name = str_replace('.bz2', '', $in_file);
167
+		}
152 168
 		if ($in_file != '' && file_exists($in_file)) {
153 169
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
154
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
155
-			else {
170
+			if (function_exists('bzopen')) {
171
+				$file = bzopen($in_file,'rb');
172
+			} else {
156 173
 				echo 'bzopen not available';
157 174
 				die;
158 175
 			}
@@ -171,10 +188,16 @@  discard block
 block discarded – undo
171 188
 	* @return Array array of the tables in HTML page
172 189
 	*/
173 190
 	public function table2array($data) {
174
-		if (!is_string($data)) return array();
175
-		if ($data == '') return array();
191
+		if (!is_string($data)) {
192
+			return array();
193
+		}
194
+		if ($data == '') {
195
+			return array();
196
+		}
176 197
 		$html = str_get_html($data);
177
-		if ($html === false) return array();
198
+		if ($html === false) {
199
+			return array();
200
+		}
178 201
 		$tabledata=array();
179 202
 		foreach($html->find('tr') as $element)
180 203
 		{
@@ -209,7 +232,9 @@  discard block
 block discarded – undo
209 232
 	*/
210 233
 	public function text2array($data) {
211 234
 		$html = str_get_html($data);
212
-		if ($html === false) return array();
235
+		if ($html === false) {
236
+			return array();
237
+		}
213 238
 		$tabledata=array();
214 239
 		foreach($html->find('p') as $element)
215 240
 		{
@@ -230,7 +255,9 @@  discard block
 block discarded – undo
230 255
 	* @return Float Distance in $unit
231 256
 	*/
232 257
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233
-		if ($lat == $latc && $lon == $lonc) return 0;
258
+		if ($lat == $latc && $lon == $lonc) {
259
+			return 0;
260
+		}
234 261
 		$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;
235 262
 		if ($unit == "km") {
236 263
 			return round($dist * 1.609344);
@@ -276,7 +303,9 @@  discard block
 block discarded – undo
276 303
 		$dX = $latc - $lat;
277 304
 		$dY = $lonc - $lon;
278 305
 		$azimuth = rad2deg(atan2($dY,$dX));
279
-		if ($azimuth < 0) return $azimuth+360;
306
+		if ($azimuth < 0) {
307
+			return $azimuth+360;
308
+		}
280 309
 		return $azimuth;
281 310
 	}
282 311
 	
@@ -290,10 +319,16 @@  discard block
 block discarded – undo
290 319
 	public function withinThreshold ($timeDifference, $distance) {
291 320
 		$x = abs($timeDifference);
292 321
 		$d = abs($distance);
293
-		if ($x == 0 || $d == 0) return true;
322
+		if ($x == 0 || $d == 0) {
323
+			return true;
324
+		}
294 325
 		// may be due to Internet jitter; distance is realistic
295
-		if ($x < 0.7 && $d < 2000) return true;
296
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
326
+		if ($x < 0.7 && $d < 2000) {
327
+			return true;
328
+		} else {
329
+			return $d/$x < 1500*0.27778;
330
+		}
331
+		// 1500 km/h max
297 332
 	}
298 333
 
299 334
 
@@ -322,11 +357,17 @@  discard block
 block discarded – undo
322 357
 	
323 358
 	public function convertDM($coord,$latlong) {
324 359
 		if ($latlong == 'latitude') {
325
-			if ($coord < 0) $NSEW = 'S';
326
-			else $NSEW = 'N';
360
+			if ($coord < 0) {
361
+				$NSEW = 'S';
362
+			} else {
363
+				$NSEW = 'N';
364
+			}
327 365
 		} else {
328
-			if ($coord < 0) $NSEW = 'W';
329
-			else $NSEW = 'E';
366
+			if ($coord < 0) {
367
+				$NSEW = 'W';
368
+			} else {
369
+				$NSEW = 'E';
370
+			}
330 371
 		}
331 372
 		$coord = abs($coord);
332 373
 		$deg = floor($coord);
@@ -369,7 +410,9 @@  discard block
 block discarded – undo
369 410
 	public function hex2str($hex) {
370 411
 		$str = '';
371 412
 		$hexln = strlen($hex);
372
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
413
+		for($i=0;$i<$hexln;$i+=2) {
414
+			$str .= chr(hexdec(substr($hex,$i,2)));
415
+		}
373 416
 		return $str;
374 417
 	}
375 418
 	
@@ -406,8 +449,11 @@  discard block
 block discarded – undo
406 449
 		$b = $lat2 - $lat1;
407 450
 		$c = -($a*$lat1+$b*$lon1);
408 451
 		$d = $a*$lat3+$b*$lon3+$c;
409
-		if ($d > -$approx && $d < $approx) return true;
410
-		else return false;
452
+		if ($d > -$approx && $d < $approx) {
453
+			return true;
454
+		} else {
455
+			return false;
456
+		}
411 457
 	}
412 458
 	
413 459
 	public function array_merge_noappend() {
@@ -466,7 +512,9 @@  discard block
 block discarded – undo
466 512
 			return $result;
467 513
 		}
468 514
 		$handle = @opendir('./locale');
469
-		if ($handle === false) return $result;
515
+		if ($handle === false) {
516
+			return $result;
517
+		}
470 518
 		while (false !== ($file = readdir($handle))) {
471 519
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
472 520
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -537,8 +585,9 @@  discard block
 block discarded – undo
537 585
 		$error = false; 
538 586
 		if ($fp_out = gzopen($dest, $mode)) { 
539 587
 			if ($fp_in = fopen($source,'rb')) { 
540
-				while (!feof($fp_in)) 
541
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
588
+				while (!feof($fp_in)) {
589
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
590
+				}
542 591
 				fclose($fp_in); 
543 592
 			} else {
544 593
 				$error = true; 
@@ -547,14 +596,17 @@  discard block
 block discarded – undo
547 596
 		} else {
548 597
 			$error = true; 
549 598
 		}
550
-		if ($error)
551
-			return false; 
552
-		else
553
-			return $dest; 
599
+		if ($error) {
600
+					return false;
601
+		} else {
602
+					return $dest;
603
+		}
554 604
 	} 
555 605
 	
556 606
 	public function remove_accents($string) {
557
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
607
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
608
+			return $string;
609
+		}
558 610
 		$chars = array(
559 611
 		    // Decompositions for Latin-1 Supplement
560 612
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -678,7 +730,9 @@  discard block
 block discarded – undo
678 730
 		$ip = gethostbyname($host);
679 731
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
680 732
 		$r = @socket_connect($s, $ip, $port);
681
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
733
+		if (!socket_set_nonblock($s)) {
734
+			echo "Unable to set nonblock on socket\n";
735
+		}
682 736
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
683 737
 			return $s;
684 738
 		}
@@ -723,18 +777,22 @@  discard block
 block discarded – undo
723 777
 		//NOTE: use a trailing slash for folders!!!
724 778
 		//see http://bugs.php.net/bug.php?id=27609
725 779
 		//see http://bugs.php.net/bug.php?id=30931
726
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
780
+		if ($path{strlen($path)-1}=='/') {
781
+			// recursively return a temporary file path
727 782
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
728
-		else if (is_dir($path))
729
-			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
783
+		} else if (is_dir($path)) {
784
+					return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
785
+		}
730 786
 		// check tmp file for read/write capabilities
731 787
 		$rm = file_exists($path);
732 788
 		$f = @fopen($path, 'a');
733
-		if ($f===false)
734
-			return false;
789
+		if ($f===false) {
790
+					return false;
791
+		}
735 792
 		fclose($f);
736
-		if (!$rm)
737
-			unlink($path);
793
+		if (!$rm) {
794
+					unlink($path);
795
+		}
738 796
 		return true;
739 797
 	}
740 798
 	
@@ -750,7 +808,9 @@  discard block
 block discarded – undo
750 808
 	 * @return Array Coordinate of the route
751 809
 	*/
752 810
 	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
753
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
811
+		if ($nbpts <= 2) {
812
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
813
+		}
754 814
 		$sx = deg2rad($begin_lon);
755 815
 		$sy = deg2rad($begin_lat);
756 816
 		$ex = deg2rad($end_lon);
@@ -759,7 +819,9 @@  discard block
 block discarded – undo
759 819
 		$h = $sy - $ey;
760 820
 		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
761 821
 		$g = 2.0*asin(sqrt($z));
762
-		if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
822
+		if ($g == M_PI || is_nan($g)) {
823
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
824
+		}
763 825
 		$first_pass = array();
764 826
 		$delta = 1.0/($nbpts-1);
765 827
 		for ($i =0; $i < $nbpts; ++$i) {
Please login to merge, or discard this patch.
Doc Comments   +15 added lines, -2 removed lines patch added patch discarded remove patch
@@ -100,6 +100,10 @@  discard block
 block discarded – undo
100 100
 		return strlen($headerLine); // Needed by curl
101 101
 	}
102 102
 
103
+	/**
104
+	 * @param string $url
105
+	 * @param string $file
106
+	 */
103 107
 	public static function download($url, $file, $referer = '') {
104 108
 		global $globalDebug, $globalProxy, $globalForceIPv4;
105 109
 		$fp = fopen($file, 'w');
@@ -124,6 +128,9 @@  discard block
 block discarded – undo
124 128
 		fclose($fp);
125 129
 	}
126 130
 
131
+	/**
132
+	 * @param string $in_file
133
+	 */
127 134
 	public static function gunzip($in_file,$out_file_name = '') {
128 135
 		//echo $in_file.' -> '.$out_file_name."\n";
129 136
 		$buffer_size = 4096; // read 4kb at a time
@@ -285,7 +292,7 @@  discard block
 block discarded – undo
285 292
 	* Check is distance realistic
286 293
 	* @param int $timeDifference the time between the reception of both messages
287 294
 	* @param float $distance distance covered
288
-	* @return whether distance is realistic
295
+	* @return boolean distance is realistic
289 296
 	*/
290 297
 	public function withinThreshold ($timeDifference, $distance) {
291 298
 		$x = abs($timeDifference);
@@ -309,6 +316,9 @@  discard block
 block discarded – undo
309 316
 	}
310 317
 
311 318
 
319
+	/**
320
+	 * @param string $latlong
321
+	 */
312 322
 	public function convertDec($dms,$latlong) {
313 323
 		if ($latlong == 'latitude') {
314 324
 			$deg = substr($dms, 0, 2);
@@ -343,6 +353,9 @@  discard block
 block discarded – undo
343 353
 		return array('latitude' => round($latitude,5),'longitude' => round($longitude,5));
344 354
 	}
345 355
 	
356
+	/**
357
+	 * @param string $latlong
358
+	 */
346 359
 	public function convertDM($coord,$latlong) {
347 360
 		if ($latlong == 'latitude') {
348 361
 			if ($coord < 0) $NSEW = 'S';
@@ -480,7 +493,7 @@  discard block
 block discarded – undo
480 493
 	/**
481 494
 	* Returns list of available locales
482 495
 	*
483
-	* @return array
496
+	* @return string[]
484 497
 	 */
485 498
 	public function listLocaleDir()
486 499
 	{
Please login to merge, or discard this patch.
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	* @param Array $headers header to submit with the form
15 15
 	* @return String the result
16 16
 	*/
17
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false) {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '', $sizelimit = false, $async = false) {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
20 20
 		curl_setopt($ch, CURLOPT_URL, $url);
21 21
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
22
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
22
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
23 23
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
24 24
 			}
25 25
 		}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
32
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
33 33
 		//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');
34 34
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
35 35
 		if ($useragent == '') {
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41 41
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
42
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
42
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
43 43
 		if ($type == 'post') {
44 44
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
45 45
 			if (is_array($data)) {
46 46
 				curl_setopt($ch, CURLOPT_POST, count($data));
47 47
 				$data_string = '';
48
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
48
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
49 49
 				rtrim($data_string, '&');
50 50
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
51 51
 			} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 		if ($cookie != '') {
59 59
 			if (is_array($cookie)) {
60
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
60
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
61 61
 			} else {
62 62
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
63 63
 			}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		if ($sizelimit === true) {
69 69
 			curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);
70 70
 			curl_setopt($ch, CURLOPT_NOPROGRESS, false);
71
-			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr,$downloadsize, $downloaded, $uploadsize, $uploaded){
71
+			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr, $downloadsize, $downloaded, $uploadsize, $uploaded) {
72 72
 				return ($downloaded > (3*1024)) ? 1 : 0;
73 73
 			});
74 74
 		}
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 		$result = curl_exec($ch);
80 80
 		$info = curl_getinfo($ch);
81 81
 		curl_close($ch);
82
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
82
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
83 83
 			echo "Cloudflare Detected\n";
84 84
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
85 85
 			$useragent = UAgent::random();
86 86
 			cloudflare::useUserAgent($useragent);
87 87
 			if ($clearanceCookie = cloudflare::bypass($url)) {
88
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
88
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
89 89
 			}
90 90
 		} else {
91 91
 			return $result;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
110 110
 		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
111 111
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
112
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
112
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
113 113
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
114 114
 			}
115 115
 		}
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 		fclose($fp);
125 125
 	}
126 126
 
127
-	public static function gunzip($in_file,$out_file_name = '') {
127
+	public static function gunzip($in_file, $out_file_name = '') {
128 128
 		//echo $in_file.' -> '.$out_file_name."\n";
129 129
 		$buffer_size = 4096; // read 4kb at a time
130 130
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
131 131
 		if ($in_file != '' && file_exists($in_file)) {
132 132
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
133
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
134
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
133
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
134
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
135 135
 			else {
136 136
 				echo 'gzopen not available';
137 137
 				die;
138 138
 			}
139 139
 			$out_file = fopen($out_file_name, 'wb'); 
140
-			while(!gzeof($file)) {
140
+			while (!gzeof($file)) {
141 141
 				fwrite($out_file, gzread($file, $buffer_size));
142 142
 			}  
143 143
 			fclose($out_file);
@@ -145,19 +145,19 @@  discard block
 block discarded – undo
145 145
 		}
146 146
 	}
147 147
 
148
-	public static function bunzip2($in_file,$out_file_name = '') {
148
+	public static function bunzip2($in_file, $out_file_name = '') {
149 149
 		//echo $in_file.' -> '.$out_file_name."\n";
150 150
 		$buffer_size = 4096; // read 4kb at a time
151 151
 		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
152 152
 		if ($in_file != '' && file_exists($in_file)) {
153 153
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
154
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
154
+			if (function_exists('bzopen')) $file = bzopen($in_file, 'rb');
155 155
 			else {
156 156
 				echo 'bzopen not available';
157 157
 				die;
158 158
 			}
159 159
 			$out_file = fopen($out_file_name, 'wb'); 
160
-			while(!feof($file)) {
160
+			while (!feof($file)) {
161 161
 				fwrite($out_file, bzread($file, $buffer_size));
162 162
 			}  
163 163
 			fclose($out_file);
@@ -175,27 +175,27 @@  discard block
 block discarded – undo
175 175
 		if ($data == '') return array();
176 176
 		$html = str_get_html($data);
177 177
 		if ($html === false) return array();
178
-		$tabledata=array();
179
-		foreach($html->find('tr') as $element)
178
+		$tabledata = array();
179
+		foreach ($html->find('tr') as $element)
180 180
 		{
181 181
 			$td = array();
182
-			foreach( $element->find('th') as $row)
182
+			foreach ($element->find('th') as $row)
183 183
 			{
184 184
 				$td [] = trim($row->plaintext);
185 185
 			}
186
-			$td=array_filter($td);
186
+			$td = array_filter($td);
187 187
 			$tabledata[] = $td;
188 188
 
189 189
 			$td = array();
190 190
 			$tdi = array();
191
-			foreach( $element->find('td') as $row)
191
+			foreach ($element->find('td') as $row)
192 192
 			{
193 193
 				$td [] = trim($row->plaintext);
194 194
 				$tdi [] = trim($row->innertext);
195 195
 			}
196
-			$td=array_filter($td);
197
-			$tdi=array_filter($tdi);
198
-			$tabledata[]=array_merge($td,$tdi);
196
+			$td = array_filter($td);
197
+			$tdi = array_filter($tdi);
198
+			$tabledata[] = array_merge($td, $tdi);
199 199
 		}
200 200
 		$html->clear();
201 201
 		unset($html);
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	public function text2array($data) {
211 211
 		$html = str_get_html($data);
212 212
 		if ($html === false) return array();
213
-		$tabledata=array();
214
-		foreach($html->find('p') as $element)
213
+		$tabledata = array();
214
+		foreach ($html->find('p') as $element)
215 215
 		{
216 216
 			$tabledata [] = trim($element->plaintext);
217 217
 		}
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 	*/
232 232
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233 233
 		if ($lat == $latc && $lon == $lonc) return 0;
234
-		$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;
234
+		$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;
235 235
 		if ($unit == "km") {
236
-			return round($dist * 1.609344);
236
+			return round($dist*1.609344);
237 237
 		} elseif ($unit == "m") {
238
-			return round($dist * 1.609344 * 1000);
238
+			return round($dist*1.609344*1000);
239 239
 		} elseif ($unit == "mile" || $unit == "mi") {
240 240
 			return round($dist);
241 241
 		} elseif ($unit == "nm") {
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	* @param String $distance distance between two points in m
253 253
 	* @return Float plunge
254 254
 	*/
255
-	public function plunge($initial_altitude,$final_altitude,$distance) {
256
-		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
255
+	public function plunge($initial_altitude, $final_altitude, $distance) {
256
+		$plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance));
257 257
 		/*
258 258
 		$siter = 6378137.0 + $initial_altitude;
259 259
 		$planer = 6378137.0 + $final_altitude;
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 	public function azimuth($lat, $lon, $latc, $lonc) {
276 276
 		$dX = $latc - $lat;
277 277
 		$dY = $lonc - $lon;
278
-		$azimuth = rad2deg(atan2($dY,$dX));
279
-		if ($azimuth < 0) return $azimuth+360;
278
+		$azimuth = rad2deg(atan2($dY, $dX));
279
+		if ($azimuth < 0) return $azimuth + 360;
280 280
 		return $azimuth;
281 281
 	}
282 282
 	
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	* @param float $distance distance covered
288 288
 	* @return whether distance is realistic
289 289
 	*/
290
-	public function withinThreshold ($timeDifference, $distance) {
290
+	public function withinThreshold($timeDifference, $distance) {
291 291
 		$x = abs($timeDifference);
292 292
 		$d = abs($distance);
293 293
 		if ($x == 0 || $d == 0) return true;
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 		return ($array !== array_values($array));
304 304
 	}
305 305
 
306
-	public function isInteger($input){
306
+	public function isInteger($input) {
307 307
 		//return(ctype_digit(strval($input)));
308
-		return preg_match('/^-?[0-9]+$/', (string)$input) ? true : false;
308
+		return preg_match('/^-?[0-9]+$/', (string) $input) ? true : false;
309 309
 	}
310 310
 
311 311
 
312
-	public function convertDec($dms,$latlong) {
312
+	public function convertDec($dms, $latlong) {
313 313
 		if ($latlong == 'latitude') {
314 314
 			$deg = substr($dms, 0, 2);
315 315
 			$min = substr($dms, 2, 4);
@@ -317,33 +317,33 @@  discard block
 block discarded – undo
317 317
 			$deg = substr($dms, 0, 3);
318 318
 			$min = substr($dms, 3, 5);
319 319
 		}
320
-		return $deg+(($min*60)/3600);
320
+		return $deg + (($min*60)/3600);
321 321
 	}
322 322
 	
323 323
 	public function convertDecLatLong($coord) {
324 324
 		//N43°36.763' W5°46.845'
325
-		$coords = explode(' ',$coord);
325
+		$coords = explode(' ', $coord);
326 326
 		$latitude = '';
327 327
 		$longitude = '';
328 328
 		foreach ($coords as $latlong) {
329
-			$type = substr($latlong,0,1);
330
-			$degmin = explode('°',substr($latlong,1,-1));
329
+			$type = substr($latlong, 0, 1);
330
+			$degmin = explode('°', substr($latlong, 1, -1));
331 331
 			$deg = $degmin[0];
332 332
 			$min = $degmin[1];
333 333
 			if ($type == 'N') {
334
-				$latitude = $deg+(($min*60)/3600);
334
+				$latitude = $deg + (($min*60)/3600);
335 335
 			} elseif ($type == 'S') {
336
-				$latitude = -($deg+(($min*60)/3600));
336
+				$latitude = -($deg + (($min*60)/3600));
337 337
 			} elseif ($type == 'E') {
338
-				$longitude = ($deg+(($min*60)/3600));
338
+				$longitude = ($deg + (($min*60)/3600));
339 339
 			} elseif ($type == 'W') {
340
-				$longitude = -($deg+(($min*60)/3600));
340
+				$longitude = -($deg + (($min*60)/3600));
341 341
 			}
342 342
 		}
343
-		return array('latitude' => round($latitude,5),'longitude' => round($longitude,5));
343
+		return array('latitude' => round($latitude, 5), 'longitude' => round($longitude, 5));
344 344
 	}
345 345
 	
346
-	public function convertDM($coord,$latlong) {
346
+	public function convertDM($coord, $latlong) {
347 347
 		if ($latlong == 'latitude') {
348 348
 			if ($coord < 0) $NSEW = 'S';
349 349
 			else $NSEW = 'N';
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
 		}
354 354
 		$coord = abs($coord);
355 355
 		$deg = floor($coord);
356
-		$coord = ($coord-$deg)*60;
356
+		$coord = ($coord - $deg)*60;
357 357
 		$min = $coord;
358
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
358
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
359 359
 	}
360 360
 	
361 361
 	/**
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	public function xcopy($source, $dest)
368 368
 	{
369 369
 		$files = glob($source.'*.*');
370
-		foreach($files as $file){
371
-			$file_to_go = str_replace($source,$dest,$file);
370
+		foreach ($files as $file) {
371
+			$file_to_go = str_replace($source, $dest, $file);
372 372
 			copy($file, $file_to_go);
373 373
 		}
374 374
 		return true;
@@ -379,9 +379,9 @@  discard block
 block discarded – undo
379 379
 	* @param	String $url url to check
380 380
 	* @return	bool Return true on succes false on failure
381 381
 	*/
382
-	public function urlexist($url){
383
-		$headers=get_headers($url);
384
-		return stripos($headers[0],"200 OK")?true:false;
382
+	public function urlexist($url) {
383
+		$headers = get_headers($url);
384
+		return stripos($headers[0], "200 OK") ?true:false;
385 385
 	}
386 386
 	
387 387
 	/**
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	public function hex2str($hex) {
393 393
 		$str = '';
394 394
 		$hexln = strlen($hex);
395
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
395
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
396 396
 		return $str;
397 397
 	}
398 398
 	
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 	* @return	String Return result
403 403
 	*/
404 404
 	public function hex2rgb($hex) {
405
-		$hex = str_replace('#','',$hex);
405
+		$hex = str_replace('#', '', $hex);
406 406
 		return sscanf($hex, "%02x%02x%02x"); 
407 407
 	}
408 408
 	
@@ -410,33 +410,33 @@  discard block
 block discarded – undo
410 410
 		//difference in longitudinal coordinates
411 411
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
412 412
 		//difference in the phi of latitudinal coordinates
413
-		$dPhi = log(tan(deg2rad($lat2) / 2 + M_PI / 4) / tan(deg2rad($lat1) / 2 + M_PI / 4));
413
+		$dPhi = log(tan(deg2rad($lat2)/2 + M_PI/4)/tan(deg2rad($lat1)/2 + M_PI/4));
414 414
 		//we need to recalculate $dLon if it is greater than pi
415
-		if(abs($dLon) > M_PI) {
416
-			if($dLon > 0) {
417
-				$dLon = (2 * M_PI - $dLon) * -1;
415
+		if (abs($dLon) > M_PI) {
416
+			if ($dLon > 0) {
417
+				$dLon = (2*M_PI - $dLon)*-1;
418 418
 			} else {
419
-				$dLon = 2 * M_PI + $dLon;
419
+				$dLon = 2*M_PI + $dLon;
420 420
 			}
421 421
 		}
422 422
 		//return the angle, normalized
423
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
423
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
424 424
 	}
425 425
 
426
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) {
426
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) {
427 427
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
428
-		$a = -($lon2-$lon1);
428
+		$a = -($lon2 - $lon1);
429 429
 		$b = $lat2 - $lat1;
430
-		$c = -($a*$lat1+$b*$lon1);
431
-		$d = $a*$lat3+$b*$lon3+$c;
430
+		$c = -($a*$lat1 + $b*$lon1);
431
+		$d = $a*$lat3 + $b*$lon3 + $c;
432 432
 		if ($d > -$approx && $d < $approx) return true;
433 433
 		else return false;
434 434
 	}
435 435
 	
436 436
 	public function array_merge_noappend() {
437 437
 		$output = array();
438
-		foreach(func_get_args() as $array) {
439
-			foreach($array as $key => $value) {
438
+		foreach (func_get_args() as $array) {
439
+			foreach ($array as $key => $value) {
440 440
 				$output[$key] = isset($output[$key]) ?
441 441
 				array_merge($output[$key], $value) : $value;
442 442
 			}
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 		return $result;
501 501
 	}
502 502
 
503
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){
503
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') {
504 504
 		global $globalMapRefresh;
505 505
 		if ($seconds == '') {
506 506
 			$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
@@ -511,27 +511,27 @@  discard block
 block discarded – undo
511 511
 		$latitude = deg2rad($latitude);
512 512
 		$longitude = deg2rad($longitude);
513 513
 		$bearing = deg2rad($heading); 
514
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
515
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
516
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
514
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
515
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
516
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
517 517
 	}
518 518
 	
519
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
519
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
520 520
 		// distance in meter
521 521
 		$R = 6378.14;
522
-		$latitude1 = $latitude * (M_PI/180);
523
-		$longitude1 = $longitude * (M_PI/180);
524
-		$brng = $bearing * (M_PI/180);
522
+		$latitude1 = $latitude*(M_PI/180);
523
+		$longitude1 = $longitude*(M_PI/180);
524
+		$brng = $bearing*(M_PI/180);
525 525
 		$d = $distance;
526 526
 
527 527
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
528
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
528
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
529 529
 
530
-		$latitude2 = $latitude2 * (180/M_PI);
531
-		$longitude2 = $longitude2 * (180/M_PI);
530
+		$latitude2 = $latitude2*(180/M_PI);
531
+		$longitude2 = $longitude2*(180/M_PI);
532 532
 
533
-		$flat = round ($latitude2,6);
534
-		$flong = round ($longitude2,6);
533
+		$flat = round($latitude2, 6);
534
+		$flong = round($longitude2, 6);
535 535
 /*
536 536
 		$dx = $distance*cos($bearing);
537 537
 		$dy = $distance*sin($bearing);
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 		$flong = $longitude + $dlong;
541 541
 		$flat = $latitude + $dlat;
542 542
 */
543
-		return array('latitude' => $flat,'longitude' => $flong);
543
+		return array('latitude' => $flat, 'longitude' => $flong);
544 544
 	}
545 545
 
546 546
 	/**
@@ -554,14 +554,14 @@  discard block
 block discarded – undo
554 554
 	 * @param integer $level GZIP compression level (default: 9)
555 555
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
556 556
 	 */
557
-	public function gzCompressFile($source, $level = 9){ 
558
-		$dest = $source . '.gz'; 
559
-		$mode = 'wb' . $level; 
557
+	public function gzCompressFile($source, $level = 9) { 
558
+		$dest = $source.'.gz'; 
559
+		$mode = 'wb'.$level; 
560 560
 		$error = false; 
561 561
 		if ($fp_out = gzopen($dest, $mode)) { 
562
-			if ($fp_in = fopen($source,'rb')) { 
562
+			if ($fp_in = fopen($source, 'rb')) { 
563 563
 				while (!feof($fp_in)) 
564
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
564
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
565 565
 				fclose($fp_in); 
566 566
 			} else {
567 567
 				$error = true; 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	} 
578 578
 	
579 579
 	public function remove_accents($string) {
580
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
580
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
581 581
 		$chars = array(
582 582
 		    // Decompositions for Latin-1 Supplement
583 583
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
635 635
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
636 636
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
637
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
637
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
638 638
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
639 639
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
640 640
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -650,13 +650,13 @@  discard block
 block discarded – undo
650 650
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
651 651
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
652 652
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
653
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
654
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
655
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
656
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
657
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
658
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
659
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
653
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
654
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
655
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
656
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
657
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
658
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
659
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
660 660
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
661 661
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
662 662
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
691 691
 			if (is_numeric($string[$i]) && $concat_flag) {
692 692
 				$int .= $string[$i];
693
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
693
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
694 694
 				$concat_flag = false;
695 695
 			}
696 696
 		}
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 			$slice = array_slice($arr, $offset + 1, $length);
737 737
 			return implode("", $slice);
738 738
 		} else {
739
-			return mb_substr($string,$offset,$length,'UTF-8');
739
+			return mb_substr($string, $offset, $length, 'UTF-8');
740 740
 		}
741 741
 	}
742 742
 
@@ -746,14 +746,14 @@  discard block
 block discarded – undo
746 746
 		//NOTE: use a trailing slash for folders!!!
747 747
 		//see http://bugs.php.net/bug.php?id=27609
748 748
 		//see http://bugs.php.net/bug.php?id=30931
749
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
749
+		if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path
750 750
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
751 751
 		else if (is_dir($path))
752 752
 			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
753 753
 		// check tmp file for read/write capabilities
754 754
 		$rm = file_exists($path);
755 755
 		$f = @fopen($path, 'a');
756
-		if ($f===false)
756
+		if ($f === false)
757 757
 			return false;
758 758
 		fclose($f);
759 759
 		if (!$rm)
@@ -772,29 +772,29 @@  discard block
 block discarded – undo
772 772
 	 * @param Integer $offset Controls the likelyhood that lines will be split which cross the dateline
773 773
 	 * @return Array Coordinate of the route
774 774
 	*/
775
-	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
776
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
775
+	public function greatcircle($begin_lat, $begin_lon, $end_lat, $end_lon, $nbpts = 20, $offset = 10) {
776
+		if ($nbpts <= 2) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
777 777
 		$sx = deg2rad($begin_lon);
778 778
 		$sy = deg2rad($begin_lat);
779 779
 		$ex = deg2rad($end_lon);
780 780
 		$ey = deg2rad($end_lat);
781 781
 		$w = $sx - $ex;
782 782
 		$h = $sy - $ey;
783
-		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
783
+		$z = pow(sin($h/2.0), 2) + cos($sy)*cos($ey)*pow(sin($w/2.0), 2);
784 784
 		$g = 2.0*asin(sqrt($z));
785
-		if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
785
+		if ($g == M_PI || is_nan($g)) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
786 786
 		$first_pass = array();
787
-		$delta = 1.0/($nbpts-1);
788
-		for ($i =0; $i < $nbpts; ++$i) {
787
+		$delta = 1.0/($nbpts - 1);
788
+		for ($i = 0; $i < $nbpts; ++$i) {
789 789
 			$step = $delta*$i;
790
-			$A = sin((1 - $step) * $g) / sin($g);
791
-			$B = sin($step * $g) / sin($g);
792
-			$x = $A * cos($sy) * cos($sx) + $B * cos($ey) * cos($ex);
793
-			$y = $A * cos($sy) * sin($sx) + $B * cos($ey) * sin($ex);
794
-			$z = $A * sin($sy) + $B * sin($ey);
790
+			$A = sin((1 - $step)*$g)/sin($g);
791
+			$B = sin($step*$g)/sin($g);
792
+			$x = $A*cos($sy)*cos($sx) + $B*cos($ey)*cos($ex);
793
+			$y = $A*cos($sy)*sin($sx) + $B*cos($ey)*sin($ex);
794
+			$z = $A*sin($sy) + $B*sin($ey);
795 795
 			$lat = rad2deg(atan2($z, sqrt(pow($x, 2) + pow($y, 2))));
796 796
 			$lon = rad2deg(atan2($y, $x));
797
-			$first_pass[] = array($lon,$lat);
797
+			$first_pass[] = array($lon, $lat);
798 798
 		}
799 799
 		$bHasBigDiff = false;
800 800
 		$dfMaxSmallDiffLong = 0;
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		// https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
810 810
 		$first_pass_ln = count($first_pass);
811 811
 		for ($j = 1; $j < $first_pass_ln; ++$j) {
812
-			$dfPrevX = $first_pass[$j-1][0];
812
+			$dfPrevX = $first_pass[$j - 1][0];
813 813
 			$dfX = $first_pass[$j][0];
814 814
 			$dfDiffLong = abs($dfX - $dfPrevX);
815 815
 			if ($dfDiffLong > $dfDiffSpace &&
@@ -827,14 +827,14 @@  discard block
 block discarded – undo
827 827
 			//$poMulti[] = $poNewLS;
828 828
 			for ($k = 0; $k < $first_pass_ln; ++$k) {
829 829
 				$dfX0 = floatval($first_pass[$k][0]);
830
-				if ($k > 0 &&  abs($dfX0 - $first_pass[$k-1][0]) > $dfDiffSpace) {
831
-					$dfX1 = floatval($first_pass[$k-1][0]);
832
-					$dfY1 = floatval($first_pass[$k-1][1]);
830
+				if ($k > 0 && abs($dfX0 - $first_pass[$k - 1][0]) > $dfDiffSpace) {
831
+					$dfX1 = floatval($first_pass[$k - 1][0]);
832
+					$dfY1 = floatval($first_pass[$k - 1][1]);
833 833
 					$dfX2 = floatval($first_pass[$k][0]);
834 834
 					$dfY2 = floatval($first_pass[$k][1]);
835 835
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
836
-					    $k+1 < count($first_pass) &&
837
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
836
+					    $k + 1 < count($first_pass) &&
837
+					    $first_pass[$k - 1][0] > -180 && $first_pass[$k - 1][0] < $dfRightBorderX)
838 838
 					{
839 839
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
840 840
 						$k++;
@@ -842,8 +842,8 @@  discard block
 block discarded – undo
842 842
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
843 843
 						continue;
844 844
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
845
-					    $k+1 < $first_pass_ln &&
846
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
845
+					    $k + 1 < $first_pass_ln &&
846
+					    $first_pass[$k - 1][0] > $dfLeftBorderX && $first_pass[$k - 1][0] < 180)
847 847
 					{
848 848
 						$poNewLS[] = array(180, $first_pass[$k][1]);
849 849
 						$k++;
@@ -866,12 +866,12 @@  discard block
 block discarded – undo
866 866
 					}
867 867
 					if ($dfX1 <= 180 && $dfX2 >= 180 && $dfX1 < $dfX2)
868 868
 					{
869
-						$dfRatio = (180 - $dfX1) / ($dfX2 - $dfX1);
870
-						$dfY = $dfRatio * $dfY2 + (1 - $dfRatio) * $dfY1;
871
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
869
+						$dfRatio = (180 - $dfX1)/($dfX2 - $dfX1);
870
+						$dfY = $dfRatio*$dfY2 + (1 - $dfRatio)*$dfY1;
871
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
872 872
 						$poMulti[] = $poNewLS;
873 873
 						$poNewLS = array();
874
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
874
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
875 875
 						//$poMulti[] = $poNewLS;
876 876
 					} else {
877 877
 						//$poNewLS[] = array();
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 			$poNewLS0 = array();
890 890
 			//$poMulti[] = $poNewLS0;
891 891
 			for ($l = 0; $l < $first_pass_ln; ++$l) {
892
-				$poNewLS0[] = array($first_pass[$l][0],$first_pass[$l][1]);
892
+				$poNewLS0[] = array($first_pass[$l][0], $first_pass[$l][1]);
893 893
 			}
894 894
 			$poMulti[] = $poNewLS0;
895 895
 		}
Please login to merge, or discard this patch.
js/map.3d.js.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 			break;
315 315
 		}
316 316
 	}
317
-	var tsk_geojson = Cesium.loadJson("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php print filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL); ?>");
317
+	var tsk_geojson = Cesium.loadJson("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php print filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL); ?>");
318 318
 	tsk_geojson.then(function(geojsondata) {
319 319
 		tsk = new Cesium.CustomDataSource('tsk');
320 320
 		for (var i =0;i < geojsondata.features.length; i++) {
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 <?php
390 390
 	if (isset($_COOKIE['lastcentercoord']) || (isset($globalCenterLatitude) && isset($globalCenterLongitude) && $globalCenterLatitude != '' && $globalCenterLongitude != '')) {
391 391
 		if (isset($_COOKIE['lastcentercoord'])) {
392
-			$lastcentercoord = explode(',',$_COOKIE['lastcentercoord']);
392
+			$lastcentercoord = explode(',', $_COOKIE['lastcentercoord']);
393 393
 			if (!isset($lastcentercoord[3])) $zoom = $lastcentercoord[2]*1000000.0;
394 394
 			else $zoom = $lastcentercoord[3];
395 395
 			$viewcenterlatitude = $lastcentercoord[0];
Please login to merge, or discard this patch.
Braces   +47 added lines, -15 removed lines patch added patch discarded remove patch
@@ -27,21 +27,30 @@  discard block
 block discarded – undo
27 27
 
28 28
 document.cookie =  'MapFormat=3d; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
29 29
 <?php
30
-	if (isset($_COOKIE['MapType3D'])) $MapType = $_COOKIE['MapType3D'];
31
-	else $MapType = $globalMapProvider;
32
-//	unset($_COOKIE['MapType']);
30
+	if (isset($_COOKIE['MapType3D'])) {
31
+		$MapType = $_COOKIE['MapType3D'];
32
+	} else {
33
+		$MapType = $globalMapProvider;
34
+	}
35
+	//	unset($_COOKIE['MapType']);
33 36
 
34 37
 	if ($MapType != 'Mapbox' && $MapType != 'OpenStreetMap' && $MapType != 'Bing-Aerial' && $MapType != 'Bing-Hybrid' && $MapType != 'Bing-Road' && $MapType != 'offline' && $MapType != 'ArcGIS-Streetmap' && $MapType != 'ArcGIS-Satellite' && $MapType != 'NatGeo-Street') {
35
-		if (isset($globalBingMapKey) && $globalBingMapKey != '') $MapType = 'Bing-Aerial';
36
-		else $MapType = 'OpenStreetMap';
38
+		if (isset($globalBingMapKey) && $globalBingMapKey != '') {
39
+			$MapType = 'Bing-Aerial';
40
+		} else {
41
+			$MapType = 'OpenStreetMap';
42
+		}
37 43
 	}
38 44
 	if (($MapType == 'Bing-Aerial' || $MapType == 'Bing-Hybrid' || $MapType == 'Bing-Road') && (!isset($globalBingMapKey) || $globalBingMapKey == '')) {
39 45
 		$MapType = 'OpenStreetMap';
40 46
 	}
41 47
 	if ($MapType == 'Mapbox') {
42
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
43
-		else $MapBoxId = $_COOKIE['MapType3DId'];
44
-?>
48
+		if ($_COOKIE['MapTypeId'] == 'default') {
49
+			$MapBoxId = $globalMapboxId;
50
+		} else {
51
+			$MapBoxId = $_COOKIE['MapType3DId'];
52
+		}
53
+		?>
45 54
 	var imProv = Cesium.MapboxImageryProvider({
46 55
 		credit: 'Map data © OpenStreetMap contributors, ' +
47 56
 	      'CC-BY-SA, ' +
@@ -108,13 +117,23 @@  discard block
 block discarded – undo
108 117
 		credit : 'Imagery courtesy Natural Earth'
109 118
 	});
110 119
 <?php
111
-	}  elseif (isset($globalMapCustomLayer[$MapType])) {
120
+	} elseif (isset($globalMapCustomLayer[$MapType])) {
112 121
 		$customid = $MapType;
113 122
 ?>
114 123
 	var imProv = Cesium.createOpenStreetMapImageryProvider({
115 124
 		url : '<?php print $globalMapCustomLayer[$customid]['url']; ?>',
116
-		maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '99'; ?>,
117
-		minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
125
+		maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
126
+	print $globalMapCustomLayer[$customid]['maxZoom'];
127
+} else {
128
+	print '99';
129
+}
130
+?>,
131
+		minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
132
+	print $globalMapCustomLayer[$customid]['minZoom'];
133
+} else {
134
+	print '0';
135
+}
136
+?>,
118 137
 		credit: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
119 138
 	});
120 139
 <?php
@@ -506,7 +525,12 @@  discard block
 block discarded – undo
506 525
 	imageryProvider : imProv,
507 526
 	timeline : archive,
508 527
 	animation : false,
509
-	shadows : <?php if ((isset($globalMap3DShadows) && $globalMap3DShadows === FALSE) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'true')) print 'false'; else print 'true'; ?>,
528
+	shadows : <?php if ((isset($globalMap3DShadows) && $globalMap3DShadows === FALSE) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'true')) {
529
+	print 'false';
530
+} else {
531
+	print 'true';
532
+}
533
+?>,
510 534
 	infoBox : false,
511 535
 	navigationHelpButton : false,
512 536
 	geocoder : false,
@@ -521,8 +545,11 @@  discard block
 block discarded – undo
521 545
 	if (isset($_COOKIE['lastcentercoord']) || (isset($globalCenterLatitude) && isset($globalCenterLongitude) && $globalCenterLatitude != '' && $globalCenterLongitude != '')) {
522 546
 		if (isset($_COOKIE['lastcentercoord'])) {
523 547
 			$lastcentercoord = explode(',',$_COOKIE['lastcentercoord']);
524
-			if (!isset($lastcentercoord[3])) $zoom = $lastcentercoord[2]*1000000.0;
525
-			else $zoom = $lastcentercoord[3];
548
+			if (!isset($lastcentercoord[3])) {
549
+				$zoom = $lastcentercoord[2]*1000000.0;
550
+			} else {
551
+				$zoom = $lastcentercoord[3];
552
+			}
526 553
 			$viewcenterlatitude = $lastcentercoord[0];
527 554
 			$viewcenterlongitude = $lastcentercoord[1];
528 555
 		} else {
@@ -642,7 +669,12 @@  discard block
 block discarded – undo
642 669
 ?>
643 670
 
644 671
 update_locationsLayer();
645
-setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
672
+setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) {
673
+	print $globalMapRefresh*1000*2;
674
+} else {
675
+	print '60000';
676
+}
677
+?>);
646 678
 
647 679
 var currentposition;
648 680
 viewer.camera.moveEnd.addEventListener(function() { 
Please login to merge, or discard this patch.
airspace-geojson.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 $Connection = new Connection();
12 12
 
13 13
 if (!$Connection->tableExists('airspace')) {
14
-    die;
14
+	die;
15 15
 }
16 16
 
17 17
 if (isset($_GET['coord'])) 
18 18
 {
19 19
 	$coords = explode(',',$_GET['coord']);
20
-        if ($globalDBdriver == 'mysql') {
20
+		if ($globalDBdriver == 'mysql') {
21 21
 		$query = "SELECT *, ST_AsWKB(SHAPE) AS wkb FROM airspace WHERE ST_Intersects(SHAPE, ST_Envelope(linestring(point(:minlon,:minlat), point(:maxlon,:maxlat))))";
22 22
 		try {
23 23
 			$sth = $Connection->db->prepare($query);
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		}
38 38
 	}
39 39
 } else {
40
-        if ($globalDBdriver == 'mysql') {
40
+		if ($globalDBdriver == 'mysql') {
41 41
 		$query = "SELECT *, ST_AsWKB(SHAPE) AS wkb FROM airspace";
42 42
 	} else {
43 43
 		$query = "SELECT *, ST_AsBinary(wkb_geometry,'NDR') AS wkb FROM airspace";
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 }
52 52
 
53 53
 $geojson = array(
54
-    'type' => 'FeatureCollection',
55
-    'features' => array()
54
+	'type' => 'FeatureCollection',
55
+	'features' => array()
56 56
 );
57 57
 
58 58
 while ($row = $sth->fetch(PDO::FETCH_ASSOC))
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 		}
116 116
 		if (isset($properties['type']) && $properties['type'] != '') {
117 117
 			$feature = array(
118
-			    'type' => 'Feature',
119
-			    'geometry' => json_decode($geom->out('json')),
120
-			    'properties' => $properties
118
+				'type' => 'Feature',
119
+				'geometry' => json_decode($geom->out('json')),
120
+				'properties' => $properties
121 121
 			);
122 122
 			array_push($geojson['features'], $feature);
123 123
 		}
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
 
17 17
 if (isset($_GET['coord'])) 
18 18
 {
19
-	$coords = explode(',',$_GET['coord']);
19
+	$coords = explode(',', $_GET['coord']);
20 20
         if ($globalDBdriver == 'mysql') {
21 21
 		$query = "SELECT *, ST_AsWKB(SHAPE) AS wkb FROM airspace WHERE ST_Intersects(SHAPE, ST_Envelope(linestring(point(:minlon,:minlat), point(:maxlon,:maxlat))))";
22 22
 		try {
23 23
 			$sth = $Connection->db->prepare($query);
24
-			$sth->execute(array(':minlon' => $coords[0],':minlat' => $coords[1],':maxlon' => $coords[2],':maxlat' => $coords[3]));
24
+			$sth->execute(array(':minlon' => $coords[0], ':minlat' => $coords[1], ':maxlon' => $coords[2], ':maxlat' => $coords[3]));
25 25
 			//$sth->execute();
26
-		} catch(PDOException $e) {
26
+		} catch (PDOException $e) {
27 27
 			echo "error";
28 28
 		}
29 29
 	} else {
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 			$sth = $Connection->db->prepare($query);
33 33
 			//$sth->execute(array(':minlon' => $coords[0],':minlat' => $coords[1],':maxlon' => $coords[2],':maxlat' => $coords[3]));
34 34
 			$sth->execute();
35
-		} catch(PDOException $e) {
35
+		} catch (PDOException $e) {
36 36
 			echo "error";
37 37
 		}
38 38
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	try {
46 46
 		$sth = $Connection->db->prepare($query);
47 47
 		$sth->execute();
48
-	} catch(PDOException $e) {
48
+	} catch (PDOException $e) {
49 49
 		echo "error";
50 50
 	}
51 51
 }
@@ -75,22 +75,22 @@  discard block
 block discarded – undo
75 75
 		if (isset($properties['ceiling'])) $properties['tops'] = $properties['ceiling'];
76 76
 		if (isset($properties['floor'])) $properties['base'] = $properties['floor'];
77 77
 		if (isset($properties['tops'])) {
78
-			if (preg_match('/^FL(\s)*(?<alt>\d+)/',strtoupper($properties['tops']),$matches)) {
78
+			if (preg_match('/^FL(\s)*(?<alt>\d+)/', strtoupper($properties['tops']), $matches)) {
79 79
 				$properties['upper_limit'] = round($matches['alt']*100*0.38048);
80
-			} elseif (preg_match('/^(?<alt>\d+)(\s)*(FT|AGL|ALT|MSL)/',strtoupper($properties['tops']),$matches)) {
80
+			} elseif (preg_match('/^(?<alt>\d+)(\s)*(FT|AGL|ALT|MSL)/', strtoupper($properties['tops']), $matches)) {
81 81
 				$properties['upper_limit'] = round($matches['alt']*0.38048);
82
-			} elseif (preg_match('/^(?<alt>\d+)(\s)*M/',strtoupper($properties['tops']),$matches)) {
82
+			} elseif (preg_match('/^(?<alt>\d+)(\s)*M/', strtoupper($properties['tops']), $matches)) {
83 83
 				$properties['upper_limit'] = $matches['alt'];
84 84
 			}
85 85
 		}
86 86
 		if (isset($properties['base'])) {
87 87
 			if ($properties['base'] == 'SFC' || $properties['base'] == 'MSL' || $properties['base'] == 'GROUND' || $properties['base'] == 'GND') {
88 88
 				$properties['lower_limit'] = 0;
89
-			} elseif (preg_match('/^FL(\s)*(?<alt>\d+)/',strtoupper($properties['base']),$matches)) {
89
+			} elseif (preg_match('/^FL(\s)*(?<alt>\d+)/', strtoupper($properties['base']), $matches)) {
90 90
 				$properties['lower_limit'] = round($matches['alt']*100*0.38048);
91
-			} elseif (preg_match('/^(?<alt>\d+)(\s)*(FT|AGL|ALT|MSL)/',strtoupper($properties['base']),$matches)) {
91
+			} elseif (preg_match('/^(?<alt>\d+)(\s)*(FT|AGL|ALT|MSL)/', strtoupper($properties['base']), $matches)) {
92 92
 				$properties['lower_limit'] = round($matches['alt']*0.38048);
93
-			} elseif (preg_match('/^(?<alt>\d+)(\s)*M/',strtoupper($properties['base']),$matches)) {
93
+			} elseif (preg_match('/^(?<alt>\d+)(\s)*M/', strtoupper($properties['base']), $matches)) {
94 94
 				$properties['lower_limit'] = $matches['alt'];
95 95
 			}
96 96
 		}
Please login to merge, or discard this patch.
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -68,12 +68,22 @@
 block discarded – undo
68 68
 		} else {
69 69
 			$geom = geoPHP::load(stream_get_contents($row['wkb']));
70 70
 		}
71
-		if (isset($properties['type'])) $properties['type'] = trim($properties['type']);
72
-		elseif (isset($properties['class'])) $properties['type'] = trim($properties['class']);
73
-		if (isset($properties['ogr_fid'])) $properties['id'] = $properties['ogr_fid'];
74
-		elseif (isset($properties['ogc_fid'])) $properties['id'] = $properties['ogc_fid'];
75
-		if (isset($properties['ceiling'])) $properties['tops'] = $properties['ceiling'];
76
-		if (isset($properties['floor'])) $properties['base'] = $properties['floor'];
71
+		if (isset($properties['type'])) {
72
+			$properties['type'] = trim($properties['type']);
73
+		} elseif (isset($properties['class'])) {
74
+			$properties['type'] = trim($properties['class']);
75
+		}
76
+		if (isset($properties['ogr_fid'])) {
77
+			$properties['id'] = $properties['ogr_fid'];
78
+		} elseif (isset($properties['ogc_fid'])) {
79
+			$properties['id'] = $properties['ogc_fid'];
80
+		}
81
+		if (isset($properties['ceiling'])) {
82
+			$properties['tops'] = $properties['ceiling'];
83
+		}
84
+		if (isset($properties['floor'])) {
85
+			$properties['base'] = $properties['floor'];
86
+		}
77 87
 		if (isset($properties['tops'])) {
78 88
 			if (preg_match('/^FL(\s)*(?<alt>\d+)/',strtoupper($properties['tops']),$matches)) {
79 89
 				$properties['upper_limit'] = round($matches['alt']*100*0.38048);
Please login to merge, or discard this patch.
js/map-aircraft.3d.js.php 2 patches
Braces   +24 added lines, -4 removed lines patch added patch discarded remove patch
@@ -275,7 +275,12 @@  discard block
 block discarded – undo
275 275
 			<?php
276 276
 			    } else {
277 277
 			?>
278
-			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
278
+			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
279
+	print $globalMapRefresh*2000;
280
+} else {
281
+	print '60000';
282
+}
283
+?>)) {
279 284
 				viewer.dataSources.get(dsn).entities.remove(entity);
280 285
 				czmlds.entities.removeById(entityid);
281 286
 			}
@@ -564,7 +569,12 @@  discard block
 block discarded – undo
564 569
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
565 570
 ?>
566 571
 update_polarLayer();
567
-setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
572
+setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) {
573
+	print $globalMapRefresh*1000*2;
574
+} else {
575
+	print '60000';
576
+}
577
+?>);
568 578
 <?php
569 579
 		}
570 580
 ?>
@@ -695,7 +705,12 @@  discard block
 block discarded – undo
695 705
 				}
696 706
 			}
697 707
 		}
698
-	,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
708
+	,<?php if (isset($globalMapRefresh)) {
709
+	print $globalMapRefresh*1000;
710
+} else {
711
+	print '30000';
712
+}
713
+?>);
699 714
 } else {
700 715
 	var clockViewModel = new Cesium.ClockViewModel(viewer.clock);
701 716
 	var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);
@@ -724,7 +739,12 @@  discard block
 block discarded – undo
724 739
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
725 740
 ?>
726 741
 update_atcLayer();
727
-setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
742
+setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) {
743
+	print $globalMapRefresh*1000*2;
744
+} else {
745
+	print '60000';
746
+}
747
+?>);
728 748
 <?php
729 749
     }
730 750
 ?>
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 			var entityid = entity.id;
290 290
 			var lastupdateentity = entity.properties.lastupdate;
291 291
 			<?php 
292
-			    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
293
-			    // Remove flights not in latest CZML
292
+				if (isset($globalMapUseBbox) && $globalMapUseBbox) {
293
+				// Remove flights not in latest CZML
294 294
 			?>
295 295
 			if (lastupdateentity != lastupdate) {
296 296
 				console.log('Remove...');
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
 				czmlds.entities.removeById(entityid);
299 299
 			}
300 300
 			<?php
301
-			    } else {
301
+				} else {
302 302
 			?>
303 303
 			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
304 304
 				viewer.dataSources.get(dsn).entities.remove(entity);
305 305
 				czmlds.entities.removeById(entityid);
306 306
 			}
307 307
 			<?php
308
-			    }
308
+				}
309 309
 			?>
310 310
 		}
311 311
 	}
@@ -762,12 +762,12 @@  discard block
 block discarded – undo
762 762
 }
763 763
 
764 764
 <?php
765
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
765
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
766 766
 ?>
767 767
 update_atcLayer();
768 768
 setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
769 769
 <?php
770
-    }
770
+	}
771 771
 ?>
772 772
 
773 773
 function iconColor(color) {
Please login to merge, or discard this patch.