Completed
Push — master ( c396ef...4342b6 )
by Yannick
34:34
created
owner-statistics-departure-airport.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 15
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') {
18
+	$filter = array_merge($filter,array('year' => $year));
19
+}
20
+if ($month != '') {
21
+	$filter = array_merge($filter,array('month' => $month));
22
+}
19 23
 $archive = false;
20 24
 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 25
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
Please login to merge, or discard this patch.
owner-statistics-route.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 15
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') {
18
+	$filter = array_merge($filter,array('year' => $year));
19
+}
20
+if ($month != '') {
21
+	$filter = array_merge($filter,array('month' => $month));
22
+}
19 23
 $archive = false;
20 24
 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 25
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
Please login to merge, or discard this patch.
owner-statistics-manufacturer.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 15
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') {
18
+	$filter = array_merge($filter,array('year' => $year));
19
+}
20
+if ($month != '') {
21
+	$filter = array_merge($filter,array('month' => $month));
22
+}
19 23
 $archive = false;
20 24
 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 25
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
Please login to merge, or discard this patch.
owner-statistics-registration.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 15
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') {
18
+	$filter = array_merge($filter,array('year' => $year));
19
+}
20
+if ($month != '') {
21
+	$filter = array_merge($filter,array('month' => $month));
22
+}
19 23
 $archive = false;
20 24
 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 25
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
Please login to merge, or discard this patch.
require/class.Weather.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,12 +63,16 @@  discard block
 block discarded – undo
63 63
 	
64 64
 	public function openweathermap($latitude,$longitude) {
65 65
 		global $globalOpenWeatherMapKey;
66
-		if ($globalOpenWeatherMapKey == '') return array();
66
+		if ($globalOpenWeatherMapKey == '') {
67
+			return array();
68
+		}
67 69
 		$Common = new Common();
68 70
 		$url = 'http://api.openweathermap.org/data/2.5/weather?lat='.$latitude.'&lon='.$longitude.'&units=metric&appid='.$globalOpenWeatherMapKey;
69 71
 		//echo $url."\n";
70 72
 		$weatherdata = json_decode($Common->getData($url),true);
71
-		if (!isset($weatherdata['main']['temp']) || !isset($weatherdata['weather'][0]['id'])) return array('clouds' => array(),'rain' => array());
73
+		if (!isset($weatherdata['main']['temp']) || !isset($weatherdata['weather'][0]['id'])) {
74
+			return array('clouds' => array(),'rain' => array());
75
+		}
72 76
 		$dew = $weatherdata['main']['temp'] - ((100-$weatherdata['main']['humidity'])/5);
73 77
 		$cumulus_base = 122.0 * ($weatherdata['main']['temp'] - $dew);
74 78
 		$stratus_base = 100.0 * (100.0 * $weatherdata['main']['humidity'])*0.3048;
@@ -104,7 +108,9 @@  discard block
 block discarded – undo
104 108
 	
105 109
 	public function nomad_wind($hour = '') {
106 110
 		global $globalWindsPath;
107
-		if ($hour == '') $hour = date('G');
111
+		if ($hour == '') {
112
+			$hour = date('G');
113
+		}
108 114
 		if (isset($globalWindsPath) && $globalWindsPath != '') {
109 115
 			$grib2json = $globalWindsPath['grib2json'];
110 116
 			$windpathsrc = $globalWindsPath['source'];
@@ -142,7 +148,9 @@  discard block
 block discarded – undo
142 148
 			system($grib2json.' --data --output '.$windpathdest.' --names --compact '.$windpathsrc);
143 149
 		} else {
144 150
 			// if not try previous run
145
-			if ($hour == date('G')) $this->nomad_wind(date('G')-6);
151
+			if ($hour == date('G')) {
152
+				$this->nomad_wind(date('G')-6);
153
+			}
146 154
 		}
147 155
 	}
148 156
 
Please login to merge, or discard this patch.
owner-statistics-arrival-airport.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 15
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') {
18
+	$filter = array_merge($filter,array('year' => $year));
19
+}
20
+if ($month != '') {
21
+	$filter = array_merge($filter,array('month' => $month));
22
+}
19 23
 $archive = false;
20 24
 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 25
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 1 patch
Braces   +48 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection. (SpotterArchive)');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection. (SpotterArchive)');
11
+		}
10 12
 	}
11 13
 
12 14
     /**
@@ -29,7 +31,9 @@  discard block
 block discarded – undo
29 31
 		if (isset($filter[0]['source'])) {
30 32
 			$filters = array_merge($filters,$filter);
31 33
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) {
35
+			$filter = array_merge($filter,$globalFilter);
36
+		}
33 37
 		$filter_query_join = '';
34 38
 		$filter_query_where = '';
35 39
 		foreach($filters as $flt) {
@@ -121,8 +125,11 @@  discard block
 block discarded – undo
121 125
 			}
122 126
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
123 127
 		}
124
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
125
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
128
+		if ($filter_query_where == '' && $where) {
129
+			$filter_query_where = ' WHERE';
130
+		} elseif ($filter_query_where != '' && $and) {
131
+			$filter_query_where .= ' AND';
132
+		}
126 133
 		if ($filter_query_where != '') {
127 134
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
128 135
 		}
@@ -136,10 +143,17 @@  discard block
 block discarded – undo
136 143
 		if ($over_country == '') {
137 144
 			$Spotter = new Spotter($this->db);
138 145
 			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
139
-			if (!empty($data_country)) $country = $data_country['iso2'];
140
-			else $country = '';
141
-		} else $country = $over_country;
142
-		if ($airline_type === NULL) $airline_type ='';
146
+			if (!empty($data_country)) {
147
+				$country = $data_country['iso2'];
148
+			} else {
149
+				$country = '';
150
+			}
151
+		} else {
152
+			$country = $over_country;
153
+		}
154
+		if ($airline_type === NULL) {
155
+			$airline_type ='';
156
+		}
143 157
 
144 158
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
145 159
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
@@ -678,7 +692,9 @@  discard block
 block discarded – undo
678 692
 					$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
679 693
 					$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
680 694
 					$translate = $Translation->ident2icao($q_item);
681
-					if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
695
+					if ($translate != $q_item) {
696
+						$additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
697
+					}
682 698
 					$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
683 699
 					$additional_query .= ")";
684 700
 				}
@@ -858,7 +874,9 @@  discard block
 block discarded – undo
858 874
 				date_default_timezone_set($globalTimezone);
859 875
 				$datetime = new DateTime();
860 876
 				$offset = $datetime->format('P');
861
-			} else $offset = '+00:00';
877
+			} else {
878
+				$offset = '+00:00';
879
+			}
862 880
 			if ($date_array[1] != "") {
863 881
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
864 882
 				$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
@@ -1112,9 +1130,13 @@  discard block
 block discarded – undo
1112 1130
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1113 1131
 			}
1114 1132
 		}
1115
-		if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1133
+		if ($sincedate != '') {
1134
+			$query .= "AND date > '".$sincedate."' ";
1135
+		}
1116 1136
 		$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1117
-		if ($limit) $query .= " LIMIT 0,10";
1137
+		if ($limit) {
1138
+			$query .= " LIMIT 0,10";
1139
+		}
1118 1140
 
1119 1141
 
1120 1142
 		$sth = $this->db->prepare($query);
@@ -1158,9 +1180,13 @@  discard block
 block discarded – undo
1158 1180
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1159 1181
 			}
1160 1182
 		}
1161
-		if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1183
+		if ($sincedate != '') {
1184
+			$query .= "AND s.date > '".$sincedate."' ";
1185
+		}
1162 1186
 		$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1163
-		if ($limit) $query .= " LIMIT 0,10";
1187
+		if ($limit) {
1188
+			$query .= " LIMIT 0,10";
1189
+		}
1164 1190
 
1165 1191
 
1166 1192
 		$sth = $this->db->prepare($query);
@@ -1382,8 +1408,11 @@  discard block
 block discarded – undo
1382 1408
 			if($row['registration'] != "")
1383 1409
 			{
1384 1410
 				$image_array = $Image->getSpotterImage($row['registration']);
1385
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
1386
-				else $temp_array['image_thumbnail'] = '';
1411
+				if (isset($image_array[0]['image_thumbnail'])) {
1412
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
1413
+				} else {
1414
+					$temp_array['image_thumbnail'] = '';
1415
+				}
1387 1416
 			}
1388 1417
 			$temp_array['registration_count'] = $row['registration_count'];
1389 1418
 			$aircraft_array[] = $temp_array;
@@ -1442,7 +1471,9 @@  discard block
 block discarded – undo
1442 1471
 			date_default_timezone_set($globalTimezone);
1443 1472
 			$datetime = new DateTime();
1444 1473
 			$offset = $datetime->format('P');
1445
-		} else $offset = '+00:00';
1474
+		} else {
1475
+			$offset = '+00:00';
1476
+		}
1446 1477
 		if ($globalDBdriver == 'mysql') {
1447 1478
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_archive_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1448 1479
 			    FROM spotter_archive_output".$filter_query." spotter_archive_output.owner_name = :owner 
Please login to merge, or discard this patch.
require/class.Common.php 1 patch
Braces   +123 added lines, -53 removed lines patch added patch discarded remove patch
@@ -36,7 +36,9 @@  discard block
 block discarded – undo
36 36
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
37 37
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
38 38
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
39
-		if ($getheaders) curl_setopt($ch, CURLOPT_HEADER, 1); 
39
+		if ($getheaders) {
40
+			curl_setopt($ch, CURLOPT_HEADER, 1);
41
+		}
40 42
 		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
41 43
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
42 44
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
@@ -45,8 +47,11 @@  discard block
 block discarded – undo
45 47
 		} else {
46 48
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
47 49
 		}
48
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
49
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
50
+		if ($timeout == '') {
51
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
52
+		} else {
53
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
54
+		}
50 55
 		//curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
51 56
 		if ($type == 'post') {
52 57
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -59,7 +64,9 @@  discard block
 block discarded – undo
59 64
 			} else {
60 65
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
61 66
 			}
62
-		} elseif ($type != 'get' && $type != '') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
67
+		} elseif ($type != 'get' && $type != '') {
68
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
69
+		}
63 70
 		if ($headers != '') {
64 71
 			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
65 72
 		}
@@ -103,8 +110,9 @@  discard block
 block discarded – undo
103 110
 	private function curlResponseHeaderCallback($ch, $headerLine) {
104 111
 		global $curl_cookies;
105 112
 		$curl_cookies = array();
106
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
107
-			$curl_cookies[] = $cookie;
113
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
114
+					$curl_cookies[] = $cookie;
115
+		}
108 116
 		return strlen($headerLine); // Needed by curl
109 117
 	}
110 118
 
@@ -116,7 +124,9 @@  discard block
 block discarded – undo
116 124
 		curl_setopt($ch, CURLOPT_URL, $url);
117 125
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
118 126
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
119
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
127
+		if ($referer != '') {
128
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
129
+		}
120 130
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
121 131
 			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
122 132
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
@@ -128,7 +138,9 @@  discard block
 block discarded – undo
128 138
 		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');
129 139
 		curl_setopt($ch, CURLOPT_FILE, $fp);
130 140
 		curl_exec($ch);
131
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
141
+		if (curl_errno($ch) && $globalDebug) {
142
+			echo 'Download error: '.curl_error($ch);
143
+		}
132 144
 		curl_close($ch);
133 145
 		fclose($fp);
134 146
 	}
@@ -136,12 +148,16 @@  discard block
 block discarded – undo
136 148
 	public static function gunzip($in_file,$out_file_name = '') {
137 149
 		//echo $in_file.' -> '.$out_file_name."\n";
138 150
 		$buffer_size = 4096; // read 4kb at a time
139
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
151
+		if ($out_file_name == '') {
152
+			$out_file_name = str_replace('.gz', '', $in_file);
153
+		}
140 154
 		if ($in_file != '' && file_exists($in_file)) {
141 155
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
142
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
143
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
144
-			else {
156
+			if (function_exists('gzopen')) {
157
+				$file = gzopen($in_file,'rb');
158
+			} elseif (function_exists('gzopen64')) {
159
+				$file = gzopen64($in_file,'rb');
160
+			} else {
145 161
 				echo 'gzopen not available';
146 162
 				die;
147 163
 			}
@@ -157,11 +173,14 @@  discard block
 block discarded – undo
157 173
 	public static function bunzip2($in_file,$out_file_name = '') {
158 174
 		//echo $in_file.' -> '.$out_file_name."\n";
159 175
 		$buffer_size = 4096; // read 4kb at a time
160
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
176
+		if ($out_file_name == '') {
177
+			$out_file_name = str_replace('.bz2', '', $in_file);
178
+		}
161 179
 		if ($in_file != '' && file_exists($in_file)) {
162 180
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
163
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
164
-			else {
181
+			if (function_exists('bzopen')) {
182
+				$file = bzopen($in_file,'rb');
183
+			} else {
165 184
 				echo 'bzopen not available';
166 185
 				die;
167 186
 			}
@@ -180,10 +199,16 @@  discard block
 block discarded – undo
180 199
 	* @return array array of the tables in HTML page
181 200
 	*/
182 201
 	public function table2array($data) {
183
-		if (!is_string($data)) return array();
184
-		if ($data == '') return array();
202
+		if (!is_string($data)) {
203
+			return array();
204
+		}
205
+		if ($data == '') {
206
+			return array();
207
+		}
185 208
 		$html = str_get_html($data);
186
-		if ($html === false) return array();
209
+		if ($html === false) {
210
+			return array();
211
+		}
187 212
 		$tabledata=array();
188 213
 		foreach($html->find('tr') as $element)
189 214
 		{
@@ -218,7 +243,9 @@  discard block
 block discarded – undo
218 243
 	*/
219 244
 	public function text2array($data) {
220 245
 		$html = str_get_html($data);
221
-		if ($html === false) return array();
246
+		if ($html === false) {
247
+			return array();
248
+		}
222 249
 		$tabledata=array();
223 250
 		foreach($html->find('p') as $element)
224 251
 		{
@@ -239,7 +266,9 @@  discard block
 block discarded – undo
239 266
 	* @return Float Distance in $unit
240 267
 	*/
241 268
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
242
-		if ($lat == $latc && $lon == $lonc) return 0;
269
+		if ($lat == $latc && $lon == $lonc) {
270
+			return 0;
271
+		}
243 272
 		$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;
244 273
 		if ($unit == "km") {
245 274
 			return round($dist * 1.609344);
@@ -285,7 +314,9 @@  discard block
 block discarded – undo
285 314
 		$dX = $latc - $lat;
286 315
 		$dY = $lonc - $lon;
287 316
 		$azimuth = rad2deg(atan2($dY,$dX));
288
-		if ($azimuth < 0) return $azimuth+360;
317
+		if ($azimuth < 0) {
318
+			return $azimuth+360;
319
+		}
289 320
 		return $azimuth;
290 321
 	}
291 322
 	
@@ -299,10 +330,16 @@  discard block
 block discarded – undo
299 330
 	public function withinThreshold ($timeDifference, $distance) {
300 331
 		$x = abs($timeDifference);
301 332
 		$d = abs($distance);
302
-		if ($x == 0 || $d == 0) return true;
333
+		if ($x == 0 || $d == 0) {
334
+			return true;
335
+		}
303 336
 		// may be due to Internet jitter; distance is realistic
304
-		if ($x < 0.7 && $d < 2000) return true;
305
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
337
+		if ($x < 0.7 && $d < 2000) {
338
+			return true;
339
+		} else {
340
+			return $d/$x < 1500*0.27778;
341
+		}
342
+		// 1500 km/h max
306 343
 	}
307 344
 
308 345
 
@@ -354,11 +391,17 @@  discard block
 block discarded – undo
354 391
 	
355 392
 	public function convertDM($coord,$latlong) {
356 393
 		if ($latlong == 'latitude') {
357
-			if ($coord < 0) $NSEW = 'S';
358
-			else $NSEW = 'N';
394
+			if ($coord < 0) {
395
+				$NSEW = 'S';
396
+			} else {
397
+				$NSEW = 'N';
398
+			}
359 399
 		} else {
360
-			if ($coord < 0) $NSEW = 'W';
361
-			else $NSEW = 'E';
400
+			if ($coord < 0) {
401
+				$NSEW = 'W';
402
+			} else {
403
+				$NSEW = 'E';
404
+			}
362 405
 		}
363 406
 		$coord = abs($coord);
364 407
 		$deg = floor($coord);
@@ -368,11 +411,17 @@  discard block
 block discarded – undo
368 411
 	}
369 412
 	public function convertDMS($coord,$latlong) {
370 413
 		if ($latlong == 'latitude') {
371
-			if ($coord < 0) $NSEW = 'S';
372
-			else $NSEW = 'N';
414
+			if ($coord < 0) {
415
+				$NSEW = 'S';
416
+			} else {
417
+				$NSEW = 'N';
418
+			}
373 419
 		} else {
374
-			if ($coord < 0) $NSEW = 'W';
375
-			else $NSEW = 'E';
420
+			if ($coord < 0) {
421
+				$NSEW = 'W';
422
+			} else {
423
+				$NSEW = 'E';
424
+			}
376 425
 		}
377 426
 		$coord = abs($coord);
378 427
 		$deg = floor($coord);
@@ -416,7 +465,9 @@  discard block
 block discarded – undo
416 465
 	public function hex2str($hex) {
417 466
 		$str = '';
418 467
 		$hexln = strlen($hex);
419
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
468
+		for($i=0;$i<$hexln;$i+=2) {
469
+			$str .= chr(hexdec(substr($hex,$i,2)));
470
+		}
420 471
 		return $str;
421 472
 	}
422 473
 	
@@ -453,8 +504,11 @@  discard block
 block discarded – undo
453 504
 		$b = $lat2 - $lat1;
454 505
 		$c = -($a*$lat1+$b*$lon1);
455 506
 		$d = $a*$lat3+$b*$lon3+$c;
456
-		if ($d > -$approx && $d < $approx) return true;
457
-		else return false;
507
+		if ($d > -$approx && $d < $approx) {
508
+			return true;
509
+		} else {
510
+			return false;
511
+		}
458 512
 	}
459 513
 	
460 514
 	public function array_merge_noappend() {
@@ -513,7 +567,9 @@  discard block
 block discarded – undo
513 567
 			return $result;
514 568
 		}
515 569
 		$handle = @opendir('./locale');
516
-		if ($handle === false) return $result;
570
+		if ($handle === false) {
571
+			return $result;
572
+		}
517 573
 		while (false !== ($file = readdir($handle))) {
518 574
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
519 575
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -584,8 +640,9 @@  discard block
 block discarded – undo
584 640
 		$error = false; 
585 641
 		if ($fp_out = gzopen($dest, $mode)) { 
586 642
 			if ($fp_in = fopen($source,'rb')) { 
587
-				while (!feof($fp_in)) 
588
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
643
+				while (!feof($fp_in)) {
644
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
645
+				}
589 646
 				fclose($fp_in); 
590 647
 			} else {
591 648
 				$error = true; 
@@ -594,14 +651,17 @@  discard block
 block discarded – undo
594 651
 		} else {
595 652
 			$error = true; 
596 653
 		}
597
-		if ($error)
598
-			return false; 
599
-		else
600
-			return $dest; 
654
+		if ($error) {
655
+					return false;
656
+		} else {
657
+					return $dest;
658
+		}
601 659
 	} 
602 660
 	
603 661
 	public function remove_accents($string) {
604
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
662
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
663
+			return $string;
664
+		}
605 665
 		$chars = array(
606 666
 		    // Decompositions for Latin-1 Supplement
607 667
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -725,7 +785,9 @@  discard block
 block discarded – undo
725 785
 		$ip = gethostbyname($host);
726 786
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
727 787
 		$r = @socket_connect($s, $ip, $port);
728
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
788
+		if (!socket_set_nonblock($s)) {
789
+			echo "Unable to set nonblock on socket\n";
790
+		}
729 791
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
730 792
 			return $s;
731 793
 		}
@@ -770,18 +832,22 @@  discard block
 block discarded – undo
770 832
 		//NOTE: use a trailing slash for folders!!!
771 833
 		//see http://bugs.php.net/bug.php?id=27609
772 834
 		//see http://bugs.php.net/bug.php?id=30931
773
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
835
+		if ($path{strlen($path)-1}=='/') {
836
+			// recursively return a temporary file path
774 837
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
775
-		else if (is_dir($path))
776
-			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
838
+		} else if (is_dir($path)) {
839
+					return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
840
+		}
777 841
 		// check tmp file for read/write capabilities
778 842
 		$rm = file_exists($path);
779 843
 		$f = @fopen($path, 'a');
780
-		if ($f===false)
781
-			return false;
844
+		if ($f===false) {
845
+					return false;
846
+		}
782 847
 		fclose($f);
783
-		if (!$rm)
784
-			unlink($path);
848
+		if (!$rm) {
849
+					unlink($path);
850
+		}
785 851
 		return true;
786 852
 	}
787 853
 	
@@ -797,7 +863,9 @@  discard block
 block discarded – undo
797 863
 	 * @return Array Coordinate of the route
798 864
 	*/
799 865
 	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
800
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
866
+		if ($nbpts <= 2) {
867
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
868
+		}
801 869
 		$sx = deg2rad($begin_lon);
802 870
 		$sy = deg2rad($begin_lat);
803 871
 		$ex = deg2rad($end_lon);
@@ -806,7 +874,9 @@  discard block
 block discarded – undo
806 874
 		$h = $sy - $ey;
807 875
 		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
808 876
 		$g = 2.0*asin(sqrt($z));
809
-		if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
877
+		if ($g == M_PI || is_nan($g)) {
878
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
879
+		}
810 880
 		$first_pass = array();
811 881
 		$delta = 1.0/($nbpts-1);
812 882
 		for ($i =0; $i < $nbpts; ++$i) {
Please login to merge, or discard this patch.
require/class.ATC.php 1 patch
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
 	public function __construct($dbc = null) {
19 19
 		$Connection = new Connection($dbc);
20 20
 		$this->db = $Connection->db;
21
-		if ($this->db === null) die('Error: No DB connection. (ATC)');
21
+		if ($this->db === null) {
22
+			die('Error: No DB connection. (ATC)');
23
+		}
22 24
 	}
23 25
 
24 26
     /**
@@ -33,20 +35,27 @@  discard block
 block discarded – undo
33 35
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
34 36
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
35 37
 				foreach($globalStatsFilters[$globalFilterName] as $source) {
36
-					if (isset($source['source'])) $filter['source'][] = $source['source'];
38
+					if (isset($source['source'])) {
39
+						$filter['source'][] = $source['source'];
40
+					}
37 41
 				}
38 42
 			} else {
39 43
 				$filter = $globalStatsFilters[$globalFilterName];
40 44
 			}
41 45
 		}
42
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
46
+		if (is_array($globalFilter)) {
47
+			$filter = array_merge($filter,$globalFilter);
48
+		}
43 49
 		$filter_query_join = '';
44 50
 		$filter_query_where = '';
45 51
 		if (isset($filter['source']) && !empty($filter['source'])) {
46 52
 			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
47 53
 		}
48
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
49
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
54
+		if ($filter_query_where == '' && $where) {
55
+			$filter_query_where = ' WHERE';
56
+		} elseif ($filter_query_where != '' && $and) {
57
+			$filter_query_where .= ' AND';
58
+		}
50 59
 		$filter_query = $filter_query_join.$filter_query_where;
51 60
 		return $filter_query;
52 61
 	}
@@ -133,7 +142,9 @@  discard block
 block discarded – undo
133 142
 		$info = str_replace('^','<br />',$info);
134 143
 		$info = str_replace('&amp;sect;','',$info);
135 144
 		$info = str_replace('"','',$info);
136
-		if ($type == '') $type = NULL;
145
+		if ($type == '') {
146
+			$type = NULL;
147
+		}
137 148
 		$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
138 149
 		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
139 150
 		try {
@@ -164,7 +175,9 @@  discard block
 block discarded – undo
164 175
 		$info = str_replace('^','<br />',$info);
165 176
 		$info = str_replace('&amp;sect;','',$info);
166 177
 		$info = str_replace('"','',$info);
167
-		if ($type == '') $type = NULL;
178
+		if ($type == '') {
179
+			$type = NULL;
180
+		}
168 181
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
169 182
 		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
170 183
 		try {
Please login to merge, or discard this patch.