Completed
Push — master ( 3d67e6...35ee00 )
by Yannick
30:32
created
aircraft-data.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 
12 12
 $from_archive = false;
13 13
 if (isset($_GET['ident'])) {
14
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
14
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
15 15
 	if (isset($_GET['currenttime'])) {
16
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
16
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
17 17
 		$currenttime = round($currenttime/1000);
18
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime);
18
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime);
19 19
 		if (empty($spotter_array)) {
20 20
 			$from_archive = true;
21
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime);
21
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime);
22 22
 		}
23 23
 	} else {
24 24
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	}
30 30
 }
31 31
 if (isset($_GET['flightaware_id'])) {
32
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
32
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
33 33
 	if (isset($_GET['currenttime'])) {
34
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
34
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
35 35
 		$currenttime = round($currenttime/1000);
36
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime);
36
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime);
37 37
 		if (empty($spotter_array)) {
38 38
 			$from_archive = true;
39 39
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
40
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime);
40
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime);
41 41
 		}
42 42
 	} else {
43 43
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
58 58
 	{
59 59
 		if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
60
-			$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
60
+			$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
61 61
 		} else $image = $spotter_item['image_thumbnail'];
62 62
 	}
63 63
 	/* else {
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
78 78
 		if (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
79 79
 			if ($spotter_item['departure_airport_time'] > 2460) {
80
-				print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>';
80
+				print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>';
81 81
 			} else {
82 82
 				print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>';
83 83
 			}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
87 87
 		if (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
88 88
 			if ($spotter_item['arrival_airport_time'] > 2460) {
89
-				print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>';
89
+				print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>';
90 90
 			} else {
91 91
 				print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>';
92 92
 			}
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	print '<div id ="altitude"><span>'._("Altitude").'</span>';
112 112
 	if (isset($globalGroundAltitude) && $globalGroundAltitude) {
113 113
 		try {
114
-			$groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']);
115
-		} catch(Exception $e) {
114
+			$groundAltitude = $Elevation->getElevation($spotter_item['latitude'], $spotter_item['longitude']);
115
+		} catch (Exception $e) {
116 116
 			// If catched not exist
117 117
 		}
118 118
 	}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	print '</div>';
180 180
 	if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
181 181
 	if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
182
-	if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
182
+	if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br/>', $spotter_item['acars']['message'])).'</div>';
183 183
 	if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
184 184
 	print '</div>';
185 185
 }
Please login to merge, or discard this patch.
Braces   +49 added lines, -18 removed lines patch added patch discarded remove patch
@@ -58,7 +58,9 @@  discard block
 block discarded – undo
58 58
 	{
59 59
 		if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
60 60
 			$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
61
-		} else $image = $spotter_item['image_thumbnail'];
61
+		} else {
62
+			$image = $spotter_item['image_thumbnail'];
63
+		}
62 64
 	}
63 65
 	/* else {
64 66
 		$image = "images/placeholder_thumb.png";
@@ -70,8 +72,12 @@  discard block
 block discarded – undo
70 72
 	}
71 73
 	print '<div class="right">';
72 74
 	print '<div class="callsign-details">';
73
-	if ($spotter_item['ident'] != 'Not Available') print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
74
-	if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
75
+	if ($spotter_item['ident'] != 'Not Available') {
76
+		print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
77
+	}
78
+	if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') {
79
+		print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
80
+	}
75 81
 	print '</div>';
76 82
 	if ($spotter_item['departure_airport'] != 'NA' && $spotter_item['arrival_airport'] != 'NA') {
77 83
 		print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
@@ -103,10 +109,16 @@  discard block
 block discarded – undo
103 109
 	print '</div>';
104 110
 	print '<div id="aircraft">';
105 111
 	print '<span>'._("Aircraft").'</span>';
106
-	if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
107
-	if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
108
-	elseif (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>';
109
-	else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
112
+	if (isset($spotter_item['aircraft_wiki'])) {
113
+		print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
114
+	}
115
+	if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') {
116
+		print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
117
+	} elseif (isset($spotter_item['aircraft_type'])) {
118
+		print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>';
119
+	} else {
120
+		print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
121
+	}
110 122
 	print '</div>';
111 123
 	print '<div id ="altitude"><span>'._("Altitude").'</span>';
112 124
 	if (isset($globalGroundAltitude) && $globalGroundAltitude) {
@@ -118,11 +130,17 @@  discard block
 block discarded – undo
118 130
 	}
119 131
 
120 132
 	if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
121
-		if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')';
122
-		else print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')';
133
+		if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
134
+			print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')';
135
+		} else {
136
+			print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')';
137
+		}
123 138
 	} else {
124
-		if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')';
125
-		else print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
139
+		if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
140
+			print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')';
141
+		} else {
142
+			print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
143
+		}
126 144
 	}
127 145
 
128 146
 	if (isset($groundAltitude) && $groundAltitude < $spotter_item['altitude']*30.48) {
@@ -136,7 +154,9 @@  discard block
 block discarded – undo
136 154
 		print '</i>';
137 155
 	}
138 156
 	print '</div>';
139
-	if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
157
+	if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') {
158
+		print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
159
+	}
140 160
 	print '<div id="speed"><span>'._("Speed").'</span>';
141 161
 	if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
142 162
 		print round($spotter_item['ground_speed']*1.15078).' mph';
@@ -150,8 +170,11 @@  discard block
 block discarded – undo
150 170
 	print '<div id="heading"><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>';
151 171
 	if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') {
152 172
 		print '<div id="pilot"><span>'._("Pilot").'</span>';
153
-		if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
154
-		else print $spotter_item['pilot_name'];
173
+		if (isset($spotter_item['pilot_id'])) {
174
+			print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
175
+		} else {
176
+			print $spotter_item['pilot_name'];
177
+		}
155 178
 		print '</div>';
156 179
 	}
157 180
 	if (isset($spotter_item['aircraft_owner']) && $spotter_item['aircraft_owner'] != '') {
@@ -177,10 +200,18 @@  discard block
 block discarded – undo
177 200
 	}
178 201
 	print '</div>';
179 202
 	print '</div>';
180
-	if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
181
-	if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
182
-	if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
183
-	if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
203
+	if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') {
204
+		print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
205
+	}
206
+	if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') {
207
+		print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
208
+	}
209
+	if (isset($spotter_item['acars']['message'])) {
210
+		print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
211
+	}
212
+	if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) {
213
+		print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
214
+	}
184 215
 	print '</div>';
185 216
 }
186 217
 ?>
Please login to merge, or discard this patch.
manufacturer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,11 +5,11 @@
 block discarded – undo
5 5
 
6 6
 if (isset($_POST['aircraft_manufacturer']) && $_POST['aircraft_manufacturer'] != '')
7 7
 {
8
-	$aircraft_manufacturer = filter_input(INPUT_POST,'aircraft_manufacturer',FILTER_SANITIZE_STRING);
8
+	$aircraft_manufacturer = filter_input(INPUT_POST, 'aircraft_manufacturer', FILTER_SANITIZE_STRING);
9 9
 	header('Location: '.$globalURL.'/manufacturer/'.$aircraft_manufacturer);
10 10
 } elseif (isset($_GET['aircraft_manufacturer']) && $_GET['aircraft_manufacturer'] != '')
11 11
 {
12
-	$aircraft_manufacturer = filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING);
12
+	$aircraft_manufacturer = filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING);
13 13
 	header('Location: '.$globalURL.'/manufacturer/'.$aircraft_manufacturer);
14 14
 } else {
15 15
 	if ($globalURL == '') {
Please login to merge, or discard this patch.
require/class.METAR.php 2 patches
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 			$Connection = new Connection();
55 55
 			$sth = $Connection->db->prepare($query);
56 56
 			$sth->execute();
57
-		} catch(PDOException $e) {
57
+		} catch (PDOException $e) {
58 58
 			return "error : ".$e->getMessage();
59 59
 		}
60 60
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 			$Connection = new Connection();
71 71
 			$sth = $Connection->db->prepare($query);
72 72
 			$sth->execute();
73
-		} catch(PDOException $e) {
73
+		} catch (PDOException $e) {
74 74
 			return "error : ".$e->getMessage();
75 75
 		}
76 76
 	}
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	public function parse($data) {
79 79
 		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
80 80
 		$codes = implode('|', array_keys($this->texts));
81
-		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
81
+		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
82 82
 		//$pieces = explode(' ',$data);
83
-		$pieces = preg_split('/\s/',$data);
83
+		$pieces = preg_split('/\s/', $data);
84 84
 		$pos = 0;
85 85
 		if ($pieces[0] == 'METAR') $pos++;
86 86
 		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -89,25 +89,25 @@  discard block
 block discarded – undo
89 89
 		if (!isset($pieces[$pos])) return $result;
90 90
 		$result['location'] = $pieces[$pos];
91 91
 		$pos++;
92
-		$result['dayofmonth'] = substr($pieces[$pos],0,2);
93
-		$result['time'] = substr($pieces[$pos],2,4);
92
+		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
93
+		$result['time'] = substr($pieces[$pos], 2, 4);
94 94
 		$c = count($pieces);
95
-		for($pos++; $pos < $c; $pos++) {
95
+		for ($pos++; $pos < $c; $pos++) {
96 96
 			$piece = $pieces[$pos];
97 97
 			if ($piece == 'RMK') break;
98 98
 			if ($piece == 'AUTO') $result['auto'] = true;
99 99
 			if ($piece == 'COR') $result['correction'] = true;
100 100
 			// Wind Speed
101 101
 			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
102
-				$result['wind']['direction'] = (float)$matches[1];
102
+				$result['wind']['direction'] = (float) $matches[1];
103 103
 				$result['wind']['unit'] = $matches[4];
104
-				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
105
-				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
106
-				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
107
-				$result['wind']['gust'] = (float)$matches[3];
104
+				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
105
+				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
106
+				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
107
+				$result['wind']['gust'] = (float) $matches[3];
108 108
 				$result['wind']['unit'] = $matches[4];
109
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
110
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
109
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
110
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
111 111
 			}
112 112
 
113 113
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 
129 129
 			// Temperature
130 130
 			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-				$temp = (float)$matches[1];
131
+				$temp = (float) $matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133
-					$temp = ((float)substr($matches[1], 1)) * -1;
133
+					$temp = ((float) substr($matches[1], 1))*-1;
134 134
 				}
135 135
 				$result['temperature'] = $temp;
136
-				$dew = (float)$matches[2];
136
+				$dew = (float) $matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138
-					$dew = ((float)substr($matches[2], 1)) * -1;
138
+					$dew = ((float) substr($matches[2], 1))*-1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141 141
 			}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 					$result['QNH'] = $matches[2];
148 148
 				} else {
149 149
 					// inHg
150
-					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
150
+					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
151 151
 				}
152 152
 				/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
     			// Visibility
169 169
 			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170 170
 				if (isset($matches[3]) && strlen($matches[3]) > 0) {
171
-					$result['visibility'] = (float)$matches[3] * 1609.34;
171
+					$result['visibility'] = (float) $matches[3]*1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
174 174
 						$result['visibility'] = '> 10000';
175 175
 					} else {
176
-						$result['visibility'] = (float)$matches[1];
176
+						$result['visibility'] = (float) $matches[1];
177 177
 					}
178 178
 				}
179 179
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196 196
 				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197 197
 				$cloud['type_code'] = $type;
198
-				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
198
+				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
199 199
 				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200 200
 				$result['cloud'][] = $cloud;
201 201
 			}
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
208
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
209
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
208
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
209
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
 			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
@@ -219,12 +219,12 @@  discard block
 block discarded – undo
219 219
 				$result['RVR']['friction'] = $matches[5];
220 220
 			}
221 221
 			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
222
-				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
223
-				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
222
+				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
223
+				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
224 224
 				if (isset($matches[3])) {
225 225
 					$range = Array(
226
-					    'from' => (float)$matches[2],
227
-					    'to'   => (float)$matches[4],
226
+					    'from' => (float) $matches[2],
227
+					    'to'   => (float) $matches[4],
228 228
 					    'unit' => $matches[5] ? 'FT' : 'M'
229 229
 					);
230 230
 				}
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		try {
273 273
 			$sth = $this->db->prepare($query);
274 274
 			$sth->execute($query_values);
275
-		} catch(PDOException $e) {
275
+		} catch (PDOException $e) {
276 276
 			return "error : ".$e->getMessage();
277 277
 		}
278 278
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
 		return $all;
283 283
 	}
284 284
 
285
-	public function addMETAR($location,$metar,$date) {
285
+	public function addMETAR($location, $metar, $date) {
286 286
 		global $globalDBdriver;
287
-		$date = date('Y-m-d H:i:s',strtotime($date));
287
+		$date = date('Y-m-d H:i:s', strtotime($date));
288 288
 		if ($globalDBdriver == 'mysql') {
289 289
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
290 290
 		} else {
291 291
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
292 292
 		}
293
-		$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
293
+		$query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
294 294
 		try {
295 295
 			$sth = $this->db->prepare($query);
296 296
 			$sth->execute($query_values);
297
-		} catch(PDOException $e) {
297
+		} catch (PDOException $e) {
298 298
 			return "error : ".$e->getMessage();
299 299
 		}
300 300
 	}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 		try {
306 306
 			$sth = $this->db->prepare($query);
307 307
 			$sth->execute($query_values);
308
-		} catch(PDOException $e) {
308
+		} catch (PDOException $e) {
309 309
 			return "error : ".$e->getMessage();
310 310
 		}
311 311
 	}
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 		try {
316 316
 			$sth = $this->db->prepare($query);
317 317
 			$sth->execute();
318
-		} catch(PDOException $e) {
318
+		} catch (PDOException $e) {
319 319
 			return "error : ".$e->getMessage();
320 320
 		}
321 321
 	}
@@ -326,27 +326,27 @@  discard block
 block discarded – undo
326 326
 		date_default_timezone_set("UTC");
327 327
 		$Common = new Common();
328 328
 		if (isset($globalIVAO) && $globalIVAO) {
329
-			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
330
-			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
329
+			$Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt');
330
+			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r");
331 331
 		} else {
332
-			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
333
-			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
332
+			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
333
+			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r");
334 334
 		}
335 335
 		if ($handle) {
336 336
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
337 337
 			$date = '';
338 338
 			if ($globalTransaction) $this->db->beginTransaction();
339
-			while(($line = fgets($handle,4096)) !== false) {
340
-				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
339
+			while (($line = fgets($handle, 4096)) !== false) {
340
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
341 341
 					$date = $line;
342 342
 				} elseif ($line != '') {
343 343
 					if ($date == '') $date = date('Y/m/d H:m');
344 344
 					$pos = 0;
345
-					$pieces = preg_split('/\s/',$line);
345
+					$pieces = preg_split('/\s/', $line);
346 346
 					if ($pieces[0] == 'METAR') $pos++;
347 347
 					if (strlen($pieces[$pos]) != 4) $pos++;
348 348
 					$location = $pieces[$pos];
349
-					echo $this->addMETAR($location,$line,$date);
349
+					echo $this->addMETAR($location, $line, $date);
350 350
 				}
351 351
 			}
352 352
 			fclose($handle);
@@ -360,22 +360,22 @@  discard block
 block discarded – undo
360 360
 		if ($globalMETARurl == '') return array();
361 361
 		date_default_timezone_set("UTC");
362 362
 		$Common = new Common();
363
-		$url = str_replace('{icao}',$icao,$globalMETARurl);
363
+		$url = str_replace('{icao}', $icao, $globalMETARurl);
364 364
 		$cycle = $Common->getData($url);
365 365
 		$date = '';
366
-		foreach(explode("\n",$cycle) as $line) {
367
-			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
366
+		foreach (explode("\n", $cycle) as $line) {
367
+			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
368 368
 				$date = $line;
369 369
 			} 
370 370
 			if ($line != '') {
371 371
 				if ($date == '') $date = date('Y/m/d H:m');
372 372
 				$pos = 0;
373
-				$pieces = preg_split('/\s/',$line);
373
+				$pieces = preg_split('/\s/', $line);
374 374
 				if ($pieces[0] == 'METAR') $pos++;
375 375
 				if (strlen($pieces[$pos]) != 4) $pos++;
376 376
 				$location = $pieces[$pos];
377 377
 				if (strlen($location == 4)) {
378
-					$this->addMETAR($location,$line,$date);
378
+					$this->addMETAR($location, $line, $date);
379 379
 					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
380 380
 				} else return array();
381 381
 			}
Please login to merge, or discard this patch.
Braces   +103 added lines, -39 removed lines patch added patch discarded remove patch
@@ -59,8 +59,11 @@  discard block
 block discarded – undo
59 59
 		}
60 60
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
61 61
 		$sth->closeCursor();
62
-		if ($row['nb'] > 0) return false;
63
-		else return true;
62
+		if ($row['nb'] > 0) {
63
+			return false;
64
+		} else {
65
+			return true;
66
+		}
64 67
 	}
65 68
 
66 69
 	public static function insert_last_update() {
@@ -82,11 +85,18 @@  discard block
 block discarded – undo
82 85
 		//$pieces = explode(' ',$data);
83 86
 		$pieces = preg_split('/\s/',$data);
84 87
 		$pos = 0;
85
-		if ($pieces[0] == 'METAR') $pos++;
86
-		elseif ($pieces[0] == 'SPECI') $pos++;
87
-		if (strlen($pieces[$pos]) != 4) $pos++;
88
+		if ($pieces[0] == 'METAR') {
89
+			$pos++;
90
+		} elseif ($pieces[0] == 'SPECI') {
91
+			$pos++;
92
+		}
93
+		if (strlen($pieces[$pos]) != 4) {
94
+			$pos++;
95
+		}
88 96
 		$result = array();
89
-		if (!isset($pieces[$pos])) return $result;
97
+		if (!isset($pieces[$pos])) {
98
+			return $result;
99
+		}
90 100
 		$result['location'] = $pieces[$pos];
91 101
 		$pos++;
92 102
 		$result['dayofmonth'] = substr($pieces[$pos],0,2);
@@ -94,16 +104,26 @@  discard block
 block discarded – undo
94 104
 		$c = count($pieces);
95 105
 		for($pos++; $pos < $c; $pos++) {
96 106
 			$piece = $pieces[$pos];
97
-			if ($piece == 'RMK') break;
98
-			if ($piece == 'AUTO') $result['auto'] = true;
99
-			if ($piece == 'COR') $result['correction'] = true;
107
+			if ($piece == 'RMK') {
108
+				break;
109
+			}
110
+			if ($piece == 'AUTO') {
111
+				$result['auto'] = true;
112
+			}
113
+			if ($piece == 'COR') {
114
+				$result['correction'] = true;
115
+			}
100 116
 			// Wind Speed
101 117
 			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
102 118
 				$result['wind']['direction'] = (float)$matches[1];
103 119
 				$result['wind']['unit'] = $matches[4];
104
-				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
105
-				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
106
-				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
120
+				if ($result['wind']['unit'] == 'KT') {
121
+					$result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
122
+				} elseif ($result['wind']['unit'] == 'KPH') {
123
+					$result['wind']['speed'] = round(((float)$matches[2])*1000,2);
124
+				} elseif ($result['wind']['unit'] == 'MPS') {
125
+					$result['wind']['speed'] = round(((float)$matches[2]),2);
126
+				}
107 127
 				$result['wind']['gust'] = (float)$matches[3];
108 128
 				$result['wind']['unit'] = $matches[4];
109 129
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
@@ -186,14 +206,23 @@  discard block
 block discarded – undo
186 206
 				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187 207
 				$type = $matches[1];
188 208
 				$cloud = array();
189
-				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
209
+				if ($type == 'SKC') {
210
+					$cloud['type'] = 'No cloud/Sky clear';
211
+				} elseif ($type == 'CLR') {
212
+					$cloud['type'] = 'No cloud below 12,000ft (3700m)';
213
+				} elseif ($type == 'NSC') {
214
+					$cloud['type'] = 'No significant cloud';
215
+				} elseif ($type == 'FEW') {
216
+					$cloud['type'] = 'Few';
217
+				} elseif ($type == 'SCT') {
218
+					$cloud['type'] = 'Scattered';
219
+				} elseif ($type == 'BKN') {
220
+					$cloud['type'] = 'Broken';
221
+				} elseif ($type == 'OVC') {
222
+					$cloud['type'] = 'Overcast/Full cloud coverage';
223
+				} elseif ($type == 'VV') {
224
+					$cloud['type'] = 'Vertical visibility';
225
+				}
197 226
 				$cloud['type_code'] = $type;
198 227
 				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199 228
 				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
@@ -219,8 +248,11 @@  discard block
 block discarded – undo
219 248
 				$result['RVR']['friction'] = $matches[5];
220 249
 			}
221 250
 			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
222
-				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
223
-				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
251
+				if (isset($matches[5])) {
252
+					$range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
253
+				} else {
254
+					$range = array('exact' => (float)$matches[2], 'unit' => 'M');
255
+				}
224 256
 				if (isset($matches[3])) {
225 257
 					$range = Array(
226 258
 					    'from' => (float)$matches[2],
@@ -253,8 +285,11 @@  discard block
 block discarded – undo
253 285
 				if (isset($matches[3])) {
254 286
 					$text[] = $this->texts[$matches[3]];
255 287
 				}
256
-				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
257
-				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
288
+				if (!isset($result['weather'])) {
289
+					$result['weather'] = implode(' ', $text);
290
+				} else {
291
+					$result['weather'] = $result['weather'].' / '.implode(' ', $text);
292
+				}
258 293
 			}
259 294
 		}
260 295
 		return $result;
@@ -265,8 +300,11 @@  discard block
 block discarded – undo
265 300
 		if (isset($globalMETARcycle) && $globalMETARcycle) {
266 301
 			$query = "SELECT * FROM metar WHERE metar_location = :icao";
267 302
 		} else {
268
-			if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
269
-			else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
303
+			if ($globalDBdriver == 'mysql') {
304
+				$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
305
+			} else {
306
+				$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
307
+			}
270 308
 		}
271 309
 		$query_values = array(':icao' => $icao);
272 310
 		try {
@@ -322,7 +360,9 @@  discard block
 block discarded – undo
322 360
 
323 361
 	public function addMETARCycle() {
324 362
 		global $globalDebug, $globalIVAO, $globalTransaction;
325
-		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
363
+		if (isset($globalDebug) && $globalDebug) {
364
+			echo "Downloading METAR cycle...";
365
+		}
326 366
 		date_default_timezone_set("UTC");
327 367
 		$Common = new Common();
328 368
 		if (isset($globalIVAO) && $globalIVAO) {
@@ -333,31 +373,47 @@  discard block
 block discarded – undo
333 373
 			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
334 374
 		}
335 375
 		if ($handle) {
336
-			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
376
+			if (isset($globalDebug) && $globalDebug) {
377
+				echo "Done - Updating DB...";
378
+			}
337 379
 			$date = '';
338
-			if ($globalTransaction) $this->db->beginTransaction();
380
+			if ($globalTransaction) {
381
+				$this->db->beginTransaction();
382
+			}
339 383
 			while(($line = fgets($handle,4096)) !== false) {
340 384
 				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
341 385
 					$date = $line;
342 386
 				} elseif ($line != '') {
343
-					if ($date == '') $date = date('Y/m/d H:m');
387
+					if ($date == '') {
388
+						$date = date('Y/m/d H:m');
389
+					}
344 390
 					$pos = 0;
345 391
 					$pieces = preg_split('/\s/',$line);
346
-					if ($pieces[0] == 'METAR') $pos++;
347
-					if (strlen($pieces[$pos]) != 4) $pos++;
392
+					if ($pieces[0] == 'METAR') {
393
+						$pos++;
394
+					}
395
+					if (strlen($pieces[$pos]) != 4) {
396
+						$pos++;
397
+					}
348 398
 					$location = $pieces[$pos];
349 399
 					echo $this->addMETAR($location,$line,$date);
350 400
 				}
351 401
 			}
352 402
 			fclose($handle);
353
-			if ($globalTransaction) $this->db->commit();
403
+			if ($globalTransaction) {
404
+				$this->db->commit();
405
+			}
406
+		}
407
+		if (isset($globalDebug) && $globalDebug) {
408
+			echo "Done\n";
354 409
 		}
355
-		if (isset($globalDebug) && $globalDebug) echo "Done\n";
356 410
 	}
357 411
 
358 412
 	public function downloadMETAR($icao) {
359 413
 		global $globalMETARurl;
360
-		if ($globalMETARurl == '') return array();
414
+		if ($globalMETARurl == '') {
415
+			return array();
416
+		}
361 417
 		date_default_timezone_set("UTC");
362 418
 		$Common = new Common();
363 419
 		$url = str_replace('{icao}',$icao,$globalMETARurl);
@@ -368,16 +424,24 @@  discard block
 block discarded – undo
368 424
 				$date = $line;
369 425
 			} 
370 426
 			if ($line != '') {
371
-				if ($date == '') $date = date('Y/m/d H:m');
427
+				if ($date == '') {
428
+					$date = date('Y/m/d H:m');
429
+				}
372 430
 				$pos = 0;
373 431
 				$pieces = preg_split('/\s/',$line);
374
-				if ($pieces[0] == 'METAR') $pos++;
375
-				if (strlen($pieces[$pos]) != 4) $pos++;
432
+				if ($pieces[0] == 'METAR') {
433
+					$pos++;
434
+				}
435
+				if (strlen($pieces[$pos]) != 4) {
436
+					$pos++;
437
+				}
376 438
 				$location = $pieces[$pos];
377 439
 				if (strlen($location == 4)) {
378 440
 					$this->addMETAR($location,$line,$date);
379 441
 					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
380
-				} else return array();
442
+				} else {
443
+					return array();
444
+				}
381 445
 			}
382 446
 		}
383 447
 		return array();
Please login to merge, or discard this patch.