Completed
Push — master ( 7e56d1...afdb22 )
by Yannick
05:45
created
aircraft-data.php 2 patches
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -46,7 +46,9 @@  discard block
 block discarded – undo
46 46
 {
47 47
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
48 48
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
49
-	} else $image = $spotter_item['image_thumbnail'];
49
+	} else {
50
+		$image = $spotter_item['image_thumbnail'];
51
+	}
50 52
 
51 53
 }
52 54
 /* else {
@@ -58,7 +60,9 @@  discard block
 block discarded – undo
58 60
 	print '<div class="left"><img src="'.$image.'" alt="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].'" title="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' Image &copy; '.$spotter_item['image_copyright'].'"/><br />Image &copy; '.$spotter_item['image_copyright'].'</div>';
59 61
 }
60 62
 print '<div class="right"><div class="callsign-details"><div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
61
-if (isset($spotter_item['airline_name'])) print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
63
+if (isset($spotter_item['airline_name'])) {
64
+	print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
65
+}
62 66
 print '</div>';
63 67
 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'];
64 68
 if (isset($spotter_item['departure_airport_time'])) {
@@ -86,9 +90,14 @@  discard block
 block discarded – undo
86 90
 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 91
 print '</div></div><div>';
88 92
 print '<span>'._("Aircraft").'</span>';
89
-if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
90
-if (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
91
-else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
93
+if (isset($spotter_item['aircraft_wiki'])) {
94
+	print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
95
+}
96
+if (isset($spotter_item['aircraft_type'])) {
97
+	print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
98
+} else {
99
+	print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
100
+}
92 101
 print '</div>';
93 102
 print '<div><span>'._("Altitude").'</span>';
94 103
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
@@ -97,7 +106,9 @@  discard block
 block discarded – undo
97 106
 	print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
98 107
 }
99 108
 print '</div>';
100
-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>';
109
+if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') {
110
+	print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
111
+}
101 112
 print '<div><span>'._("Speed").'</span>';
102 113
 if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
103 114
 	print round($spotter_item['ground_speed']*1.15078).' mph';
@@ -111,8 +122,11 @@  discard block
 block discarded – undo
111 122
 print '<div><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>';
112 123
 if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') {
113 124
 	print '<div><span>'._("Pilot").'</span>';
114
-	if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
115
-	else print $spotter_item['pilot_name'];
125
+	if (isset($spotter_item['pilot_id'])) {
126
+		print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
127
+	} else {
128
+		print $spotter_item['pilot_name'];
129
+	}
116 130
 	print '</div>';
117 131
 }
118 132
 
@@ -133,10 +147,18 @@  discard block
 block discarded – undo
133 147
 }
134 148
 print '</div>';
135 149
 
136
-if (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>';
137
-if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
138
-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>';
139
-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>';
150
+if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') {
151
+	print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
152
+}
153
+if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') {
154
+	print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
155
+}
156
+if (isset($spotter_item['acars']['message'])) {
157
+	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>';
158
+}
159
+if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) {
160
+	print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
161
+}
140 162
 print '</div>';
141 163
 ?>
142 164
 </div>
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@  discard block
 block discarded – undo
9 9
 
10 10
 $from_archive = false;
11 11
 if (isset($_GET['ident'])) {
12
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
13 13
 	if (isset($_GET['currenttime'])) {
14
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
14
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
15 15
 		$currenttime = round($currenttime/1000);
16
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime);
16
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime);
17 17
 		if (empty($spotter_array)) {
18 18
 			$from_archive = true;
19
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime);
19
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime);
20 20
 		}
21 21
 	} else {
22 22
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 	}
28 28
 }
29 29
 if (isset($_GET['flightaware_id'])) {
30
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
30
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
31 31
 	if (isset($_GET['currenttime'])) {
32
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
32
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
33 33
 		$currenttime = round($currenttime/1000);
34
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime);
34
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime);
35 35
 		if (empty($spotter_array)) {
36 36
 			$from_archive = true;
37 37
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
38
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime);
38
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime);
39 39
 		}
40 40
 	} else {
41 41
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
55 55
 {
56 56
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
57
-		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
57
+		$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
58 58
 	} else $image = $spotter_item['image_thumbnail'];
59 59
 
60 60
 }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 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'];
73 73
 if (isset($spotter_item['departure_airport_time'])) {
74 74
 	if ($spotter_item['departure_airport_time'] > 2460) {
75
-		print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>';
75
+		print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>';
76 76
 	} else {
77 77
 		print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>';
78 78
 	}
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 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'];
82 82
 if (isset($spotter_item['arrival_airport_time'])) {
83 83
 	if ($spotter_item['arrival_airport_time'] > 2460) {
84
-		print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>';
84
+		print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>';
85 85
 	} else {
86 86
 		print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>';
87 87
 	}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
 if (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>';
151 151
 if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
152
-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>';
152
+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>';
153 153
 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>';
154 154
 print '</div>';
155 155
 ?>
Please login to merge, or discard this patch.
live-czml.php 3 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 function quaternionrotate($heading, $attitude = 0, $bank = 0) {
16
-    // Assuming the angles are in radians.
17
-    $c1 = cos($heading/2);
18
-    $s1 = sin($heading/2);
19
-    $c2 = cos($attitude/2);
20
-    $s2 = sin($attitude/2);
21
-    $c3 = cos($bank/2);
22
-    $s3 = sin($bank/2);
23
-    $c1c2 = $c1*$c2;
24
-    $s1s2 = $s1*$s2;
25
-    $w =$c1c2*$c3 - $s1s2*$s3;
26
-    $x =$c1c2*$s3 + $s1s2*$c3;
27
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
28
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
29
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
16
+	// Assuming the angles are in radians.
17
+	$c1 = cos($heading/2);
18
+	$s1 = sin($heading/2);
19
+	$c2 = cos($attitude/2);
20
+	$s2 = sin($attitude/2);
21
+	$c3 = cos($bank/2);
22
+	$s3 = sin($bank/2);
23
+	$c1c2 = $c1*$c2;
24
+	$s1s2 = $s1*$s2;
25
+	$w =$c1c2*$c3 - $s1s2*$s3;
26
+	$x =$c1c2*$s3 + $s1s2*$c3;
27
+	$y =$s1*$c2*$c3 + $c1*$s2*$s3;
28
+	$z =$c1*$s2*$c3 - $s1*$c2*$s3;
29
+	return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
30 30
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
31 31
 
32 32
 }
33 33
 
34 34
 
35 35
 if (isset($_GET['download'])) {
36
-    if ($_GET['download'] == "true")
37
-    {
36
+	if ($_GET['download'] == "true")
37
+	{
38 38
 	header('Content-disposition: attachment; filename="flightairmap.json"');
39
-    }
39
+	}
40 40
 }
41 41
 header('Content-Type: text/javascript');
42 42
 
@@ -188,78 +188,78 @@  discard block
 block discarded – undo
188 188
 				$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20 },';
189 189
 			} elseif ($spotter_item['engine_type'] == 'Jet') {
190 190
 				if ($spotter_item['engine_count'] == '1') {
191
-				    if ($spotter_item['wake_category'] == 'M') {
191
+					if ($spotter_item['wake_category'] == 'M') {
192 192
 					$model = 'J1M';
193
-				    } elseif ($spotter_item['wake_category'] == 'L') {
193
+					} elseif ($spotter_item['wake_category'] == 'L') {
194 194
 					$model = '';
195
-				    }
195
+					}
196 196
 				} elseif ($spotter_item['engine_count'] == '2') {
197
-				    if ($spotter_item['wake_category'] == 'M') {
197
+					if ($spotter_item['wake_category'] == 'M') {
198 198
 					$model = 'J2M';
199
-				    } elseif ($spotter_item['wake_category'] == 'H') {
199
+					} elseif ($spotter_item['wake_category'] == 'H') {
200 200
 					$model = 'J2H';
201
-				    } elseif ($spotter_item['wake_category'] == 'L') {
201
+					} elseif ($spotter_item['wake_category'] == 'L') {
202 202
 					$model = 'J2L';
203
-				    }
203
+					}
204 204
 				} elseif ($spotter_item['engine_count'] == '3') {
205
-				    if ($spotter_item['wake_category'] == 'M') {
205
+					if ($spotter_item['wake_category'] == 'M') {
206 206
 					$model = 'J3M';
207
-				    } elseif ($spotter_item['wake_category'] == 'H') {
207
+					} elseif ($spotter_item['wake_category'] == 'H') {
208 208
 					$model = 'J3H';
209
-				    }
209
+					}
210 210
 				} elseif ($spotter_item['engine_count'] == '4') {
211
-				    if ($spotter_item['wake_category'] == 'M') {
211
+					if ($spotter_item['wake_category'] == 'M') {
212 212
 					$model = 'J4M';
213
-				    } elseif ($spotter_item['wake_category'] == 'H') {
213
+					} elseif ($spotter_item['wake_category'] == 'H') {
214 214
 					$model = 'J4H';
215
-				    }
215
+					}
216 216
 				}
217 217
 				if (isset($modelsdb[$model])) {
218
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
218
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
219 219
 				} else {
220
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
220
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
221 221
 				}
222 222
 			} elseif ($spotter_item['engine_type'] == 'Turboprop') {
223 223
 				if ($spotter_item['engine_count'] == '1') {
224
-				    if ($spotter_item['wake_category'] == 'L') {
224
+					if ($spotter_item['wake_category'] == 'L') {
225 225
 					$model = 'T1L';
226
-				    }
226
+					}
227 227
 				} elseif ($spotter_item['engine_count'] == '2') {
228
-				    if ($spotter_item['wake_category'] == 'M') {
228
+					if ($spotter_item['wake_category'] == 'M') {
229 229
 					$model = 'T2M';
230
-				    } elseif ($spotter_item['wake_category'] == 'L') {
230
+					} elseif ($spotter_item['wake_category'] == 'L') {
231 231
 					$model = 'T2L';
232
-				    }
232
+					}
233 233
 				} elseif ($spotter_item['engine_count'] == '4') {
234
-				    if ($spotter_item['wake_category'] == 'M') {
235
-				    } elseif ($spotter_item['wake_category'] == 'H') {
234
+					if ($spotter_item['wake_category'] == 'M') {
235
+					} elseif ($spotter_item['wake_category'] == 'H') {
236 236
 					$model = 'T4H';
237
-				    }
237
+					}
238 238
 				}
239 239
 				if (isset($modelsdb[$model])) {
240
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
240
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
241 241
 				} else {
242
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
242
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
243 243
 				}
244 244
 			} elseif ($spotter_item['engine_type'] == 'Piston') {
245 245
 				if ($spotter_item['engine_count'] == '1') {
246
-				    if ($spotter_item['wake_category'] == 'L') {
246
+					if ($spotter_item['wake_category'] == 'L') {
247 247
 					$model = 'P1L';
248
-				    } elseif ($spotter_item['wake_category'] == 'M') {
248
+					} elseif ($spotter_item['wake_category'] == 'M') {
249 249
 					$model = 'P1M';
250
-				    }
250
+					}
251 251
 				} elseif ($spotter_item['engine_count'] == '2') {
252
-				    if ($spotter_item['wake_category'] == 'M') {
252
+					if ($spotter_item['wake_category'] == 'M') {
253 253
 					$model = 'P2M';
254
-				    } elseif ($spotter_item['wake_category'] == 'L') {
254
+					} elseif ($spotter_item['wake_category'] == 'L') {
255 255
 					$model = 'P2L';
256
-				    }
256
+					}
257 257
 				// ju52 = P3M
258 258
 				}
259 259
 				if (isset($modelsdb[$model])) {
260
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
260
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
261 261
 				} else {
262
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
262
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
263 263
 				}
264 264
 			} else {
265 265
 				$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
     $s3 = sin($bank/2);
23 23
     $c1c2 = $c1*$c2;
24 24
     $s1s2 = $s1*$s2;
25
-    $w =$c1c2*$c3 - $s1s2*$s3;
26
-    $x =$c1c2*$s3 + $s1s2*$c3;
27
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
28
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
29
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
25
+    $w = $c1c2*$c3 - $s1s2*$s3;
26
+    $x = $c1c2*$s3 + $s1s2*$c3;
27
+    $y = $s1*$c2*$c3 + $c1*$s2*$s3;
28
+    $z = $c1*$s2*$c3 - $s1*$c2*$s3;
29
+    return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w);
30 30
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
31 31
 
32 32
 }
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 $min = false;
48 48
 $allhistory = false;
49 49
 $filter['source'] = array();
50
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
51
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
52
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
53
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
54
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
55
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
56
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
57
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
58
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
50
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
51
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
52
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
53
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs'));
54
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
55
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
56
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
57
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
58
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
59 59
 /*
60 60
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
61 61
 	$min = true;
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 	$from_archive = true;
103 103
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
104 104
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
105
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
106
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
107
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
108
-	$begindate = date('Y-m-d H:i:s',$begindate);
109
-	$enddate = date('Y-m-d H:i:s',$enddate);
110
-	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter);
105
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
106
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
107
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
108
+	$begindate = date('Y-m-d H:i:s', $begindate);
109
+	$enddate = date('Y-m-d H:i:s', $enddate);
110
+	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter);
111 111
 } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) {
112 112
 	$from_archive = true;
113 113
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
@@ -117,34 +117,34 @@  discard block
 block discarded – undo
117 117
 	$begindate = $_COOKIE['archive_begin'];
118 118
 	$enddate = $_COOKIE['archive_end'];
119 119
 
120
-	$archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT);
121
-	$begindate = date('Y-m-d H:i:s',$begindate);
122
-	$enddate = date('Y-m-d H:i:s',$enddate);
120
+	$archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT);
121
+	$begindate = date('Y-m-d H:i:s', $begindate);
122
+	$enddate = date('Y-m-d H:i:s', $enddate);
123 123
 //	echo 'Begin : '.$begindate.' - End : '.$enddate."\n";
124
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
124
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
125 125
 } else {
126 126
 	$spotter_array = $SpotterLive->getMinLastLiveSpotterData($filter);
127 127
 }
128 128
 
129 129
 if (!empty($spotter_array)) {
130 130
 	if (isset($_GET['archive'])) {
131
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
131
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
132 132
 	} else {
133 133
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
134 134
 	}
135 135
 	if ($flightcnt == '') $flightcnt = 0;
136 136
 } else $flightcnt = 0;
137 137
 
138
-$sqltime = round(microtime(true)-$begintime,2);
138
+$sqltime = round(microtime(true) - $begintime, 2);
139 139
 $minitime = time();
140 140
 $maxitime = 0;
141 141
 
142 142
 
143 143
 $modelsdb = array();
144 144
 if (file_exists('models/modelsdb')) {
145
-	if (($handle = fopen('models/modelsdb','r')) !== FALSE) {
146
-		while (($row = fgetcsv($handle,1000)) !== FALSE) {
147
-			if (isset($row[1]) ){
145
+	if (($handle = fopen('models/modelsdb', 'r')) !== FALSE) {
146
+		while (($row = fgetcsv($handle, 1000)) !== FALSE) {
147
+			if (isset($row[1])) {
148 148
 				$model = $row[0];
149 149
 				$modelsdb[$model] = $row[1];
150 150
 			}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 $output .= '},';
173 173
 if (!empty($spotter_array) && is_array($spotter_array))
174 174
 {
175
-	foreach($spotter_array as $spotter_item)
175
+	foreach ($spotter_array as $spotter_item)
176 176
 	{
177 177
 		$j++;
178 178
 		date_default_timezone_set('UTC');
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			$output .= '"cartographicDegrees": [';
311 311
 			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
312 312
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
313
-			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
313
+			$output .= '"'.date("c", strtotime($spotter_item['date'])).'", ';
314 314
 			$output .= $spotter_item['longitude'].', ';
315 315
 			$output .= $spotter_item['latitude'].', ';
316 316
 			$prevlong = $spotter_item['longitude'];
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
323 323
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
324 324
 		} else {
325
-			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
325
+			$output .= ',"'.date("c", strtotime($spotter_item['date'])).'", ';
326 326
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
327 327
 			if ($spotter_item['ground_speed'] == 0) {
328 328
 				$output .= $prevlong.', ';
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	$output  = substr($output, 0, -1);
352 352
 }
353 353
 $output .= ']';
354
-$output = str_replace('%minitime%',date("c",$minitime),$output);
355
-$output = str_replace('%maxitime%',date("c",$maxitime),$output);
354
+$output = str_replace('%minitime%', date("c", $minitime), $output);
355
+$output = str_replace('%maxitime%', date("c", $maxitime), $output);
356 356
 print $output;
357 357
 ?>
Please login to merge, or discard this patch.
Braces   +56 added lines, -19 removed lines patch added patch discarded remove patch
@@ -40,22 +40,43 @@  discard block
 block discarded – undo
40 40
 }
41 41
 header('Content-Type: text/javascript');
42 42
 
43
-if (!isset($globalJsonCompress)) $compress = true;
44
-else $compress = $globalJsonCompress;
43
+if (!isset($globalJsonCompress)) {
44
+	$compress = true;
45
+} else {
46
+	$compress = $globalJsonCompress;
47
+}
45 48
 
46 49
 $from_archive = false;
47 50
 $min = false;
48 51
 $allhistory = false;
49 52
 $filter['source'] = array();
50
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
51
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
52
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
53
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
54
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
55
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
56
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
57
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
58
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
53
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
54
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
55
+}
56
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
57
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
58
+}
59
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
60
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
+}
62
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
63
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
64
+}
65
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
66
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
67
+}
68
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
69
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
70
+}
71
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
72
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
73
+}
74
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
75
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
+}
77
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
78
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
79
+}
59 80
 /*
60 81
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
61 82
 	$min = true;
@@ -132,8 +153,12 @@  discard block
 block discarded – undo
132 153
 	} else {
133 154
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
134 155
 	}
135
-	if ($flightcnt == '') $flightcnt = 0;
136
-} else $flightcnt = 0;
156
+	if ($flightcnt == '') {
157
+		$flightcnt = 0;
158
+	}
159
+	} else {
160
+	$flightcnt = 0;
161
+}
137 162
 
138 163
 $sqltime = round(microtime(true)-$begintime,2);
139 164
 $minitime = time();
@@ -155,7 +180,9 @@  discard block
 block discarded – undo
155 180
 $j = 0;
156 181
 $prev_flightaware_id = '';
157 182
 $speed = 1;
158
-if (isset($archivespeed)) $speed = $archivespeed;
183
+if (isset($archivespeed)) {
184
+	$speed = $archivespeed;
185
+}
159 186
 $output = '[';
160 187
 $output .= '{"id" : "document", "name" : "fam","version" : "1.0"';
161 188
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "LOOP_STOP","step": "SYSTEM_CLOCK_MULTIPLIER"}';
@@ -296,8 +323,12 @@  discard block
 block discarded – undo
296 323
 				}
297 324
 			} else {
298 325
 				$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
299
-				if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
300
-				if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
326
+				if ($spotter_item['aircraft_shadow'] != '') {
327
+					$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
328
+				}
329
+				if ($spotter_item['aircraft_icao'] != '') {
330
+					$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
331
+				}
301 332
 			}
302 333
 	//		$output .= '"heightReference": "CLAMP_TO_GROUND",';
303 334
 			$output .= '"heightReference": "RELATIVE_TO_GROUND",';
@@ -308,8 +339,12 @@  discard block
 block discarded – undo
308 339
 	//		$output .= '"interpolationDegree" : 5,';
309 340
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
310 341
 			$output .= '"cartographicDegrees": [';
311
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
312
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
342
+			if ($minitime > strtotime($spotter_item['date'])) {
343
+				$minitime = strtotime($spotter_item['date']);
344
+			}
345
+			if ($maxitime < strtotime($spotter_item['date'])) {
346
+				$maxitime = strtotime($spotter_item['date']);
347
+			}
313 348
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
314 349
 			$output .= $spotter_item['longitude'].', ';
315 350
 			$output .= $spotter_item['latitude'].', ';
@@ -323,7 +358,9 @@  discard block
 block discarded – undo
323 358
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
324 359
 		} else {
325 360
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
326
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
361
+			if ($maxitime < strtotime($spotter_item['date'])) {
362
+				$maxitime = strtotime($spotter_item['date']);
363
+			}
327 364
 			if ($spotter_item['ground_speed'] == 0) {
328 365
 				$output .= $prevlong.', ';
329 366
 				$output .= $prevlat.', ';
Please login to merge, or discard this patch.
require/class.ACARS.php 3 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
 		$this->SI = new SpotterImport($this->db);
17 17
 	}
18 18
 	/**
19
-	* Change IATA to ICAO value for ident
20
-	*
21
-	* @param String $ident ident
22
-	* @return String the icao
23
-	*/
19
+	 * Change IATA to ICAO value for ident
20
+	 *
21
+	 * @param String $ident ident
22
+	 * @return String the icao
23
+	 */
24 24
 	public function ident2icao($ident) {
25 25
 		if (substr($ident,0,2) == 'AF') {
26 26
 			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	/**
39
-	* Deletes all info in the live table
40
-	*
41
-	* @return String success or false
42
-	*
43
-	*/
39
+	 * Deletes all info in the live table
40
+	 *
41
+	 * @return String success or false
42
+	 *
43
+	 */
44 44
 	public function deleteLiveAcarsData()
45 45
 	{
46 46
 		global $globalDBdriver;
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 	/**
63
-	* Deletes all info in the archive table
64
-	*
65
-	* @return String success or false
66
-	*
67
-	*/
63
+	 * Deletes all info in the archive table
64
+	 *
65
+	 * @return String success or false
66
+	 *
67
+	 */
68 68
 	public function deleteArchiveAcarsData()
69 69
 	{
70 70
 		global $globalACARSArchiveKeepMonths, $globalDBdriver;
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 
86 86
 
87 87
 	/**
88
-	* Parse ACARS data
89
-	*
90
-	* @param String ACARS data in acarsdec data
91
-	*
92
-	*/
88
+	 * Parse ACARS data
89
+	 *
90
+	 * @param String ACARS data in acarsdec data
91
+	 *
92
+	 */
93 93
 	public function parse($data) {
94 94
 		global $globalDebug, $globalACARSArchive;
95 95
 		//$Image = new Image($this->db);
@@ -666,11 +666,11 @@  discard block
 block discarded – undo
666 666
 
667 667
 
668 668
 	/**
669
-	* Add ACARS data
670
-	*
671
-	* @param String ACARS data in acarsdec data
672
-	*
673
-	*/
669
+	 * Add ACARS data
670
+	 *
671
+	 * @param String ACARS data in acarsdec data
672
+	 *
673
+	 */
674 674
 	function add($data) {
675 675
 		global $globalDebug, $globalACARSArchive;
676 676
 		$Image = new Image($this->db);
@@ -725,15 +725,15 @@  discard block
 block discarded – undo
725 725
 	}
726 726
 
727 727
 	/**
728
-	* Add Live ACARS data in DB
729
-	*
730
-	* @param String $ident ident
731
-	* @param String $registration Registration of the aircraft
732
-	* @param String $label Label of the ACARS message
733
-	* @param String $block_id Block id of the ACARS message
734
-	* @param String $msg_no Number of the ACARS message
735
-	* @param String $message ACARS message
736
-	*/
728
+	 * Add Live ACARS data in DB
729
+	 *
730
+	 * @param String $ident ident
731
+	 * @param String $registration Registration of the aircraft
732
+	 * @param String $label Label of the ACARS message
733
+	 * @param String $block_id Block id of the ACARS message
734
+	 * @param String $msg_no Number of the ACARS message
735
+	 * @param String $message ACARS message
736
+	 */
737 737
 	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
738 738
 		global $globalDebug;
739 739
 		date_default_timezone_set('UTC');
@@ -771,15 +771,15 @@  discard block
 block discarded – undo
771 771
 	}
772 772
 
773 773
 	/**
774
-	* Add Archive ACARS data in DB
775
-	*
776
-	* @param String $ident ident
777
-	* @param String $registration Registration of the aircraft
778
-	* @param String $label Label of the ACARS message
779
-	* @param String $block_id Block id of the ACARS message
780
-	* @param String $msg_no Number of the ACARS message
781
-	* @param String $message ACARS message
782
-	*/
774
+	 * Add Archive ACARS data in DB
775
+	 *
776
+	 * @param String $ident ident
777
+	 * @param String $registration Registration of the aircraft
778
+	 * @param String $label Label of the ACARS message
779
+	 * @param String $block_id Block id of the ACARS message
780
+	 * @param String $msg_no Number of the ACARS message
781
+	 * @param String $message ACARS message
782
+	 */
783 783
 	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
784 784
 		global $globalDebug;
785 785
 		date_default_timezone_set('UTC');
@@ -813,11 +813,11 @@  discard block
 block discarded – undo
813 813
 	}
814 814
 
815 815
 	/**
816
-	* Get Message title from label from DB
817
-	*
818
-	* @param String $label
819
-	* @return String Return ACARS title
820
-	*/
816
+	 * Get Message title from label from DB
817
+	 *
818
+	 * @param String $label
819
+	 * @return String Return ACARS title
820
+	 */
821 821
 	public function getTitlefromLabel($label) {
822 822
 		$Connection = new Connection($this->db);
823 823
 		$this->db = $Connection->db;
@@ -837,10 +837,10 @@  discard block
 block discarded – undo
837 837
 	}
838 838
 
839 839
 	/**
840
-	* List all Message title & label from DB
841
-	*
842
-	* @return Array Return ACARS data in array
843
-	*/
840
+	 * List all Message title & label from DB
841
+	 *
842
+	 * @return Array Return ACARS data in array
843
+	 */
844 844
 	public function getAllTitleLabel() {
845 845
 		$query = "SELECT * FROM acars_label ORDER BY title";
846 846
 		$query_values = array();
@@ -858,11 +858,11 @@  discard block
 block discarded – undo
858 858
 	}
859 859
 
860 860
 	/**
861
-	* Get Live ACARS data from DB
862
-	*
863
-	* @param String $ident
864
-	* @return Array Return ACARS data in array
865
-	*/
861
+	 * Get Live ACARS data from DB
862
+	 *
863
+	 * @param String $ident
864
+	 * @return Array Return ACARS data in array
865
+	 */
866 866
 	public function getLiveAcarsData($ident) {
867 867
 		$query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC";
868 868
 		$query_values = array(':ident' => $ident);
@@ -880,10 +880,10 @@  discard block
 block discarded – undo
880 880
 	}
881 881
 
882 882
 	/**
883
-	* Get Latest ACARS data from DB
884
-	*
885
-	* @return Array Return ACARS data in array
886
-	*/
883
+	 * Get Latest ACARS data from DB
884
+	 *
885
+	 * @return Array Return ACARS data in array
886
+	 */
887 887
 	public function getLatestAcarsData($limit = '',$label = '') {
888 888
 		global $globalURL, $globalDBdriver;
889 889
 		$Image = new Image($this->db);
@@ -980,10 +980,10 @@  discard block
 block discarded – undo
980 980
 	}
981 981
 
982 982
 	/**
983
-	* Get Archive ACARS data from DB
984
-	*
985
-	* @return Array Return ACARS data in array
986
-	*/
983
+	 * Get Archive ACARS data from DB
984
+	 *
985
+	 * @return Array Return ACARS data in array
986
+	 */
987 987
 	public function getArchiveAcarsData($limit = '',$label = '') {
988 988
 		global $globalURL, $globalDBdriver;
989 989
 		$Image = new Image($this->db);
@@ -1085,13 +1085,13 @@  discard block
 block discarded – undo
1085 1085
 	}
1086 1086
 
1087 1087
 	/**
1088
-	* Add ModeS data to DB
1089
-	*
1090
-	* @param String $ident ident
1091
-	* @param String $registration Registration of the aircraft
1092
-	* @param String $icao
1093
-	* @param String $ICAOTypeCode
1094
-	*/
1088
+	 * Add ModeS data to DB
1089
+	 *
1090
+	 * @param String $ident ident
1091
+	 * @param String $registration Registration of the aircraft
1092
+	 * @param String $icao
1093
+	 * @param String $ICAOTypeCode
1094
+	 */
1095 1095
 	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1096 1096
 		global $globalDebug, $globalDBdriver;
1097 1097
 		$ident = trim($ident);
Please login to merge, or discard this patch.
Spacing   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	* @return String the icao
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25
-		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
25
+		if (substr($ident, 0, 2) == 'AF') {
26
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
28 28
 		} else {
29 29
 			$Spotter = new Spotter($this->db);
30
-			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
30
+			$identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2));
31 31
 			if (isset($identicao[0])) {
32
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
32
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
33 33
 			} else $icao = $ident;
34 34
 		}
35 35
 		return $icao;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 			$sth = $this->db->prepare($query);
55 55
 			$sth->execute();
56
-		} catch(PDOException $e) {
56
+		} catch (PDOException $e) {
57 57
 			return "error";
58 58
 		}
59 59
 		return "success";
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 			$sth = $this->db->prepare($query);
79 79
 			$sth->execute();
80
-		} catch(PDOException $e) {
80
+		} catch (PDOException $e) {
81 81
 			return "error";
82 82
 		}
83 83
 		return "success";
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
 		$ident = '';
103 103
 		$message = '';
104 104
 		$result = array();
105
-		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
106
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
107
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
108
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
105
+		$n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
106
+		if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
107
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
108
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
109 109
 		if ($n != 0) {
110
-			$registration = str_replace('.','',$registration);
111
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
110
+			$registration = str_replace('.', '', $registration);
111
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
112 112
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
113 113
 		} else $message = $data;
114 114
 		$decode = array();
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 				$temp = '';
129 129
 				$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
130 130
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
131
-					$latitude = $la / 10000.0;
132
-					$longitude = $ln / 10000.0;
131
+					$latitude = $la/10000.0;
132
+					$longitude = $ln/10000.0;
133 133
 					if ($lac == 'S') $latitude = '-'.$latitude;
134 134
 					if ($lnc == 'W') $longitude = '-'.$longitude;
135 135
 					// Temp not always available
136 136
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
137
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
138
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
137
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
138
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
139 139
 
140 140
 					//$icao = $Translation->checkTranslation($ident);
141 141
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -147,19 +147,19 @@  discard block
 block discarded – undo
147 147
 				$dhour = '';
148 148
 				$darr = '';
149 149
 				$ahour = '';
150
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
150
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
151 151
 				if ($n == 4 && strlen($darr) == 4) {
152
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
153
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
154
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
152
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
153
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
154
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
155 155
 					//$icao = ACARS->ident2icao($ident);
156 156
 					//$icao = $Translation->checkTranslation($ident);
157 157
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
158 158
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
159 159
 					$found = true;
160 160
 				}
161
-				elseif ($n == 2 || $n  == 4) {
162
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
161
+				elseif ($n == 2 || $n == 4) {
162
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
163 163
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
164 164
 					//$icao = ACARS->ident2icao($ident);
165 165
 					//$icao = $Translation->checkTranslation($ident);
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 				$ahour = '';
218 218
 				$aair = '';
219 219
 				$apiste = '';
220
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
220
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste);
221 221
 				if ($n > 8) {
222
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
224
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
222
+					if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
224
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
225 225
 					$icao = trim($aident);
226 226
 
227 227
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
247 247
 					$las = $las.'.'.$lass;
248 248
 					$lns = $lns.'.'.$lns;
249
-					$latitude = $las / 1000.0;
250
-					$longitude = $lns / 1000.0;
249
+					$latitude = $las/1000.0;
250
+					$longitude = $lns/1000.0;
251 251
 					if ($lac == 'S') $latitude = '-'.$latitude;
252 252
 					if ($lnc == 'W') $longitude = '-'.$longitude;
253 253
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -342,17 +342,17 @@  discard block
 block discarded – undo
342 342
 				$alt = '';
343 343
 				$fuel = '';
344 344
 				$speed = '';
345
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
345
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
346 346
 				if ($n == 9) {
347 347
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
348 348
 					$icao = trim($aident);
349 349
 					$decode['icao'] = $icao;
350
-					$latitude = $las / 100.0;
351
-					$longitude = $lns / 100.0;
350
+					$latitude = $las/100.0;
351
+					$longitude = $lns/100.0;
352 352
 					if ($lac == 'S') $latitude = '-'.$latitude;
353 353
 					if ($lnc == 'W') $longitude = '-'.$longitude;
354 354
 
355
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
355
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
356 356
 					$found = true;
357 357
 				}
358 358
 			}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 					if ($lac == 'S') $latitude = '-'.$latitude;
372 372
 					if ($lnc == 'W') $longitude = '-'.$longitude;
373 373
 
374
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
374
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
375 375
 					$found = true;
376 376
 				}
377 377
 			}
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 				$dair = '';
405 405
 				$darr = '';
406 406
 				$aident = '';
407
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
407
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
408 408
 				if ($n == 8) {
409 409
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
410 410
 					$icao = trim($aident);
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 				*/
438 438
 				$dair = '';
439 439
 				$darr = '';
440
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
440
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
441 441
 				if ($n == 3) {
442 442
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
443 443
 					//$icao = $Translation->checkTranslation($ident);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 				*/
454 454
 				$dair = '';
455 455
 				$darr = '';
456
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
456
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
457 457
 				if ($n == 3) {
458 458
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459 459
 					//$icao = $Translation->checkTranslation($ident);
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 				}
465 465
 			}
466 466
 			if (!$found) {
467
-				$n = sscanf($message,'MET01%4c',$airport);
467
+				$n = sscanf($message, 'MET01%4c', $airport);
468 468
 				if ($n == 1) {
469 469
 					if ($globalDebug) echo 'airport name : '.$airport;
470 470
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -473,241 +473,241 @@  discard block
 block discarded – undo
473 473
 			}
474 474
 
475 475
 			if ($label == 'H1') {
476
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
477
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
476
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
477
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
478 478
 				}
479
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
480
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
479
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
480
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
481 481
 				}
482
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
483
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
482
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
483
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
484 484
 				}
485
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
486
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
485
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
486
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
487 487
 				}
488
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
489
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
488
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
489
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
490 490
 				}
491
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
492
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
491
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
492
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
493 493
 				}
494
-				elseif (preg_match(':^#M1AAEP:',$message)) {
495
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
494
+				elseif (preg_match(':^#M1AAEP:', $message)) {
495
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
496 496
 				}
497
-				elseif (preg_match(':^#M2APWD:',$message)) {
498
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
497
+				elseif (preg_match(':^#M2APWD:', $message)) {
498
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
499 499
 				}
500
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
501
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
500
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
501
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
502 502
 				}
503
-				elseif (preg_match(':^#CF:',$message)) {
504
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
503
+				elseif (preg_match(':^#CF:', $message)) {
504
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
505 505
 				}
506
-				elseif (preg_match(':^#DF:',$message)) {
507
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
506
+				elseif (preg_match(':^#DF:', $message)) {
507
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
508 508
 				}
509
-				elseif (preg_match(':^#EC:',$message)) {
510
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
509
+				elseif (preg_match(':^#EC:', $message)) {
510
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
511 511
 				}
512
-				elseif (preg_match(':^#EI:',$message)) {
513
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
512
+				elseif (preg_match(':^#EI:', $message)) {
513
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
514 514
 				}
515
-				elseif (preg_match(':^#H1:',$message)) {
516
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
515
+				elseif (preg_match(':^#H1:', $message)) {
516
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
517 517
 				}
518
-				elseif (preg_match(':^#H2:',$message)) {
519
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
518
+				elseif (preg_match(':^#H2:', $message)) {
519
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
520 520
 				}
521
-				elseif (preg_match(':^#HD:',$message)) {
522
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
521
+				elseif (preg_match(':^#HD:', $message)) {
522
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
523 523
 				}
524
-				elseif (preg_match(':^#M1:',$message)) {
525
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
524
+				elseif (preg_match(':^#M1:', $message)) {
525
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
526 526
 				}
527
-				elseif (preg_match(':^#M2:',$message)) {
528
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
527
+				elseif (preg_match(':^#M2:', $message)) {
528
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
529 529
 				}
530
-				elseif (preg_match(':^#M3:',$message)) {
531
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
530
+				elseif (preg_match(':^#M3:', $message)) {
531
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
532 532
 				}
533
-				elseif (preg_match(':^#MD:',$message)) {
534
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
533
+				elseif (preg_match(':^#MD:', $message)) {
534
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
535 535
 				}
536
-				elseif (preg_match(':^#PS:',$message)) {
537
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
536
+				elseif (preg_match(':^#PS:', $message)) {
537
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
538 538
 				}
539
-				elseif (preg_match(':^#S1:',$message)) {
540
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
539
+				elseif (preg_match(':^#S1:', $message)) {
540
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
541 541
 				}
542
-				elseif (preg_match(':^#S2:',$message)) {
543
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
542
+				elseif (preg_match(':^#S2:', $message)) {
543
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
544 544
 				}
545
-				elseif (preg_match(':^#SD:',$message)) {
546
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
545
+				elseif (preg_match(':^#SD:', $message)) {
546
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
547 547
 				}
548
-				elseif (preg_match(':^#T[0-8]:',$message)) {
549
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
548
+				elseif (preg_match(':^#T[0-8]:', $message)) {
549
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
550 550
 				}
551
-				elseif (preg_match(':^#WO:',$message)) {
552
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
551
+				elseif (preg_match(':^#WO:', $message)) {
552
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
553 553
 				}
554
-				elseif (preg_match(':^#A1:',$message)) {
555
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
554
+				elseif (preg_match(':^#A1:', $message)) {
555
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
556 556
 				}
557
-				elseif (preg_match(':^#A3:',$message)) {
558
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
557
+				elseif (preg_match(':^#A3:', $message)) {
558
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
559 559
 				}
560
-				elseif (preg_match(':^#A4:',$message)) {
561
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
560
+				elseif (preg_match(':^#A4:', $message)) {
561
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
562 562
 				}
563
-				elseif (preg_match(':^#A6:',$message)) {
564
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
563
+				elseif (preg_match(':^#A6:', $message)) {
564
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
565 565
 				}
566
-				elseif (preg_match(':^#A8:',$message)) {
567
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
566
+				elseif (preg_match(':^#A8:', $message)) {
567
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
568 568
 				}
569
-				elseif (preg_match(':^#A9:',$message)) {
570
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
569
+				elseif (preg_match(':^#A9:', $message)) {
570
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
571 571
 				}
572
-				elseif (preg_match(':^#A0:',$message)) {
573
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
572
+				elseif (preg_match(':^#A0:', $message)) {
573
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
574 574
 				}
575
-				elseif (preg_match(':^#AA:',$message)) {
576
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
575
+				elseif (preg_match(':^#AA:', $message)) {
576
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
577 577
 				}
578
-				elseif (preg_match(':^#AB:',$message)) {
579
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
578
+				elseif (preg_match(':^#AB:', $message)) {
579
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
580 580
 				}
581
-				elseif (preg_match(':^#AC:',$message)) {
582
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
581
+				elseif (preg_match(':^#AC:', $message)) {
582
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
583 583
 				}
584
-				elseif (preg_match(':^#AD:',$message)) {
585
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
584
+				elseif (preg_match(':^#AD:', $message)) {
585
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
586 586
 				}
587
-				elseif (preg_match(':^#AF:',$message)) {
588
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
587
+				elseif (preg_match(':^#AF:', $message)) {
588
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
589 589
 				}
590
-				elseif (preg_match(':^#B1:',$message)) {
591
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
590
+				elseif (preg_match(':^#B1:', $message)) {
591
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
592 592
 				}
593
-				elseif (preg_match(':^#B2:',$message)) {
594
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
593
+				elseif (preg_match(':^#B2:', $message)) {
594
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
595 595
 				}
596
-				elseif (preg_match(':^#B3:',$message)) {
597
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
596
+				elseif (preg_match(':^#B3:', $message)) {
597
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
598 598
 				}
599
-				elseif (preg_match(':^#B4:',$message)) {
600
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
599
+				elseif (preg_match(':^#B4:', $message)) {
600
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
601 601
 				}
602
-				elseif (preg_match(':^#B6:',$message)) {
603
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
602
+				elseif (preg_match(':^#B6:', $message)) {
603
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
604 604
 				}
605
-				elseif (preg_match(':^#B8:',$message)) {
606
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
605
+				elseif (preg_match(':^#B8:', $message)) {
606
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
607 607
 				}
608
-				elseif (preg_match(':^#B9:',$message)) {
609
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
608
+				elseif (preg_match(':^#B9:', $message)) {
609
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
610 610
 				}
611
-				elseif (preg_match(':^#B0:',$message)) {
612
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
611
+				elseif (preg_match(':^#B0:', $message)) {
612
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
613 613
 				}
614
-				elseif (preg_match(':^#BA:',$message)) {
615
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
614
+				elseif (preg_match(':^#BA:', $message)) {
615
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
616 616
 				}
617
-				elseif (preg_match(':^#BB:',$message)) {
618
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
617
+				elseif (preg_match(':^#BB:', $message)) {
618
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
619 619
 				}
620
-				elseif (preg_match(':^#BC:',$message)) {
621
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
620
+				elseif (preg_match(':^#BC:', $message)) {
621
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
622 622
 				}
623
-				elseif (preg_match(':^#BD:',$message)) {
624
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
623
+				elseif (preg_match(':^#BD:', $message)) {
624
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
625 625
 				}
626
-				elseif (preg_match(':^#BE:',$message)) {
627
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
626
+				elseif (preg_match(':^#BE:', $message)) {
627
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
628 628
 				}
629
-				elseif (preg_match(':^#BF:',$message)) {
630
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
629
+				elseif (preg_match(':^#BF:', $message)) {
630
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
631 631
 				}
632
-				elseif (preg_match(':^#H3:',$message)) {
633
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
632
+				elseif (preg_match(':^#H3:', $message)) {
633
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
634 634
 				}
635 635
 			}
636 636
 			if ($label == '10') {
637
-				if (preg_match(':^DTO01:',$message)) {
638
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
637
+				if (preg_match(':^DTO01:', $message)) {
638
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
639 639
 				}
640
-				elseif (preg_match(':^AIS01:',$message)) {
641
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
640
+				elseif (preg_match(':^AIS01:', $message)) {
641
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
642 642
 				}
643
-				elseif (preg_match(':^FTX01:',$message)) {
644
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
643
+				elseif (preg_match(':^FTX01:', $message)) {
644
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
645 645
 				}
646
-				elseif (preg_match(':^FPL01:',$message)) {
647
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
646
+				elseif (preg_match(':^FPL01:', $message)) {
647
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
648 648
 				}
649
-				elseif (preg_match(':^WAB01:',$message)) {
650
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
649
+				elseif (preg_match(':^WAB01:', $message)) {
650
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
651 651
 				}
652
-				elseif (preg_match(':^MET01:',$message)) {
653
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
652
+				elseif (preg_match(':^MET01:', $message)) {
653
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
654 654
 				}
655
-				elseif (preg_match(':^WAB02:',$message)) {
656
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
655
+				elseif (preg_match(':^WAB02:', $message)) {
656
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
657 657
 				}
658 658
 			}
659 659
 			if ($label == '15') {
660
-				if (preg_match(':^FST01:',$message)) {
661
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
660
+				if (preg_match(':^FST01:', $message)) {
661
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
662 662
 				}
663 663
 			}
664 664
 			if (!$found && $label == 'SA') {
665
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
665
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
666 666
 				if ($n == 4) {
667 667
 					$vsta = array('Version' => $version);
668 668
 					if ($state == 'E') {
669
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
669
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
670 670
 					}
671 671
 					elseif ($state == 'L') {
672
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
672
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
673 673
 					}
674 674
 					else {
675
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
675
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
676 676
 					}
677 677
 					if ($type == 'V') {
678
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
678
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
679 679
 					}
680 680
 					elseif ($type == 'S') {
681
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
681
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
682 682
 					}
683 683
 					elseif ($type == 'H') {
684
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
684
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
685 685
 					}
686 686
 					elseif ($type == 'G') {
687
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
687
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
688 688
 					}
689 689
 					elseif ($type == 'C') {
690
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
690
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
691 691
 					}
692 692
 					elseif ($type == '2') {
693
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
693
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
694 694
 					}
695 695
 					elseif ($type == 'X') {
696
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
696
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
697 697
 					}
698 698
 					elseif ($type == 'I') {
699
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
699
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
700 700
 					}
701 701
 					else {
702
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
702
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
703 703
 					}
704
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
705
-					$decode = array_merge($vsta,$decode);
704
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
705
+					$decode = array_merge($vsta, $decode);
706 706
 				}
707 707
 			}
708 708
 
709 709
 			$title = $this->getTitlefromLabel($label);
710
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
710
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
711 711
 
712 712
 			/*
713 713
 			// Business jets always use GS0001
@@ -740,13 +740,13 @@  discard block
 block discarded – undo
740 740
 		$message = $this->parse($data);
741 741
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
742 742
 		
743
-			$ident = (string)$message['ident'];
743
+			$ident = (string) $message['ident'];
744 744
 			$label = $message['label'];
745 745
 			$block_id = $message['block_id'];
746 746
 			$msg_no = $message['msg_no'];
747 747
 			$msg = $message['message'];
748 748
 			$decode = $message['decode'];
749
-			$registration = (string)$message['registration'];
749
+			$registration = (string) $message['registration'];
750 750
 		
751 751
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
752 752
 			else $latitude = '';
@@ -763,23 +763,23 @@  discard block
 block discarded – undo
763 763
 			}
764 764
 		
765 765
 			// Business jets always use GS0001
766
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
766
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
767 767
 			if ($globalDebug && isset($info) && $info != '') echo $info;
768 768
 
769 769
 			if (count($decode) > 0) $decode_json = json_encode($decode);
770 770
 			else $decode_json = '';
771 771
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
772
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
772
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
773 773
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
774
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
774
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
775 775
 			}
776 776
 
777
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
778
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
779
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
777
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
778
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
779
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
780 780
 
781 781
 			if ($globalDebug && count($decode) > 0) {
782
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
782
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
783 783
 			}
784 784
 		}
785 785
 	}
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 	* @param String $msg_no Number of the ACARS message
795 795
 	* @param String $message ACARS message
796 796
 	*/
797
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
797
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
798 798
 		global $globalDebug;
799 799
 		date_default_timezone_set('UTC');
800 800
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -803,22 +803,22 @@  discard block
 block discarded – undo
803 803
 
804 804
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
805 805
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
806
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
806
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
807 807
 			try {
808 808
 				$stht = $this->db->prepare($query_test);
809 809
 				$stht->execute($query_test_values);
810
-			} catch(PDOException $e) {
810
+			} catch (PDOException $e) {
811 811
 				return "error : ".$e->getMessage();
812 812
 			}
813 813
 			if ($stht->fetchColumn() == 0) {
814 814
 				if ($globalDebug) echo "Add Live ACARS data...";
815 815
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
816
-				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
816
+				$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s"));
817 817
 				try {
818 818
 
819 819
 					$sth = $this->db->prepare($query);
820 820
 					$sth->execute($query_values);
821
-				} catch(PDOException $e) {
821
+				} catch (PDOException $e) {
822 822
 					return "error : ".$e->getMessage();
823 823
 				}
824 824
 			} else {
@@ -840,10 +840,10 @@  discard block
 block discarded – undo
840 840
 	* @param String $msg_no Number of the ACARS message
841 841
 	* @param String $message ACARS message
842 842
 	*/
843
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
843
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
844 844
 		global $globalDebug;
845 845
 		date_default_timezone_set('UTC');
846
-		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) {
846
+		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) {
847 847
 			/*
848 848
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
849 849
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -859,12 +859,12 @@  discard block
 block discarded – undo
859 859
 			*/
860 860
 			if ($globalDebug) echo "Add Live ACARS data...";
861 861
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
862
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
862
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
863 863
 			try {
864 864
 
865 865
 				$sth = $this->db->prepare($query);
866 866
 				$sth->execute($query_values);
867
-			} catch(PDOException $e) {
867
+			} catch (PDOException $e) {
868 868
 				return "error : ".$e->getMessage();
869 869
 			}
870 870
 //    	    }
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 
888 888
 			$sth = $this->db->prepare($query);
889 889
 			$sth->execute($query_values);
890
-		} catch(PDOException $e) {
890
+		} catch (PDOException $e) {
891 891
 			echo "error : ".$e->getMessage();
892 892
 			die;
893 893
 		}
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 
909 909
 			$sth = $this->db->prepare($query);
910 910
 			$sth->execute($query_values);
911
-		} catch(PDOException $e) {
911
+		} catch (PDOException $e) {
912 912
 			echo "error : ".$e->getMessage();
913 913
 			die;
914 914
 		}
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 
931 931
 			$sth = $this->db->prepare($query);
932 932
 			$sth->execute($query_values);
933
-		} catch(PDOException $e) {
933
+		} catch (PDOException $e) {
934 934
 			echo "error : ".$e->getMessage();
935 935
 			die;
936 936
 		}
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 	*
945 945
 	* @return Array Return ACARS data in array
946 946
 	*/
947
-	public function getLatestAcarsData($limit = '',$label = '') {
947
+	public function getLatestAcarsData($limit = '', $label = '') {
948 948
 		global $globalURL, $globalDBdriver;
949 949
 		$Image = new Image($this->db);
950 950
 		$Spotter = new Spotter($this->db);
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
 		{
957 957
 			$limit_array = explode(",", $limit);
958 958
 
959
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
960
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
959
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
960
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
961 961
 
962 962
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
963 963
 			{
@@ -979,48 +979,48 @@  discard block
 block discarded – undo
979 979
 
980 980
 			$sth = $this->db->prepare($query);
981 981
 			$sth->execute($query_values);
982
-		} catch(PDOException $e) {
982
+		} catch (PDOException $e) {
983 983
 			return "error : ".$e->getMessage();
984 984
 		}
985 985
 		$i = 0;
986 986
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
987 987
 			$data = array();
988 988
 			if ($row['registration'] != '') {
989
-				$row['registration'] = str_replace('.','',$row['registration']);
989
+				$row['registration'] = str_replace('.', '', $row['registration']);
990 990
 				$image_array = $Image->getSpotterImage($row['registration']);
991
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
992
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
991
+				if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
992
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
993
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
994 994
 			if ($row['registration'] == '') $row['registration'] = 'NA';
995 995
 			if ($row['ident'] == '') $row['ident'] = 'NA';
996
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
996
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
997 997
 			if (isset($identicao[0])) {
998
-				if (substr($row['ident'],0,2) == 'AF') {
999
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1000
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1001
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
998
+				if (substr($row['ident'], 0, 2) == 'AF') {
999
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1000
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1001
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1002 1002
 
1003
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1003
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1004 1004
 			} else $icao = $row['ident'];
1005
-			$icao = $Translation->checkTranslation($icao,false);
1005
+			$icao = $Translation->checkTranslation($icao, false);
1006 1006
 
1007
-			$decode = json_decode($row['decode'],true);
1007
+			$decode = json_decode($row['decode'], true);
1008 1008
 			$found = false;
1009
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1009
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1010 1010
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1011 1011
 				if (isset($airport_info[0]['icao'])) {
1012 1012
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1013 1013
 					$found = true;
1014 1014
 				}
1015 1015
 			}
1016
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1016
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1017 1017
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1018 1018
 				if (isset($airport_info[0]['icao'])) {
1019 1019
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1020 1020
 					$found = true;
1021 1021
 				}
1022 1022
 			}
1023
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1023
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1024 1024
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1025 1025
 				if (isset($airport_info[0]['icao'])) {
1026 1026
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 				}
1029 1029
 			}
1030 1030
 			if ($found) $row['decode'] = json_encode($decode);
1031
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1031
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1032 1032
 			$result[] = $data;
1033 1033
 			$i++;
1034 1034
 		}
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 	*
1045 1045
 	* @return Array Return ACARS data in array
1046 1046
 	*/
1047
-	public function getArchiveAcarsData($limit = '',$label = '') {
1047
+	public function getArchiveAcarsData($limit = '', $label = '') {
1048 1048
 		global $globalURL, $globalDBdriver;
1049 1049
 		$Image = new Image($this->db);
1050 1050
 		$Spotter = new Spotter($this->db);
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
 		{
1057 1057
 			$limit_array = explode(",", $limit);
1058 1058
 
1059
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1060
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1059
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1060
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1061 1061
 
1062 1062
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1063 1063
 			{
@@ -1087,45 +1087,45 @@  discard block
 block discarded – undo
1087 1087
 
1088 1088
 			$sth = $this->db->prepare($query);
1089 1089
 			$sth->execute($query_values);
1090
-		} catch(PDOException $e) {
1090
+		} catch (PDOException $e) {
1091 1091
 			return "error : ".$e->getMessage();
1092 1092
 		}
1093
-		$i=0;
1093
+		$i = 0;
1094 1094
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1095 1095
 			$data = array();
1096 1096
 			if ($row['registration'] != '') {
1097
-				$row['registration'] = str_replace('.','',$row['registration']);
1097
+				$row['registration'] = str_replace('.', '', $row['registration']);
1098 1098
 				$image_array = $Image->getSpotterImage($row['registration']);
1099
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1100
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1101
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1099
+				if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
1100
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1101
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1102 1102
 			$icao = '';
1103 1103
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1104 1104
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1105
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1105
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1106 1106
 			if (isset($identicao[0])) {
1107
-				if (substr($row['ident'],0,2) == 'AF') {
1108
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1109
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1110
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1111
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1107
+				if (substr($row['ident'], 0, 2) == 'AF') {
1108
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1109
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1110
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1111
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1112 1112
 			} else $icao = $row['ident'];
1113 1113
 			$icao = $Translation->checkTranslation($icao);
1114 1114
 
1115 1115
 
1116
-			$decode = json_decode($row['decode'],true);
1116
+			$decode = json_decode($row['decode'], true);
1117 1117
 			$found = false;
1118
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1118
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1119 1119
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1120 1120
 				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1121 1121
 				$found = true;
1122 1122
 			}
1123
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1123
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1124 1124
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1125 1125
 				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1126 1126
 				$found = true;
1127 1127
 			}
1128
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1128
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1129 1129
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1130 1130
 				if (isset($airport_info[0]['icao'])) {
1131 1131
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 			}
1135 1135
 			if ($found) $row['decode'] = json_encode($decode);
1136 1136
 
1137
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1137
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1138 1138
 			$result[] = $data;
1139 1139
 			$i++;
1140 1140
 		}
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 	* @param String $icao
1153 1153
 	* @param String $ICAOTypeCode
1154 1154
 	*/
1155
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1155
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1156 1156
 		global $globalDebug, $globalDBdriver;
1157 1157
 		$ident = trim($ident);
1158 1158
 		$Translation = new Translation($this->db);
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 			return '';
1167 1167
 		}
1168 1168
 
1169
-		$registration = str_replace('.','',$registration);
1169
+		$registration = str_replace('.', '', $registration);
1170 1170
 		$ident = $Translation->ident2icao($ident);
1171 1171
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1172 1172
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 
1177 1177
 			$sthsi = $this->db->prepare($querysi);
1178 1178
 			$sthsi->execute($querysi_values);
1179
-		} catch(PDOException $e) {
1179
+		} catch (PDOException $e) {
1180 1180
 			if ($globalDebug) echo $e->getMessage();
1181 1181
 			return "error : ".$e->getMessage();
1182 1182
 		}
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
 			$Translation = new Translation($this->db);
1188 1188
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1189 1189
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1190
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1191
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1190
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1191
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1192 1192
 		} else {
1193 1193
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1194 1194
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 				try {
1197 1197
 					$sth = $this->db->prepare($query);
1198 1198
 					$sth->execute($query_values);
1199
-				} catch(PDOException $e) {
1199
+				} catch (PDOException $e) {
1200 1200
 					if ($globalDebug) echo $e->getMessage();
1201 1201
 					return "error : ".$e->getMessage();
1202 1202
 				}
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 				$sth->closeCursor();
1205 1205
 				if (isset($result['modes'])) $hex = $result['modes'];
1206 1206
 				else $hex = '';
1207
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1207
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1208 1208
 				$this->SI->add($SI_data);
1209 1209
 			}
1210 1210
 		}
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 
1217 1217
 			$sth = $this->db->prepare($query);
1218 1218
 			$sth->execute($query_values);
1219
-		} catch(PDOException $e) {
1219
+		} catch (PDOException $e) {
1220 1220
 			if ($globalDebug) echo $e->getMessage();
1221 1221
 			return "error : ".$e->getMessage();
1222 1222
 		}
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1228 1228
 			else $ModeS = '';
1229 1229
 			if ($ModeS == '') {
1230
-				$id = explode('-',$result['flightaware_id']);
1230
+				$id = explode('-', $result['flightaware_id']);
1231 1231
 				$ModeS = $id[0];
1232 1232
 			}
1233 1233
 			if ($ModeS != '') {
@@ -1238,21 +1238,21 @@  discard block
 block discarded – undo
1238 1238
 
1239 1239
 					$sthc = $this->db->prepare($queryc);
1240 1240
 					$sthc->execute($queryc_values);
1241
-				} catch(PDOException $e) {
1241
+				} catch (PDOException $e) {
1242 1242
 					if ($globalDebug) echo $e->getMessage();
1243 1243
 					return "error : ".$e->getMessage();
1244 1244
 				}
1245 1245
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1246 1246
 				$sthc->closeCursor();
1247
-				if (count($row) ==  0) {
1247
+				if (count($row) == 0) {
1248 1248
 					if ($globalDebug) echo " Add to ModeS table - ";
1249 1249
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1250
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1250
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1251 1251
 					try {
1252 1252
 
1253 1253
 						$sthi = $this->db->prepare($queryi);
1254 1254
 						$sthi->execute($queryi_values);
1255
-					} catch(PDOException $e) {
1255
+					} catch (PDOException $e) {
1256 1256
 						if ($globalDebug) echo $e->getMessage();
1257 1257
 						return "error : ".$e->getMessage();
1258 1258
 					}
@@ -1260,16 +1260,16 @@  discard block
 block discarded – undo
1260 1260
 					if ($globalDebug) echo " Update ModeS table - ";
1261 1261
 					if ($ICAOTypeCode != '') {
1262 1262
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1263
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1263
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1264 1264
 					} else {
1265 1265
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1266
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1266
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1267 1267
 					}
1268 1268
 					try {
1269 1269
 
1270 1270
 						$sthi = $this->db->prepare($queryi);
1271 1271
 						$sthi->execute($queryi_values);
1272
-					} catch(PDOException $e) {
1272
+					} catch (PDOException $e) {
1273 1273
 						if ($globalDebug) echo $e->getMessage();
1274 1274
 						return "error : ".$e->getMessage();
1275 1275
 					}
@@ -1307,13 +1307,13 @@  discard block
 block discarded – undo
1307 1307
 					elseif ($globalDBdriver == 'pgsql') {
1308 1308
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1309 1309
 					}
1310
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1310
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1311 1311
 				}
1312 1312
 				try {
1313 1313
 
1314 1314
 					$sthi = $this->db->prepare($queryi);
1315 1315
 					$sthi->execute($queryi_values);
1316
-				} catch(PDOException $e) {
1316
+				} catch (PDOException $e) {
1317 1317
 					if ($globalDebug) echo $e->getMessage();
1318 1318
 					return "error : ".$e->getMessage();
1319 1319
 				}
Please login to merge, or discard this patch.
Braces   +409 added lines, -261 removed lines patch added patch discarded remove patch
@@ -23,14 +23,19 @@  discard block
 block discarded – undo
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25 25
 		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
26
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
27
+				$icao = $ident;
28
+			} else {
29
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
30
+			}
28 31
 		} else {
29 32
 			$Spotter = new Spotter($this->db);
30 33
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
31 34
 			if (isset($identicao[0])) {
32 35
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
33
-			} else $icao = $ident;
36
+			} else {
37
+				$icao = $ident;
38
+			}
34 39
 		}
35 40
 		return $icao;
36 41
 	}
@@ -103,14 +108,24 @@  discard block
 block discarded – undo
103 108
 		$message = '';
104 109
 		$result = array();
105 110
 		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
106
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
107
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
108
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
111
+		if ($n == 0) {
112
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
113
+		}
114
+		if ($n == 0) {
115
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
116
+		}
117
+		if ($n == 0) {
118
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
119
+		}
109 120
 		if ($n != 0) {
110 121
 			$registration = str_replace('.','',$registration);
111 122
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
112
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
113
-		} else $message = $data;
123
+			if ($globalDebug) {
124
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
125
+			}
126
+		} else {
127
+			$message = $data;
128
+		}
114 129
 		$decode = array();
115 130
 		$found = false;
116 131
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -130,12 +145,21 @@  discard block
 block discarded – undo
130 145
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
131 146
 					$latitude = $la / 10000.0;
132 147
 					$longitude = $ln / 10000.0;
133
-					if ($lac == 'S') $latitude = '-'.$latitude;
134
-					if ($lnc == 'W') $longitude = '-'.$longitude;
148
+					if ($lac == 'S') {
149
+						$latitude = '-'.$latitude;
150
+					}
151
+					if ($lnc == 'W') {
152
+						$longitude = '-'.$longitude;
153
+					}
135 154
 					// Temp not always available
136
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
137
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
138
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
155
+					if ($globalDebug) {
156
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
157
+					}
158
+					if ($temp == '') {
159
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
160
+					} else {
161
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
162
+					}
139 163
 
140 164
 					//$icao = $Translation->checkTranslation($ident);
141 165
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -149,25 +173,35 @@  discard block
 block discarded – undo
149 173
 				$ahour = '';
150 174
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
151 175
 				if ($n == 4 && strlen($darr) == 4) {
152
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
153
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
154
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
176
+					if ($dhour != '') {
177
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
178
+					}
179
+					if ($ahour != '') {
180
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
181
+					}
182
+					if ($globalDebug) {
183
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
184
+					}
155 185
 					//$icao = ACARS->ident2icao($ident);
156 186
 					//$icao = $Translation->checkTranslation($ident);
157 187
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
158 188
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
159 189
 					$found = true;
160
-				}
161
-				elseif ($n == 2 || $n  == 4) {
162
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
163
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
190
+				} elseif ($n == 2 || $n  == 4) {
191
+					if ($dhour != '') {
192
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
193
+					}
194
+					if ($globalDebug) {
195
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
196
+					}
164 197
 					//$icao = ACARS->ident2icao($ident);
165 198
 					//$icao = $Translation->checkTranslation($ident);
166 199
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
167 200
 					$found = true;
168
-				}
169
-				elseif ($n == 1) {
170
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
201
+				} elseif ($n == 1) {
202
+					if ($globalDebug) {
203
+						echo 'airport arrival : '.$darr."\n";
204
+					}
171 205
 					//$icao = ACARS->ident2icao($ident);
172 206
 					//$icao = $Translation->checkTranslation($ident);
173 207
 					$decode = array('Arrival airport' => $darr);
@@ -185,7 +219,9 @@  discard block
 block discarded – undo
185 219
 				$darr = '';
186 220
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
187 221
 				if ($n == 4) {
188
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
222
+					if ($globalDebug) {
223
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
224
+					}
189 225
 					//$icao = ACARS->ident2icao($ident);
190 226
 					//$icao = $Translation->checkTranslation($ident);
191 227
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -219,14 +255,23 @@  discard block
 block discarded – undo
219 255
 				$apiste = '';
220 256
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
221 257
 				if ($n > 8) {
222
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
224
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
258
+					if ($globalDebug) {
259
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
260
+					}
261
+					if ($dhour != '') {
262
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
263
+					}
264
+					if ($ahour != '') {
265
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
266
+					}
225 267
 					$icao = trim($aident);
226 268
 
227 269
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
228
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
229
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
270
+					if ($ahour == '') {
271
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
272
+					} else {
273
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
274
+					}
230 275
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
231 276
 					$decode['icao'] = $icao;
232 277
 					$found = true;
@@ -248,9 +293,15 @@  discard block
 block discarded – undo
248 293
 					$lns = $lns.'.'.$lns;
249 294
 					$latitude = $las / 1000.0;
250 295
 					$longitude = $lns / 1000.0;
251
-					if ($lac == 'S') $latitude = '-'.$latitude;
252
-					if ($lnc == 'W') $longitude = '-'.$longitude;
253
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
296
+					if ($lac == 'S') {
297
+						$latitude = '-'.$latitude;
298
+					}
299
+					if ($lnc == 'W') {
300
+						$longitude = '-'.$longitude;
301
+					}
302
+					if ($globalDebug) {
303
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
304
+					}
254 305
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
255 306
 					$found = true;
256 307
 				}
@@ -268,7 +319,9 @@  discard block
 block discarded – undo
268 319
 				$darr = '';
269 320
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
270 321
 				if ($n == 4) {
271
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
322
+					if ($globalDebug) {
323
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
324
+					}
272 325
 					//$icao = $Translation->checkTranslation($ident);
273 326
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
274 327
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -281,7 +334,9 @@  discard block
 block discarded – undo
281 334
 				$darr = '';
282 335
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
283 336
 				if ($n == 4) {
284
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
337
+					if ($globalDebug) {
338
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
339
+					}
285 340
 					//$icao = $Translation->checkTranslation($ident);
286 341
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
287 342
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -294,7 +349,9 @@  discard block
 block discarded – undo
294 349
 				$darr = '';
295 350
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
296 351
 				if ($n == 2) {
297
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
352
+					if ($globalDebug) {
353
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
354
+					}
298 355
 					//$icao = $Translation->checkTranslation($ident);
299 356
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
300 357
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -308,7 +365,9 @@  discard block
 block discarded – undo
308 365
 				$darr = '';
309 366
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
310 367
 				if ($n == 6) {
311
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
368
+					if ($globalDebug) {
369
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
370
+					}
312 371
 					//$icao = $Translation->checkTranslation($ident);
313 372
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
314 373
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -321,7 +380,9 @@  discard block
 block discarded – undo
321 380
 				$darr = '';
322 381
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
323 382
 				if ($n == 7) {
324
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
383
+					if ($globalDebug) {
384
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
385
+					}
325 386
 					//$icao = $Translation->checkTranslation($ident);
326 387
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
327 388
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -349,8 +410,12 @@  discard block
 block discarded – undo
349 410
 					$decode['icao'] = $icao;
350 411
 					$latitude = $las / 100.0;
351 412
 					$longitude = $lns / 100.0;
352
-					if ($lac == 'S') $latitude = '-'.$latitude;
353
-					if ($lnc == 'W') $longitude = '-'.$longitude;
413
+					if ($lac == 'S') {
414
+						$latitude = '-'.$latitude;
415
+					}
416
+					if ($lnc == 'W') {
417
+						$longitude = '-'.$longitude;
418
+					}
354 419
 
355 420
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
356 421
 					$found = true;
@@ -368,8 +433,12 @@  discard block
 block discarded – undo
368 433
 				if ($n == 4) {
369 434
 					$latitude = $las;
370 435
 					$longitude = $lns;
371
-					if ($lac == 'S') $latitude = '-'.$latitude;
372
-					if ($lnc == 'W') $longitude = '-'.$longitude;
436
+					if ($lac == 'S') {
437
+						$latitude = '-'.$latitude;
438
+					}
439
+					if ($lnc == 'W') {
440
+						$longitude = '-'.$longitude;
441
+					}
373 442
 
374 443
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
375 444
 					$found = true;
@@ -385,7 +454,9 @@  discard block
 block discarded – undo
385 454
 				$darr = '';
386 455
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
387 456
 				if ($n == 5) {
388
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
457
+					if ($globalDebug) {
458
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459
+					}
389 460
 					//$icao = $Translation->checkTranslation($ident);
390 461
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
391 462
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -406,7 +477,9 @@  discard block
 block discarded – undo
406 477
 				$aident = '';
407 478
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
408 479
 				if ($n == 8) {
409
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
480
+					if ($globalDebug) {
481
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
482
+					}
410 483
 					$icao = trim($aident);
411 484
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
412 485
 					$decode['icao'] = $icao;
@@ -423,7 +496,9 @@  discard block
 block discarded – undo
423 496
 				$darr = '';
424 497
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
425 498
 				if ($n == 5) {
426
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
499
+					if ($globalDebug) {
500
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
501
+					}
427 502
 					//$icao = $Translation->checkTranslation($ident);
428 503
 
429 504
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -439,7 +514,9 @@  discard block
 block discarded – undo
439 514
 				$darr = '';
440 515
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
441 516
 				if ($n == 3) {
442
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
517
+					if ($globalDebug) {
518
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
519
+					}
443 520
 					//$icao = $Translation->checkTranslation($ident);
444 521
 
445 522
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -455,7 +532,9 @@  discard block
 block discarded – undo
455 532
 				$darr = '';
456 533
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
457 534
 				if ($n == 3) {
458
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
535
+					if ($globalDebug) {
536
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
537
+					}
459 538
 					//$icao = $Translation->checkTranslation($ident);
460 539
 
461 540
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -466,7 +545,9 @@  discard block
 block discarded – undo
466 545
 			if (!$found) {
467 546
 				$n = sscanf($message,'MET01%4c',$airport);
468 547
 				if ($n == 1) {
469
-					if ($globalDebug) echo 'airport name : '.$airport;
548
+					if ($globalDebug) {
549
+						echo 'airport name : '.$airport;
550
+					}
470 551
 					$decode = array('Airport/Waypoint name' => $airport);
471 552
 					$found = true;
472 553
 				}
@@ -475,184 +556,126 @@  discard block
 block discarded – undo
475 556
 			if ($label == 'H1') {
476 557
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
477 558
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
478
-				}
479
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
559
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
480 560
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
481
-				}
482
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
561
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
483 562
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
484
-				}
485
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
563
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
486 564
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
487
-				}
488
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
565
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
489 566
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
490
-				}
491
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
567
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
492 568
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
493
-				}
494
-				elseif (preg_match(':^#M1AAEP:',$message)) {
569
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
495 570
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
496
-				}
497
-				elseif (preg_match(':^#M2APWD:',$message)) {
571
+				} elseif (preg_match(':^#M2APWD:',$message)) {
498 572
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
499
-				}
500
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
573
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
501 574
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
502
-				}
503
-				elseif (preg_match(':^#CF:',$message)) {
575
+				} elseif (preg_match(':^#CF:',$message)) {
504 576
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
505
-				}
506
-				elseif (preg_match(':^#DF:',$message)) {
577
+				} elseif (preg_match(':^#DF:',$message)) {
507 578
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
508
-				}
509
-				elseif (preg_match(':^#EC:',$message)) {
579
+				} elseif (preg_match(':^#EC:',$message)) {
510 580
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
511
-				}
512
-				elseif (preg_match(':^#EI:',$message)) {
581
+				} elseif (preg_match(':^#EI:',$message)) {
513 582
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
514
-				}
515
-				elseif (preg_match(':^#H1:',$message)) {
583
+				} elseif (preg_match(':^#H1:',$message)) {
516 584
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
517
-				}
518
-				elseif (preg_match(':^#H2:',$message)) {
585
+				} elseif (preg_match(':^#H2:',$message)) {
519 586
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
520
-				}
521
-				elseif (preg_match(':^#HD:',$message)) {
587
+				} elseif (preg_match(':^#HD:',$message)) {
522 588
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
523
-				}
524
-				elseif (preg_match(':^#M1:',$message)) {
589
+				} elseif (preg_match(':^#M1:',$message)) {
525 590
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
526
-				}
527
-				elseif (preg_match(':^#M2:',$message)) {
591
+				} elseif (preg_match(':^#M2:',$message)) {
528 592
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
529
-				}
530
-				elseif (preg_match(':^#M3:',$message)) {
593
+				} elseif (preg_match(':^#M3:',$message)) {
531 594
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
532
-				}
533
-				elseif (preg_match(':^#MD:',$message)) {
595
+				} elseif (preg_match(':^#MD:',$message)) {
534 596
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
535
-				}
536
-				elseif (preg_match(':^#PS:',$message)) {
597
+				} elseif (preg_match(':^#PS:',$message)) {
537 598
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
538
-				}
539
-				elseif (preg_match(':^#S1:',$message)) {
599
+				} elseif (preg_match(':^#S1:',$message)) {
540 600
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
541
-				}
542
-				elseif (preg_match(':^#S2:',$message)) {
601
+				} elseif (preg_match(':^#S2:',$message)) {
543 602
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
544
-				}
545
-				elseif (preg_match(':^#SD:',$message)) {
603
+				} elseif (preg_match(':^#SD:',$message)) {
546 604
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
547
-				}
548
-				elseif (preg_match(':^#T[0-8]:',$message)) {
605
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
549 606
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
550
-				}
551
-				elseif (preg_match(':^#WO:',$message)) {
607
+				} elseif (preg_match(':^#WO:',$message)) {
552 608
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
553
-				}
554
-				elseif (preg_match(':^#A1:',$message)) {
609
+				} elseif (preg_match(':^#A1:',$message)) {
555 610
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
556
-				}
557
-				elseif (preg_match(':^#A3:',$message)) {
611
+				} elseif (preg_match(':^#A3:',$message)) {
558 612
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
559
-				}
560
-				elseif (preg_match(':^#A4:',$message)) {
613
+				} elseif (preg_match(':^#A4:',$message)) {
561 614
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
562
-				}
563
-				elseif (preg_match(':^#A6:',$message)) {
615
+				} elseif (preg_match(':^#A6:',$message)) {
564 616
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
565
-				}
566
-				elseif (preg_match(':^#A8:',$message)) {
617
+				} elseif (preg_match(':^#A8:',$message)) {
567 618
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
568
-				}
569
-				elseif (preg_match(':^#A9:',$message)) {
619
+				} elseif (preg_match(':^#A9:',$message)) {
570 620
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
571
-				}
572
-				elseif (preg_match(':^#A0:',$message)) {
621
+				} elseif (preg_match(':^#A0:',$message)) {
573 622
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
574
-				}
575
-				elseif (preg_match(':^#AA:',$message)) {
623
+				} elseif (preg_match(':^#AA:',$message)) {
576 624
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
577
-				}
578
-				elseif (preg_match(':^#AB:',$message)) {
625
+				} elseif (preg_match(':^#AB:',$message)) {
579 626
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
580
-				}
581
-				elseif (preg_match(':^#AC:',$message)) {
627
+				} elseif (preg_match(':^#AC:',$message)) {
582 628
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
583
-				}
584
-				elseif (preg_match(':^#AD:',$message)) {
629
+				} elseif (preg_match(':^#AD:',$message)) {
585 630
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
586
-				}
587
-				elseif (preg_match(':^#AF:',$message)) {
631
+				} elseif (preg_match(':^#AF:',$message)) {
588 632
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
589
-				}
590
-				elseif (preg_match(':^#B1:',$message)) {
633
+				} elseif (preg_match(':^#B1:',$message)) {
591 634
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
592
-				}
593
-				elseif (preg_match(':^#B2:',$message)) {
635
+				} elseif (preg_match(':^#B2:',$message)) {
594 636
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
595
-				}
596
-				elseif (preg_match(':^#B3:',$message)) {
637
+				} elseif (preg_match(':^#B3:',$message)) {
597 638
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
598
-				}
599
-				elseif (preg_match(':^#B4:',$message)) {
639
+				} elseif (preg_match(':^#B4:',$message)) {
600 640
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
601
-				}
602
-				elseif (preg_match(':^#B6:',$message)) {
641
+				} elseif (preg_match(':^#B6:',$message)) {
603 642
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
604
-				}
605
-				elseif (preg_match(':^#B8:',$message)) {
643
+				} elseif (preg_match(':^#B8:',$message)) {
606 644
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
607
-				}
608
-				elseif (preg_match(':^#B9:',$message)) {
645
+				} elseif (preg_match(':^#B9:',$message)) {
609 646
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
610
-				}
611
-				elseif (preg_match(':^#B0:',$message)) {
647
+				} elseif (preg_match(':^#B0:',$message)) {
612 648
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
613
-				}
614
-				elseif (preg_match(':^#BA:',$message)) {
649
+				} elseif (preg_match(':^#BA:',$message)) {
615 650
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
616
-				}
617
-				elseif (preg_match(':^#BB:',$message)) {
651
+				} elseif (preg_match(':^#BB:',$message)) {
618 652
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
619
-				}
620
-				elseif (preg_match(':^#BC:',$message)) {
653
+				} elseif (preg_match(':^#BC:',$message)) {
621 654
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
622
-				}
623
-				elseif (preg_match(':^#BD:',$message)) {
655
+				} elseif (preg_match(':^#BD:',$message)) {
624 656
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
625
-				}
626
-				elseif (preg_match(':^#BE:',$message)) {
657
+				} elseif (preg_match(':^#BE:',$message)) {
627 658
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
628
-				}
629
-				elseif (preg_match(':^#BF:',$message)) {
659
+				} elseif (preg_match(':^#BF:',$message)) {
630 660
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
631
-				}
632
-				elseif (preg_match(':^#H3:',$message)) {
661
+				} elseif (preg_match(':^#H3:',$message)) {
633 662
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
634 663
 				}
635 664
 			}
636 665
 			if ($label == '10') {
637 666
 				if (preg_match(':^DTO01:',$message)) {
638 667
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
639
-				}
640
-				elseif (preg_match(':^AIS01:',$message)) {
668
+				} elseif (preg_match(':^AIS01:',$message)) {
641 669
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
642
-				}
643
-				elseif (preg_match(':^FTX01:',$message)) {
670
+				} elseif (preg_match(':^FTX01:',$message)) {
644 671
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
645
-				}
646
-				elseif (preg_match(':^FPL01:',$message)) {
672
+				} elseif (preg_match(':^FPL01:',$message)) {
647 673
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
648
-				}
649
-				elseif (preg_match(':^WAB01:',$message)) {
674
+				} elseif (preg_match(':^WAB01:',$message)) {
650 675
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
651
-				}
652
-				elseif (preg_match(':^MET01:',$message)) {
676
+				} elseif (preg_match(':^MET01:',$message)) {
653 677
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
654
-				}
655
-				elseif (preg_match(':^WAB02:',$message)) {
678
+				} elseif (preg_match(':^WAB02:',$message)) {
656 679
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
657 680
 				}
658 681
 			}
@@ -667,38 +690,28 @@  discard block
 block discarded – undo
667 690
 					$vsta = array('Version' => $version);
668 691
 					if ($state == 'E') {
669 692
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
670
-					}
671
-					elseif ($state == 'L') {
693
+					} elseif ($state == 'L') {
672 694
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
673
-					}
674
-					else {
695
+					} else {
675 696
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
676 697
 					}
677 698
 					if ($type == 'V') {
678 699
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
679
-					}
680
-					elseif ($type == 'S') {
700
+					} elseif ($type == 'S') {
681 701
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
682
-					}
683
-					elseif ($type == 'H') {
702
+					} elseif ($type == 'H') {
684 703
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
685
-					}
686
-					elseif ($type == 'G') {
704
+					} elseif ($type == 'G') {
687 705
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
688
-					}
689
-					elseif ($type == 'C') {
706
+					} elseif ($type == 'C') {
690 707
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
691
-					}
692
-					elseif ($type == '2') {
708
+					} elseif ($type == '2') {
693 709
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
694
-					}
695
-					elseif ($type == 'X') {
710
+					} elseif ($type == 'X') {
696 711
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
697
-					}
698
-					elseif ($type == 'I') {
712
+					} elseif ($type == 'I') {
699 713
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
700
-					}
701
-					else {
714
+					} else {
702 715
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
703 716
 					}
704 717
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -707,7 +720,9 @@  discard block
 block discarded – undo
707 720
 			}
708 721
 
709 722
 			$title = $this->getTitlefromLabel($label);
710
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
723
+			if ($title != '') {
724
+				$decode = array_merge(array('Message title' => $title),$decode);
725
+			}
711 726
 
712 727
 			/*
713 728
 			// Business jets always use GS0001
@@ -748,14 +763,26 @@  discard block
 block discarded – undo
748 763
 			$decode = $message['decode'];
749 764
 			$registration = (string)$message['registration'];
750 765
 		
751
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
752
-			else $latitude = '';
753
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
754
-			else $longitude = '';
755
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
756
-			else $airicao = '';
757
-			if (isset($decode['icao'])) $icao = $decode['icao'];
758
-			else $icao = $Translation->checkTranslation($ident);
766
+			if (isset($decode['latitude'])) {
767
+				$latitude = $decode['latitude'];
768
+			} else {
769
+				$latitude = '';
770
+			}
771
+			if (isset($decode['longitude'])) {
772
+				$longitude = $decode['longitude'];
773
+			} else {
774
+				$longitude = '';
775
+			}
776
+			if (isset($decode['airicao'])) {
777
+				$airicao = $decode['airicao'];
778
+			} else {
779
+				$airicao = '';
780
+			}
781
+			if (isset($decode['icao'])) {
782
+				$icao = $decode['icao'];
783
+			} else {
784
+				$icao = $Translation->checkTranslation($ident);
785
+			}
759 786
 		
760 787
 			$image_array = $Image->getSpotterImage($registration);
761 788
 			if (!isset($image_array[0]['registration'])) {
@@ -763,11 +790,18 @@  discard block
 block discarded – undo
763 790
 			}
764 791
 		
765 792
 			// Business jets always use GS0001
766
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
767
-			if ($globalDebug && isset($info) && $info != '') echo $info;
793
+			if ($ident != 'GS0001') {
794
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
795
+			}
796
+			if ($globalDebug && isset($info) && $info != '') {
797
+				echo $info;
798
+			}
768 799
 
769
-			if (count($decode) > 0) $decode_json = json_encode($decode);
770
-			else $decode_json = '';
800
+			if (count($decode) > 0) {
801
+				$decode_json = json_encode($decode);
802
+			} else {
803
+				$decode_json = '';
804
+			}
771 805
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
772 806
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
773 807
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
@@ -775,8 +809,12 @@  discard block
 block discarded – undo
775 809
 			}
776 810
 
777 811
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
778
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
779
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
812
+			if (!isset($globalACARSArchive)) {
813
+				$globalACARSArchive = array('10','80','81','82','3F');
814
+			}
815
+			if ($result && in_array($label,$globalACARSArchive)) {
816
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
817
+			}
780 818
 
781 819
 			if ($globalDebug && count($decode) > 0) {
782 820
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
@@ -801,7 +839,9 @@  discard block
 block discarded – undo
801 839
 			$Connection = new Connection($this->db);
802 840
 			$this->db = $Connection->db;
803 841
 
804
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
842
+			if ($globalDebug) {
843
+				echo "Test if not already in Live ACARS table...";
844
+			}
805 845
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
806 846
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
807 847
 			try {
@@ -811,7 +851,9 @@  discard block
 block discarded – undo
811 851
 				return "error : ".$e->getMessage();
812 852
 			}
813 853
 			if ($stht->fetchColumn() == 0) {
814
-				if ($globalDebug) echo "Add Live ACARS data...";
854
+				if ($globalDebug) {
855
+					echo "Add Live ACARS data...";
856
+				}
815 857
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
816 858
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
817 859
 				try {
@@ -822,10 +864,14 @@  discard block
 block discarded – undo
822 864
 					return "error : ".$e->getMessage();
823 865
 				}
824 866
 			} else {
825
-				if ($globalDebug) echo "Data already in DB...\n";
867
+				if ($globalDebug) {
868
+					echo "Data already in DB...\n";
869
+				}
826 870
 				return false;
827 871
 			}
828
-			if ($globalDebug) echo "Done\n";
872
+			if ($globalDebug) {
873
+				echo "Done\n";
874
+			}
829 875
 			return true;
830 876
 		}
831 877
 	}
@@ -857,7 +903,9 @@  discard block
 block discarded – undo
857 903
 			    	    }
858 904
 				    if ($stht->fetchColumn() == 0) {
859 905
 			*/
860
-			if ($globalDebug) echo "Add Live ACARS data...";
906
+			if ($globalDebug) {
907
+				echo "Add Live ACARS data...";
908
+			}
861 909
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
862 910
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
863 911
 			try {
@@ -868,7 +916,9 @@  discard block
 block discarded – undo
868 916
 				return "error : ".$e->getMessage();
869 917
 			}
870 918
 //    	    }
871
-			if ($globalDebug) echo "Done\n";
919
+			if ($globalDebug) {
920
+				echo "Done\n";
921
+			}
872 922
 		}
873 923
 	}
874 924
 
@@ -892,8 +942,11 @@  discard block
 block discarded – undo
892 942
 			die;
893 943
 		}
894 944
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
895
-		if (count($row) > 0) return $row[0]['title'];
896
-		else return '';
945
+		if (count($row) > 0) {
946
+			return $row[0]['title'];
947
+		} else {
948
+			return '';
949
+		}
897 950
 	}
898 951
 
899 952
 	/**
@@ -913,8 +966,11 @@  discard block
 block discarded – undo
913 966
 			die;
914 967
 		}
915 968
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
916
-		if (count($row) > 0) return $row;
917
-		else return array();
969
+		if (count($row) > 0) {
970
+			return $row;
971
+		} else {
972
+			return array();
973
+		}
918 974
 	}
919 975
 
920 976
 	/**
@@ -935,8 +991,11 @@  discard block
 block discarded – undo
935 991
 			die;
936 992
 		}
937 993
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
938
-		if (count($row) > 0) return $row[0];
939
-		else return array();
994
+		if (count($row) > 0) {
995
+			return $row[0];
996
+		} else {
997
+			return array();
998
+		}
940 999
 	}
941 1000
 
942 1001
 	/**
@@ -988,20 +1047,36 @@  discard block
 block discarded – undo
988 1047
 			if ($row['registration'] != '') {
989 1048
 				$row['registration'] = str_replace('.','',$row['registration']);
990 1049
 				$image_array = $Image->getSpotterImage($row['registration']);
991
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
992
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
994
-			if ($row['registration'] == '') $row['registration'] = 'NA';
995
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1050
+				if (count($image_array) > 0) {
1051
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1052
+				} else {
1053
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1054
+				}
1055
+			} else {
1056
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1057
+			}
1058
+			if ($row['registration'] == '') {
1059
+				$row['registration'] = 'NA';
1060
+			}
1061
+			if ($row['ident'] == '') {
1062
+				$row['ident'] = 'NA';
1063
+			}
996 1064
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
997 1065
 			if (isset($identicao[0])) {
998 1066
 				if (substr($row['ident'],0,2) == 'AF') {
999
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1000
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1001
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1067
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1068
+						$icao = $row['ident'];
1069
+					} else {
1070
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1071
+					}
1072
+				} else {
1073
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1074
+				}
1002 1075
 
1003 1076
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1004
-			} else $icao = $row['ident'];
1077
+			} else {
1078
+				$icao = $row['ident'];
1079
+			}
1005 1080
 			$icao = $Translation->checkTranslation($icao,false);
1006 1081
 
1007 1082
 			$decode = json_decode($row['decode'],true);
@@ -1027,7 +1102,9 @@  discard block
 block discarded – undo
1027 1102
 					$found = true;
1028 1103
 				}
1029 1104
 			}
1030
-			if ($found) $row['decode'] = json_encode($decode);
1105
+			if ($found) {
1106
+				$row['decode'] = json_encode($decode);
1107
+			}
1031 1108
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1032 1109
 			$result[] = $data;
1033 1110
 			$i++;
@@ -1035,8 +1112,9 @@  discard block
 block discarded – undo
1035 1112
 		if (isset($result)) {
1036 1113
 			$result[0]['query_number_rows'] = $i;
1037 1114
 			return $result;
1115
+		} else {
1116
+			return array();
1038 1117
 		}
1039
-		else return array();
1040 1118
 	}
1041 1119
 
1042 1120
 	/**
@@ -1096,20 +1174,36 @@  discard block
 block discarded – undo
1096 1174
 			if ($row['registration'] != '') {
1097 1175
 				$row['registration'] = str_replace('.','',$row['registration']);
1098 1176
 				$image_array = $Image->getSpotterImage($row['registration']);
1099
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1100
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1101
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1177
+				if (count($image_array) > 0) {
1178
+					$data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1179
+				} else {
1180
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1181
+				}
1182
+			} else {
1183
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1184
+			}
1102 1185
 			$icao = '';
1103
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1104
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1186
+			if ($row['registration'] == '') {
1187
+				$row['registration'] = 'NA';
1188
+			}
1189
+			if ($row['ident'] == '') {
1190
+				$row['ident'] = 'NA';
1191
+			}
1105 1192
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1106 1193
 			if (isset($identicao[0])) {
1107 1194
 				if (substr($row['ident'],0,2) == 'AF') {
1108
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1109
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1110
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1195
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1196
+						$icao = $row['ident'];
1197
+					} else {
1198
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1199
+					}
1200
+				} else {
1201
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1202
+				}
1111 1203
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1112
-			} else $icao = $row['ident'];
1204
+			} else {
1205
+				$icao = $row['ident'];
1206
+			}
1113 1207
 			$icao = $Translation->checkTranslation($icao);
1114 1208
 
1115 1209
 
@@ -1117,12 +1211,16 @@  discard block
 block discarded – undo
1117 1211
 			$found = false;
1118 1212
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1119 1213
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1120
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1214
+				if (isset($airport_info[0]['icao'])) {
1215
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1216
+				}
1121 1217
 				$found = true;
1122 1218
 			}
1123 1219
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1124 1220
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1125
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1221
+				if (isset($airport_info[0]['icao'])) {
1222
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1223
+				}
1126 1224
 				$found = true;
1127 1225
 			}
1128 1226
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1132,7 +1230,9 @@  discard block
 block discarded – undo
1132 1230
 					$found = true;
1133 1231
 				}
1134 1232
 			}
1135
-			if ($found) $row['decode'] = json_encode($decode);
1233
+			if ($found) {
1234
+				$row['decode'] = json_encode($decode);
1235
+			}
1136 1236
 
1137 1237
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1138 1238
 			$result[] = $data;
@@ -1141,7 +1241,9 @@  discard block
 block discarded – undo
1141 1241
 		if (isset($result)) {
1142 1242
 			$result[0]['query_number_rows'] = $i;
1143 1243
 			return $result;
1144
-		} else return array();
1244
+		} else {
1245
+			return array();
1246
+		}
1145 1247
 	}
1146 1248
 
1147 1249
 	/**
@@ -1157,19 +1259,29 @@  discard block
 block discarded – undo
1157 1259
 		$ident = trim($ident);
1158 1260
 		$Translation = new Translation($this->db);
1159 1261
 		$Spotter = new Spotter($this->db);
1160
-		if ($globalDebug) echo "Test if we add ModeS data...";
1262
+		if ($globalDebug) {
1263
+			echo "Test if we add ModeS data...";
1264
+		}
1161 1265
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1162
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1163
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1266
+		if ($icao == '') {
1267
+			$icao = $Translation->checkTranslation($ident);
1268
+		}
1269
+		if ($globalDebug) {
1270
+			echo '- Ident : '.$icao.' - ';
1271
+		}
1164 1272
 		if ($ident == '' || $registration == '') {
1165
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1273
+			if ($globalDebug) {
1274
+				echo "Ident or registration null, exit\n";
1275
+			}
1166 1276
 			return '';
1167 1277
 		}
1168 1278
 
1169 1279
 		$registration = str_replace('.','',$registration);
1170 1280
 		$ident = $Translation->ident2icao($ident);
1171 1281
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1172
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1282
+		if ($globalDebug) {
1283
+			echo "Check if needed to add translation ".$ident.'... ';
1284
+		}
1173 1285
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1174 1286
 		$querysi_values = array(':registration' => $registration);
1175 1287
 		try {
@@ -1177,7 +1289,9 @@  discard block
 block discarded – undo
1177 1289
 			$sthsi = $this->db->prepare($querysi);
1178 1290
 			$sthsi->execute($querysi_values);
1179 1291
 		} catch(PDOException $e) {
1180
-			if ($globalDebug) echo $e->getMessage();
1292
+			if ($globalDebug) {
1293
+				echo $e->getMessage();
1294
+			}
1181 1295
 			return "error : ".$e->getMessage();
1182 1296
 		}
1183 1297
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1186,9 +1300,14 @@  discard block
 block discarded – undo
1186 1300
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1187 1301
 			$Translation = new Translation($this->db);
1188 1302
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1189
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1190
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1191
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1303
+			if ($globalDebug) {
1304
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1305
+			}
1306
+			if ($ident != $trans_ident) {
1307
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1308
+			} elseif ($trans_ident == $ident) {
1309
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1310
+			}
1192 1311
 		} else {
1193 1312
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1194 1313
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1197,18 +1316,25 @@  discard block
 block discarded – undo
1197 1316
 					$sth = $this->db->prepare($query);
1198 1317
 					$sth->execute($query_values);
1199 1318
 				} catch(PDOException $e) {
1200
-					if ($globalDebug) echo $e->getMessage();
1319
+					if ($globalDebug) {
1320
+						echo $e->getMessage();
1321
+					}
1201 1322
 					return "error : ".$e->getMessage();
1202 1323
 				}
1203 1324
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1204 1325
 				$sth->closeCursor();
1205
-				if (isset($result['modes'])) $hex = $result['modes'];
1206
-				else $hex = '';
1326
+				if (isset($result['modes'])) {
1327
+					$hex = $result['modes'];
1328
+				} else {
1329
+					$hex = '';
1330
+				}
1207 1331
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1208 1332
 				$this->SI->add($SI_data);
1209 1333
 			}
1210 1334
 		}
1211
-		if ($globalDebug) echo 'Done'."\n";
1335
+		if ($globalDebug) {
1336
+			echo 'Done'."\n";
1337
+		}
1212 1338
 
1213 1339
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1214 1340
 		$query_values = array(':ident' => $icao);
@@ -1217,15 +1343,20 @@  discard block
 block discarded – undo
1217 1343
 			$sth = $this->db->prepare($query);
1218 1344
 			$sth->execute($query_values);
1219 1345
 		} catch(PDOException $e) {
1220
-			if ($globalDebug) echo $e->getMessage();
1346
+			if ($globalDebug) {
1347
+				echo $e->getMessage();
1348
+			}
1221 1349
 			return "error : ".$e->getMessage();
1222 1350
 		}
1223 1351
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1224 1352
 		$sth->closeCursor();
1225 1353
 		//print_r($result);
1226 1354
 		if (isset($result['flightaware_id'])) {
1227
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1228
-			else $ModeS = '';
1355
+			if (isset($result['ModeS'])) {
1356
+				$ModeS = $result['ModeS'];
1357
+			} else {
1358
+				$ModeS = '';
1359
+			}
1229 1360
 			if ($ModeS == '') {
1230 1361
 				$id = explode('-',$result['flightaware_id']);
1231 1362
 				$ModeS = $id[0];
@@ -1239,13 +1370,17 @@  discard block
 block discarded – undo
1239 1370
 					$sthc = $this->db->prepare($queryc);
1240 1371
 					$sthc->execute($queryc_values);
1241 1372
 				} catch(PDOException $e) {
1242
-					if ($globalDebug) echo $e->getMessage();
1373
+					if ($globalDebug) {
1374
+						echo $e->getMessage();
1375
+					}
1243 1376
 					return "error : ".$e->getMessage();
1244 1377
 				}
1245 1378
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1246 1379
 				$sthc->closeCursor();
1247 1380
 				if (count($row) ==  0) {
1248
-					if ($globalDebug) echo " Add to ModeS table - ";
1381
+					if ($globalDebug) {
1382
+						echo " Add to ModeS table - ";
1383
+					}
1249 1384
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1250 1385
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1251 1386
 					try {
@@ -1253,11 +1388,15 @@  discard block
 block discarded – undo
1253 1388
 						$sthi = $this->db->prepare($queryi);
1254 1389
 						$sthi->execute($queryi_values);
1255 1390
 					} catch(PDOException $e) {
1256
-						if ($globalDebug) echo $e->getMessage();
1391
+						if ($globalDebug) {
1392
+							echo $e->getMessage();
1393
+						}
1257 1394
 						return "error : ".$e->getMessage();
1258 1395
 					}
1259 1396
 				} else {
1260
-					if ($globalDebug) echo " Update ModeS table - ";
1397
+					if ($globalDebug) {
1398
+						echo " Update ModeS table - ";
1399
+					}
1261 1400
 					if ($ICAOTypeCode != '') {
1262 1401
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1263 1402
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1270,7 +1409,9 @@  discard block
 block discarded – undo
1270 1409
 						$sthi = $this->db->prepare($queryi);
1271 1410
 						$sthi->execute($queryi_values);
1272 1411
 					} catch(PDOException $e) {
1273
-						if ($globalDebug) echo $e->getMessage();
1412
+						if ($globalDebug) {
1413
+							echo $e->getMessage();
1414
+						}
1274 1415
 						return "error : ".$e->getMessage();
1275 1416
 					}
1276 1417
 				}
@@ -1292,7 +1433,9 @@  discard block
 block discarded – undo
1292 1433
 					    return "error : ".$e->getMessage();
1293 1434
 				}
1294 1435
 				*/
1295
-				if ($globalDebug) echo " Update Spotter_output table - ";
1436
+				if ($globalDebug) {
1437
+					echo " Update Spotter_output table - ";
1438
+				}
1296 1439
 				if ($ICAOTypeCode != '') {
1297 1440
 					if ($globalDBdriver == 'mysql') {
1298 1441
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1303,8 +1446,7 @@  discard block
 block discarded – undo
1303 1446
 				} else {
1304 1447
 					if ($globalDBdriver == 'mysql') {
1305 1448
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1306
-					}
1307
-					elseif ($globalDBdriver == 'pgsql') {
1449
+					} elseif ($globalDBdriver == 'pgsql') {
1308 1450
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1309 1451
 					}
1310 1452
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1314,15 +1456,21 @@  discard block
 block discarded – undo
1314 1456
 					$sthi = $this->db->prepare($queryi);
1315 1457
 					$sthi->execute($queryi_values);
1316 1458
 				} catch(PDOException $e) {
1317
-					if ($globalDebug) echo $e->getMessage();
1459
+					if ($globalDebug) {
1460
+						echo $e->getMessage();
1461
+					}
1318 1462
 					return "error : ".$e->getMessage();
1319 1463
 				}
1320 1464
 
1321 1465
 			}
1322 1466
 		} else {
1323
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1467
+			if ($globalDebug) {
1468
+				echo " Can't find ModeS in spotter_output - ";
1469
+			}
1470
+		}
1471
+		if ($globalDebug) {
1472
+			echo "Done\n";
1324 1473
 		}
1325
-		if ($globalDebug) echo "Done\n";
1326 1474
 	}
1327 1475
 }
1328 1476
 ?>
Please login to merge, or discard this patch.
require/class.Image.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -319,6 +319,9 @@
 block discarded – undo
319 319
 		return false;
320 320
 	}
321 321
 
322
+	/**
323
+	 * @param string $aircraft_icao
324
+	 */
322 325
 	public function fromIvaoMtl($aircraft_icao,$airline_icao) {
323 326
 		$Common = new Common();
324 327
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	/**
15
-	* Gets the images based on the aircraft registration
16
-	*
17
-	* @return Array the images list
18
-	*
19
-	*/
15
+	 * Gets the images based on the aircraft registration
16
+	 *
17
+	 * @return Array the images list
18
+	 *
19
+	 */
20 20
 	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
21 21
 	{
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 			WHERE spotter_image.registration = :registration";
30 30
 		$sth = $this->db->prepare($query);
31 31
 		$sth->execute(array(':registration' => $registration));
32
-          /*
32
+		  /*
33 33
         $images_array = array();
34 34
 	$temp_array = array();
35 35
 
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	/**
55
-	* Gets the image copyright based on the Exif data
56
-	*
57
-	* @return String image copyright
58
-	*
59
-	*/
55
+	 * Gets the image copyright based on the Exif data
56
+	 *
57
+	 * @return String image copyright
58
+	 *
59
+	 */
60 60
 	public function getExifCopyright($url) {
61 61
 		$exif = exif_read_data($url);
62 62
 		$copyright = '';
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 	}
72 72
 
73 73
 	/**
74
-	* Adds the images based on the aircraft registration
75
-	*
76
-	* @return String either success or error
77
-	*
78
-	*/
74
+	 * Adds the images based on the aircraft registration
75
+	 *
76
+	 * @return String either success or error
77
+	 *
78
+	 */
79 79
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
80 80
 	{
81 81
 		global $globalDebug,$globalAircraftImageFetch;
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	/**
107
-	* Gets the aircraft image
108
-	*
109
-	* @param String $aircraft_registration the registration of the aircraft
110
-	* @return Array the aircraft thumbnail, orignal url and copyright
111
-	*
112
-	*/
107
+	 * Gets the aircraft image
108
+	 *
109
+	 * @param String $aircraft_registration the registration of the aircraft
110
+	 * @return Array the aircraft thumbnail, orignal url and copyright
111
+	 *
112
+	 */
113 113
 	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
114 114
 	{
115 115
 		global $globalAircraftImageSources, $globalIVAO;
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 	}
150 150
 
151 151
 	/**
152
-	* Gets the aircraft image from Planespotters
153
-	*
154
-	* @param String $aircraft_registration the registration of the aircraft
155
-	* @param String $aircraft_name type of the aircraft
156
-	* @return Array the aircraft thumbnail, orignal url and copyright
157
-	*
158
-	*/
152
+	 * Gets the aircraft image from Planespotters
153
+	 *
154
+	 * @param String $aircraft_registration the registration of the aircraft
155
+	 * @param String $aircraft_name type of the aircraft
156
+	 * @return Array the aircraft thumbnail, orignal url and copyright
157
+	 *
158
+	 */
159 159
 	public function fromPlanespotters($aircraft_registration, $aircraft_name='') {
160 160
 		$Common = new Common();
161 161
 		// If aircraft registration is only number, also check with aircraft model
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	/**
185
-	* Gets the aircraft image from Deviantart
186
-	*
187
-	* @param String $aircraft_registration the registration of the aircraft
188
-	* @param String $aircraft_name type of the aircraft
189
-	* @return Array the aircraft thumbnail, orignal url and copyright
190
-	*
191
-	*/
185
+	 * Gets the aircraft image from Deviantart
186
+	 *
187
+	 * @param String $aircraft_registration the registration of the aircraft
188
+	 * @param String $aircraft_name type of the aircraft
189
+	 * @return Array the aircraft thumbnail, orignal url and copyright
190
+	 *
191
+	 */
192 192
 	public function fromDeviantart($aircraft_registration, $aircraft_name='') {
193 193
 		$Common = new Common();
194 194
 		// If aircraft registration is only number, also check with aircraft model
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 
218 218
 	/**
219
-	* Gets the aircraft image from JetPhotos
220
-	*
221
-	* @param String $aircraft_registration the registration of the aircraft
222
-	* @param String $aircraft_name type of the aircraft
223
-	* @return Array the aircraft thumbnail, orignal url and copyright
224
-	*
225
-	*/
219
+	 * Gets the aircraft image from JetPhotos
220
+	 *
221
+	 * @param String $aircraft_registration the registration of the aircraft
222
+	 * @param String $aircraft_name type of the aircraft
223
+	 * @return Array the aircraft thumbnail, orignal url and copyright
224
+	 *
225
+	 */
226 226
 	public function fromJetPhotos($aircraft_registration, $aircraft_name='') {
227 227
 		$Common = new Common();
228 228
 		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
 	}
259 259
 
260 260
 	/**
261
-	* Gets the aircraft image from PlanePictures
262
-	*
263
-	* @param String $aircraft_registration the registration of the aircraft
264
-	* @param String $aircraft_name type of the aircraft
265
-	* @return Array the aircraft thumbnail, orignal url and copyright
266
-	*
267
-	*/
261
+	 * Gets the aircraft image from PlanePictures
262
+	 *
263
+	 * @param String $aircraft_registration the registration of the aircraft
264
+	 * @param String $aircraft_name type of the aircraft
265
+	 * @return Array the aircraft thumbnail, orignal url and copyright
266
+	 *
267
+	 */
268 268
 	public function fromPlanePictures($aircraft_registration, $aircraft_name='') {
269 269
 		$Common = new Common();
270 270
 		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
@@ -292,13 +292,13 @@  discard block
 block discarded – undo
292 292
 	}
293 293
 
294 294
 	/**
295
-	* Gets the aircraft image from Flickr
296
-	*
297
-	* @param String $aircraft_registration the registration of the aircraft
298
-	* @param String $aircraft_name type of the aircraft
299
-	* @return Array the aircraft thumbnail, orignal url and copyright
300
-	*
301
-	*/
295
+	 * Gets the aircraft image from Flickr
296
+	 *
297
+	 * @param String $aircraft_registration the registration of the aircraft
298
+	 * @param String $aircraft_name type of the aircraft
299
+	 * @return Array the aircraft thumbnail, orignal url and copyright
300
+	 *
301
+	 */
302 302
 	public function fromFlickr($aircraft_registration,$aircraft_name='') {
303 303
 		$Common = new Common();
304 304
 		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 	}
337 337
 
338 338
 	/**
339
-	* Gets the aircraft image from Bing
340
-	*
341
-	* @param String $aircraft_registration the registration of the aircraft
342
-	* @param String $aircraft_name type of the aircraft
343
-	* @return Array the aircraft thumbnail, orignal url and copyright
344
-	*
345
-	*/
339
+	 * Gets the aircraft image from Bing
340
+	 *
341
+	 * @param String $aircraft_registration the registration of the aircraft
342
+	 * @param String $aircraft_name type of the aircraft
343
+	 * @return Array the aircraft thumbnail, orignal url and copyright
344
+	 *
345
+	 */
346 346
 	public function fromBing($aircraft_registration,$aircraft_name='') {
347 347
 		global $globalImageBingKey;
348 348
 		$Common = new Common();
@@ -368,13 +368,13 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 
370 370
 	/**
371
-	* Gets the aircraft image from airport-data
372
-	*
373
-	* @param String $aircraft_registration the registration of the aircraft
374
-	* @param String $aircraft_name type of the aircraft
375
-	* @return Array the aircraft thumbnail, orignal url and copyright
376
-	*
377
-	*/
371
+	 * Gets the aircraft image from airport-data
372
+	 *
373
+	 * @param String $aircraft_registration the registration of the aircraft
374
+	 * @param String $aircraft_name type of the aircraft
375
+	 * @return Array the aircraft thumbnail, orignal url and copyright
376
+	 *
377
+	 */
378 378
 	public function fromAirportData($aircraft_registration,$aircraft_name='') {
379 379
 		$Common = new Common();
380 380
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
@@ -393,13 +393,13 @@  discard block
 block discarded – undo
393 393
 	}
394 394
 
395 395
 	/**
396
-	* Gets the aircraft image from WikiMedia
397
-	*
398
-	* @param String $aircraft_registration the registration of the aircraft
399
-	* @param String $aircraft_name type of the aircraft
400
-	* @return Array the aircraft thumbnail, orignal url and copyright
401
-	*
402
-	*/
396
+	 * Gets the aircraft image from WikiMedia
397
+	 *
398
+	 * @param String $aircraft_registration the registration of the aircraft
399
+	 * @param String $aircraft_name type of the aircraft
400
+	 * @return Array the aircraft thumbnail, orignal url and copyright
401
+	 *
402
+	 */
403 403
 	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
404 404
 		$Common = new Common();
405 405
 		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 	}
450 450
 
451 451
 	/**
452
-	* Gets the aircraft image from custom url
453
-	*
454
-	* @param String $aircraft_registration the registration of the aircraft
455
-	* @param String $aircraft_name type of the aircraft
456
-	* @return Array the aircraft thumbnail, orignal url and copyright
457
-	*
458
-	*/
452
+	 * Gets the aircraft image from custom url
453
+	 *
454
+	 * @param String $aircraft_registration the registration of the aircraft
455
+	 * @param String $aircraft_name type of the aircraft
456
+	 * @return Array the aircraft thumbnail, orignal url and copyright
457
+	 *
458
+	 */
459 459
 	public function fromCustomSource($aircraft_registration,$aircraft_name='') {
460 460
 		global $globalAircraftCustomSources;
461 461
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
Please login to merge, or discard this patch.
Braces   +126 added lines, -46 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23 23
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24 24
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
25
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
25
+		if ($registration == '' && $aircraft_icao != '') {
26
+			$registration = $aircraft_icao.$airline_icao;
27
+		}
26 28
 		$registration = trim($registration);
27 29
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright
28 30
 			FROM spotter_image 
@@ -60,8 +62,11 @@  discard block
 block discarded – undo
60 62
 	public function getExifCopyright($url) {
61 63
 		$exif = exif_read_data($url);
62 64
 		$copyright = '';
63
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
64
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
65
+		if (isset($exif['COMPUTED']['copyright'])) {
66
+			$copyright = $exif['COMPUTED']['copyright'];
67
+		} elseif (isset($exif['copyright'])) {
68
+			$copyright = $exif['copyright'];
69
+		}
65 70
 		if ($copyright != '') {
66 71
 			$copyright = str_replace('Copyright ','',$copyright);
67 72
 			$copyright = str_replace('© ','',$copyright);
@@ -79,18 +84,29 @@  discard block
 block discarded – undo
79 84
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
80 85
 	{
81 86
 		global $globalDebug,$globalAircraftImageFetch;
82
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
87
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
88
+			return '';
89
+		}
83 90
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
84 91
 		$registration = trim($registration);
85 92
 		//getting the aircraft image
86
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
87
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
88
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
89
-		else return "success";
93
+		if ($globalDebug && $registration != '') {
94
+			echo 'Try to find an aircraft image for '.$registration.'...';
95
+		} elseif ($globalDebug && $aircraft_icao != '') {
96
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
97
+		} elseif ($globalDebug && $airline_icao != '') {
98
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
99
+		} else {
100
+			return "success";
101
+		}
90 102
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
91
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
103
+		if ($registration == '' && $aircraft_icao != '') {
104
+			$registration = $aircraft_icao.$airline_icao;
105
+		}
92 106
 		if ($image_url['original'] != '') {
93
-			if ($globalDebug) echo 'Found !'."\n";
107
+			if ($globalDebug) {
108
+				echo 'Found !'."\n";
109
+			}
94 110
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
95 111
 			try {
96 112
 				$sth = $this->db->prepare($query);
@@ -99,7 +115,9 @@  discard block
 block discarded – undo
99 115
 				echo $e->getMessage()."\n";
100 116
 				return "error";
101 117
 			}
102
-		} elseif ($globalDebug) echo "Not found :'(\n";
118
+		} elseif ($globalDebug) {
119
+			echo "Not found :'(\n";
120
+		}
103 121
 		return "success";
104 122
 	}
105 123
 
@@ -114,36 +132,75 @@  discard block
 block discarded – undo
114 132
 	{
115 133
 		global $globalAircraftImageSources, $globalIVAO;
116 134
 		$Spotter = new Spotter($this->db);
117
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
135
+		if (!isset($globalIVAO)) {
136
+			$globalIVAO = FALSE;
137
+		}
118 138
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
119 139
 		if ($aircraft_registration != '') {
120
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
140
+			if (strpos($aircraft_registration,'/') !== false) {
141
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
142
+			}
121 143
 			$aircraft_registration = urlencode(trim($aircraft_registration));
122 144
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
123
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
124
-			else $aircraft_name = '';
125
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
126
-			else $aircraft_icao = '';
127
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
128
-			else $airline_icao = '';
145
+			if (isset($aircraft_info[0]['aircraft_name'])) {
146
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
147
+			} else {
148
+				$aircraft_name = '';
149
+			}
150
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
151
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
152
+			} else {
153
+				$aircraft_icao = '';
154
+			}
155
+			if (isset($aircraft_info[0]['airline_icao'])) {
156
+				$airline_icao = $aircraft_info[0]['airline_icao'];
157
+			} else {
158
+				$airline_icao = '';
159
+			}
129 160
 		} elseif ($aircraft_icao != '') {
130 161
 			$aircraft_registration = $aircraft_icao;
131 162
 			$aircraft_name = '';
132
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
133
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
163
+		} else {
164
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
165
+		}
166
+		if (!isset($globalAircraftImageSources)) {
167
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
168
+		}
134 169
 		foreach ($globalAircraftImageSources as $source) {
135 170
 			$source = strtolower($source);
136
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
137
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
138
-			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
139
-			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name);
140
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
141
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
142
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
143
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
144
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
145
-			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
146
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
171
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
172
+				$images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
173
+			}
174
+			if ($source == 'planespotters' && !$globalIVAO) {
175
+				$images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
176
+			}
177
+			if ($source == 'flickr') {
178
+				$images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
179
+			}
180
+			if ($source == 'bing') {
181
+				$images_array = $this->fromBing($aircraft_registration,$aircraft_name);
182
+			}
183
+			if ($source == 'deviantart') {
184
+				$images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
185
+			}
186
+			if ($source == 'wikimedia') {
187
+				$images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
188
+			}
189
+			if ($source == 'jetphotos' && !$globalIVAO) {
190
+				$images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
191
+			}
192
+			if ($source == 'planepictures' && !$globalIVAO) {
193
+				$images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
194
+			}
195
+			if ($source == 'airportdata' && !$globalIVAO) {
196
+				$images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
197
+			}
198
+			if ($source == 'customsources') {
199
+				$images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
200
+			}
201
+			if (isset($images_array) && $images_array['original'] != '') {
202
+				return $images_array;
203
+			}
147 204
 		}
148 205
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
149 206
 	}
@@ -301,8 +358,11 @@  discard block
 block discarded – undo
301 358
 	*/
302 359
 	public function fromFlickr($aircraft_registration,$aircraft_name='') {
303 360
 		$Common = new Common();
304
-		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
305
-		else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
361
+		if ($aircraft_name != '') {
362
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
363
+		} else {
364
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
365
+		}
306 366
 		$data = $Common->getData($url);
307 367
 		if ($xml = simplexml_load_string($data)) {
308 368
 			if (isset($xml->channel->item)) {
@@ -346,9 +406,14 @@  discard block
 block discarded – undo
346 406
 	public function fromBing($aircraft_registration,$aircraft_name='') {
347 407
 		global $globalImageBingKey;
348 408
 		$Common = new Common();
349
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
350
-		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
351
-		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
409
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
410
+			return false;
411
+		}
412
+		if ($aircraft_name != '') {
413
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
414
+		} else {
415
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
416
+		}
352 417
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
353 418
 		$data = $Common->getData($url,'get','',$headers);
354 419
 		$result = json_decode($data);
@@ -402,13 +467,18 @@  discard block
 block discarded – undo
402 467
 	*/
403 468
 	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
404 469
 		$Common = new Common();
405
-		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
406
-		else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
470
+		if ($aircraft_name != '') {
471
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
472
+		} else {
473
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
474
+		}
407 475
 		$data = $Common->getData($url);
408 476
 		$result = json_decode($data);
409 477
 		if (isset($result->query->search[0]->title)) {
410 478
 			$fileo = $result->query->search[0]->title;
411
-			if (substr($fileo,-3) == 'pdf') return false;
479
+			if (substr($fileo,-3) == 'pdf') {
480
+				return false;
481
+			}
412 482
 			$file = urlencode($fileo);
413 483
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
414 484
 			$data2 = $Common->getData($url2);
@@ -460,7 +530,9 @@  discard block
 block discarded – undo
460 530
 		global $globalAircraftCustomSources;
461 531
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
462 532
 		if (!empty($globalAircraftImageCustomSources)) {
463
-			if (!isset($globalAircraftImageCustomSources[0])) $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources;
533
+			if (!isset($globalAircraftImageCustomSources[0])) {
534
+				$globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources;
535
+			}
464 536
 			foreach ($globalAircraftImageCustomSources as $source) {
465 537
 				$Common = new Common();
466 538
 				$url = str_replace('{registration}',$aircraft_registration,$source['original']);
@@ -469,17 +541,25 @@  discard block
 block discarded – undo
469 541
 					$image_url = array();
470 542
 					$image_url['thumbnail'] = $url_thumbnail;
471 543
 					$image_url['original'] = $url;
472
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
473
-					else $exifCopyright = '';
474
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
475
-					else $image_url['copyright'] = $source['copyright'];
544
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
545
+						$exifCopyright = $this->getExifCopyright($url);
546
+					} else {
547
+						$exifCopyright = '';
548
+					}
549
+					if ($exifCopyright  != '') {
550
+						$image_url['copyright'] = $exifCopyright;
551
+					} else {
552
+						$image_url['copyright'] = $source['copyright'];
553
+					}
476 554
 					$image_url['source_website'] = $source['source_website'];
477 555
 					$image_url['source'] = $source['source'];
478 556
 					return $image_url;
479 557
 				}
480 558
 			}
481 559
 			return false;
482
-		} else return false;
560
+		} else {
561
+			return false;
562
+		}
483 563
 	}
484 564
 }
485 565
 
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 	* @return Array the images list
18 18
 	*
19 19
 	*/
20
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
20
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
21 21
 	{
22
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
22
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
23
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
24
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
25 25
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
26 26
 		$registration = trim($registration);
27
-		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
27
+		$query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
28 28
 			FROM spotter_image 
29 29
 			WHERE spotter_image.registration = :registration";
30 30
 		$sth = $this->db->prepare($query);
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
64 64
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
65 65
 		if ($copyright != '') {
66
-			$copyright = str_replace('Copyright ','',$copyright);
67
-			$copyright = str_replace('© ','',$copyright);
68
-			$copyright = str_replace('(c) ','',$copyright);
66
+			$copyright = str_replace('Copyright ', '', $copyright);
67
+			$copyright = str_replace('© ', '', $copyright);
68
+			$copyright = str_replace('(c) ', '', $copyright);
69 69
 		}
70 70
 		return $copyright;
71 71
 	}
@@ -76,26 +76,26 @@  discard block
 block discarded – undo
76 76
 	* @return String either success or error
77 77
 	*
78 78
 	*/
79
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
79
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
80 80
 	{
81
-		global $globalDebug,$globalAircraftImageFetch;
81
+		global $globalDebug, $globalAircraftImageFetch;
82 82
 		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
83
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
83
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
84 84
 		$registration = trim($registration);
85 85
 		//getting the aircraft image
86 86
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
87 87
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
88 88
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
89 89
 		else return "success";
90
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
90
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
91 91
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
92 92
 		if ($image_url['original'] != '') {
93 93
 			if ($globalDebug) echo 'Found !'."\n";
94
-			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
94
+			$query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
95 95
 			try {
96 96
 				$sth = $this->db->prepare($query);
97
-				$sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
98
-			} catch(PDOException $e) {
97
+				$sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
98
+			} catch (PDOException $e) {
99 99
 				echo $e->getMessage()."\n";
100 100
 				return "error";
101 101
 			}
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 		global $globalAircraftImageSources, $globalIVAO;
116 116
 		$Spotter = new Spotter($this->db);
117 117
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
118
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
118
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
119 119
 		if ($aircraft_registration != '') {
120
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
120
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
121 121
 			$aircraft_registration = urlencode(trim($aircraft_registration));
122 122
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
123 123
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -129,23 +129,23 @@  discard block
 block discarded – undo
129 129
 		} elseif ($aircraft_icao != '') {
130 130
 			$aircraft_registration = $aircraft_icao;
131 131
 			$aircraft_name = '';
132
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
133
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
132
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
133
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
134 134
 		foreach ($globalAircraftImageSources as $source) {
135 135
 			$source = strtolower($source);
136
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
137
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
138
-			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
139
-			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name);
140
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
141
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
142
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
143
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
144
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
145
-			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
136
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao, $airline_icao);
137
+			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration, $aircraft_name);
138
+			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration, $aircraft_name);
139
+			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration, $aircraft_name);
140
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration, $aircraft_name);
141
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration, $aircraft_name);
142
+			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration, $aircraft_name);
143
+			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration, $aircraft_name);
144
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration, $aircraft_name);
145
+			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration, $aircraft_name);
146 146
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
147 147
 		}
148
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
148
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
149 149
 	}
150 150
 
151 151
 	/**
@@ -156,24 +156,24 @@  discard block
 block discarded – undo
156 156
 	* @return Array the aircraft thumbnail, orignal url and copyright
157 157
 	*
158 158
 	*/
159
-	public function fromPlanespotters($aircraft_registration, $aircraft_name='') {
159
+	public function fromPlanespotters($aircraft_registration, $aircraft_name = '') {
160 160
 		$Common = new Common();
161 161
 		// If aircraft registration is only number, also check with aircraft model
162
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
163
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
162
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
163
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
164 164
 		} else {
165 165
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
166
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
166
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
167 167
 		}
168 168
 		$data = $Common->getData($url);
169 169
 		if ($xml = simplexml_load_string($data)) {
170 170
 			if (isset($xml->channel->item)) {
171 171
 				$image_url = array();
172
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
172
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
173 173
 				$image_url['thumbnail'] = $thumbnail_url;
174
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
175
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
176
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
174
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
175
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
176
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
177 177
 				$image_url['source'] = 'planespotters';
178 178
 				return $image_url;
179 179
 			}
@@ -189,25 +189,25 @@  discard block
 block discarded – undo
189 189
 	* @return Array the aircraft thumbnail, orignal url and copyright
190 190
 	*
191 191
 	*/
192
-	public function fromDeviantart($aircraft_registration, $aircraft_name='') {
192
+	public function fromDeviantart($aircraft_registration, $aircraft_name = '') {
193 193
 		$Common = new Common();
194 194
 		// If aircraft registration is only number, also check with aircraft model
195
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
196
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
195
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
196
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
197 197
 		} else {
198
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
198
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
199 199
 		}
200 200
 
201 201
 		$data = $Common->getData($url);
202 202
 		if ($xml = simplexml_load_string($data)) {
203 203
 			if (isset($xml->channel->item->link)) {
204 204
 				$image_url = array();
205
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
205
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
206 206
 				$image_url['thumbnail'] = $thumbnail_url;
207
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
207
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
208 208
 				$image_url['original'] = $original_url;
209
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
210
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
209
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
210
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
211 211
 				$image_url['source'] = 'deviantart';
212 212
 				return $image_url;
213 213
 			}
@@ -223,32 +223,32 @@  discard block
 block discarded – undo
223 223
 	* @return Array the aircraft thumbnail, orignal url and copyright
224 224
 	*
225 225
 	*/
226
-	public function fromJetPhotos($aircraft_registration, $aircraft_name='') {
226
+	public function fromJetPhotos($aircraft_registration, $aircraft_name = '') {
227 227
 		$Common = new Common();
228
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
228
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
229 229
 		$data = $Common->getData($url);
230 230
 		$dom = new DOMDocument();
231 231
 		@$dom->loadHTML($data);
232 232
 		$all_pics = array();
233
-		foreach($dom->getElementsByTagName('img') as $image) {
233
+		foreach ($dom->getElementsByTagName('img') as $image) {
234 234
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
235 235
 				$all_pics[] = $image->getAttribute('src');
236 236
 			}
237 237
 		}
238 238
 		$all_authors = array();
239
-		foreach($dom->getElementsByTagName('meta') as $author) {
239
+		foreach ($dom->getElementsByTagName('meta') as $author) {
240 240
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
241 241
 				$all_authors[] = $author->getAttribute('content');
242 242
 			}
243 243
 		}
244 244
 		$all_ref = array();
245
-		foreach($dom->getElementsByTagName('a') as $link) {
245
+		foreach ($dom->getElementsByTagName('a') as $link) {
246 246
 			$all_ref[] = $link->getAttribute('href');
247 247
 		}
248 248
 		if (isset($all_pics[0])) {
249 249
 			$image_url = array();
250 250
 			$image_url['thumbnail'] = $all_pics[0];
251
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
251
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
252 252
 			$image_url['copyright'] = $all_authors[0];
253 253
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
254 254
 			$image_url['source'] = 'JetPhotos';
@@ -265,24 +265,24 @@  discard block
 block discarded – undo
265 265
 	* @return Array the aircraft thumbnail, orignal url and copyright
266 266
 	*
267 267
 	*/
268
-	public function fromPlanePictures($aircraft_registration, $aircraft_name='') {
268
+	public function fromPlanePictures($aircraft_registration, $aircraft_name = '') {
269 269
 		$Common = new Common();
270
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
270
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
271 271
 		$data = $Common->getData($url);
272 272
 		$dom = new DOMDocument();
273 273
 		@$dom->loadHTML($data);
274 274
 		$all_pics = array();
275
-		foreach($dom->getElementsByTagName('img') as $image) {
275
+		foreach ($dom->getElementsByTagName('img') as $image) {
276 276
 			$all_pics[] = $image->getAttribute('src');
277 277
 		}
278 278
 		$all_links = array();
279
-		foreach($dom->getElementsByTagName('a') as $link) {
280
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
279
+		foreach ($dom->getElementsByTagName('a') as $link) {
280
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
281 281
 		}
282
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1])) {
282
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1])) {
283 283
 			$image_url = array();
284 284
 			$image_url['thumbnail'] = 'http://www.planepictures.net'.$all_pics[1];
285
-			$image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN','',$all_pics[1]);
285
+			$image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN', '', $all_pics[1]);
286 286
 			$image_url['copyright'] = $all_links[6]['text'];
287 287
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
288 288
 			$image_url['source'] = 'PlanePictures';
@@ -299,19 +299,19 @@  discard block
 block discarded – undo
299 299
 	* @return Array the aircraft thumbnail, orignal url and copyright
300 300
 	*
301 301
 	*/
302
-	public function fromFlickr($aircraft_registration,$aircraft_name='') {
302
+	public function fromFlickr($aircraft_registration, $aircraft_name = '') {
303 303
 		$Common = new Common();
304 304
 		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
305 305
 		else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
306 306
 		$data = $Common->getData($url);
307 307
 		if ($xml = simplexml_load_string($data)) {
308 308
 			if (isset($xml->channel->item)) {
309
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
309
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
310 310
 				$image_url = array();
311 311
 				$image_url['thumbnail'] = $original_url;
312 312
 				$image_url['original'] = $original_url;
313
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
314
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
313
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
314
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
315 315
 				$image_url['source'] = 'flickr';
316 316
 				return $image_url;
317 317
 			}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		return false;
320 320
 	}
321 321
 
322
-	public function fromIvaoMtl($aircraft_icao,$airline_icao) {
322
+	public function fromIvaoMtl($aircraft_icao, $airline_icao) {
323 323
 		$Common = new Common();
324 324
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
325 325
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
 	* @return Array the aircraft thumbnail, orignal url and copyright
344 344
 	*
345 345
 	*/
346
-	public function fromBing($aircraft_registration,$aircraft_name='') {
346
+	public function fromBing($aircraft_registration, $aircraft_name = '') {
347 347
 		global $globalImageBingKey;
348 348
 		$Common = new Common();
349 349
 		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
350 350
 		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
351 351
 		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
352
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
353
-		$data = $Common->getData($url,'get','',$headers);
352
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
353
+		$data = $Common->getData($url, 'get', '', $headers);
354 354
 		$result = json_decode($data);
355 355
 		if (isset($result->d->results[0]->MediaUrl)) {
356 356
 			$image_url = array();
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
 	* @return Array the aircraft thumbnail, orignal url and copyright
376 376
 	*
377 377
 	*/
378
-	public function fromAirportData($aircraft_registration,$aircraft_name='') {
378
+	public function fromAirportData($aircraft_registration, $aircraft_name = '') {
379 379
 		$Common = new Common();
380 380
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
381 381
 		$data = $Common->getData($url);
382 382
 		$result = json_decode($data);
383 383
 		if (isset($result->count) && $result->count > 0) {
384 384
 			$image_url = array();
385
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
385
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
386 386
 			$image_url['source_website'] = $result->data[0]->link;
387 387
 			$image_url['thumbnail'] = $result->data[0]->image;
388 388
 			$image_url['copyright'] = $result->data[0]->photographer;
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	* @return Array the aircraft thumbnail, orignal url and copyright
401 401
 	*
402 402
 	*/
403
-	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
403
+	public function fromWikimedia($aircraft_registration, $aircraft_name = '') {
404 404
 		$Common = new Common();
405 405
 		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
406 406
 		else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 		$result = json_decode($data);
409 409
 		if (isset($result->query->search[0]->title)) {
410 410
 			$fileo = $result->query->search[0]->title;
411
-			if (substr($fileo,-3) == 'pdf') return false;
411
+			if (substr($fileo, -3) == 'pdf') return false;
412 412
 			$file = urlencode($fileo);
413 413
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
414 414
 			$data2 = $Common->getData($url2);
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
 				if (isset($result2->query->pages)) {
434 434
 					foreach ($result2->query->pages as $page) {
435 435
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
436
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
436
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
437 437
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
438 438
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
439 439
 							}
440
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
440
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
441 441
 							return $image_url;
442 442
 						}
443 443
 					}
@@ -456,22 +456,22 @@  discard block
 block discarded – undo
456 456
 	* @return Array the aircraft thumbnail, orignal url and copyright
457 457
 	*
458 458
 	*/
459
-	public function fromCustomSource($aircraft_registration,$aircraft_name='') {
459
+	public function fromCustomSource($aircraft_registration, $aircraft_name = '') {
460 460
 		global $globalAircraftImageCustomSources;
461 461
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
462 462
 		if (!empty($globalAircraftImageCustomSources)) {
463 463
 			if (!isset($globalAircraftImageCustomSources[0])) $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources;
464 464
 			foreach ($globalAircraftImageCustomSources as $source) {
465 465
 				$Common = new Common();
466
-				$url = str_replace('{registration}',$aircraft_registration,$source['original']);
467
-				$url_thumbnail = str_replace('{registration}',$aircraft_registration,$source['original']);
466
+				$url = str_replace('{registration}', $aircraft_registration, $source['original']);
467
+				$url_thumbnail = str_replace('{registration}', $aircraft_registration, $source['original']);
468 468
 				if ($Common->urlexist($url)) {
469 469
 					$image_url = array();
470 470
 					$image_url['thumbnail'] = $url_thumbnail;
471 471
 					$image_url['original'] = $url;
472 472
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
473 473
 					else $exifCopyright = '';
474
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
474
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
475 475
 					else $image_url['copyright'] = $source['copyright'];
476 476
 					$image_url['source_website'] = $source['source_website'];
477 477
 					$image_url['source'] = $source['source'];
Please login to merge, or discard this patch.
require/class.METAR.php 3 patches
Braces   +94 added lines, -36 removed lines patch added patch discarded remove patch
@@ -58,8 +58,11 @@  discard block
 block discarded – undo
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
61
-                if ($row['nb'] > 0) return false;
62
-                else return true;
61
+                if ($row['nb'] > 0) {
62
+                	return false;
63
+                } else {
64
+                	return true;
65
+                }
63 66
         }
64 67
 
65 68
         public static function insert_last_update() {
@@ -83,9 +86,14 @@  discard block
 block discarded – undo
83 86
     		//$pieces = explode(' ',$data);
84 87
     		$pieces = preg_split('/\s/',$data);
85 88
     		$pos = 0;
86
-    		if ($pieces[0] == 'METAR') $pos++;
87
-    		elseif ($pieces[0] == 'SPECI') $pos++;
88
-    		if (strlen($pieces[$pos]) != 4) $pos++;
89
+    		if ($pieces[0] == 'METAR') {
90
+    			$pos++;
91
+    		} elseif ($pieces[0] == 'SPECI') {
92
+    			$pos++;
93
+    		}
94
+    		if (strlen($pieces[$pos]) != 4) {
95
+    			$pos++;
96
+    		}
89 97
     		$result = array();
90 98
     		$result['location'] = $pieces[$pos];
91 99
     		$pos++;
@@ -94,16 +102,26 @@  discard block
 block discarded – undo
94 102
     		$c = count($pieces);
95 103
     		for($pos++; $pos < $c; $pos++) {
96 104
     			$piece = $pieces[$pos];
97
-    			if ($piece == 'RMK') break;
98
-    			if ($piece == 'AUTO') $result['auto'] = true;
99
-    			if ($piece == 'COR') $result['correction'] = true;
105
+    			if ($piece == 'RMK') {
106
+    				break;
107
+    			}
108
+    			if ($piece == 'AUTO') {
109
+    				$result['auto'] = true;
110
+    			}
111
+    			if ($piece == 'COR') {
112
+    				$result['correction'] = true;
113
+    			}
100 114
     			// Wind Speed
101 115
     			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 116
     				$result['wind']['direction'] = (float)$matches[1];
103 117
 				$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);
118
+    				if ($result['wind']['unit'] == 'KT') {
119
+    					$result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
120
+    				} elseif ($result['wind']['unit'] == 'KPH') {
121
+    					$result['wind']['speed'] = round(((float)$matches[2])*1000,2);
122
+    				} elseif ($result['wind']['unit'] == 'MPS') {
123
+    					$result['wind']['speed'] = round(((float)$matches[2]),2);
124
+    				}
107 125
 				$result['wind']['gust'] = (float)$matches[3];
108 126
 				$result['wind']['unit'] = $matches[4];
109 127
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
@@ -185,14 +203,23 @@  discard block
 block discarded – undo
185 203
     				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
186 204
     				$type = $matches[1];
187 205
     				$cloud = array();
188
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
189
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
190
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
191
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
192
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
193
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
194
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
195
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
206
+    				if ($type == 'SKC') {
207
+    					$cloud['type'] = 'No cloud/Sky clear';
208
+    				} elseif ($type == 'CLR') {
209
+    					$cloud['type'] = 'No cloud below 12,000ft (3700m)';
210
+    				} elseif ($type == 'NSC') {
211
+    					$cloud['type'] = 'No significant cloud';
212
+    				} elseif ($type == 'FEW') {
213
+    					$cloud['type'] = 'Few';
214
+    				} elseif ($type == 'SCT') {
215
+    					$cloud['type'] = 'Scattered';
216
+    				} elseif ($type == 'BKN') {
217
+    					$cloud['type'] = 'Broken';
218
+    				} elseif ($type == 'OVC') {
219
+    					$cloud['type'] = 'Overcast/Full cloud coverage';
220
+    				} elseif ($type == 'VV') {
221
+    					$cloud['type'] = 'Vertical visibility';
222
+    				}
196 223
     				$cloud['type_code'] = $type;
197 224
     				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
198 225
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
@@ -222,8 +249,11 @@  discard block
 block discarded – undo
222 249
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
223 250
     				//echo $piece;
224 251
     				//print_r($matches);
225
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
226
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
252
+    				if (isset($matches[5])) {
253
+    					$range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
254
+    				} else {
255
+    					$range = array('exact' => (float)$matches[2], 'unit' => 'M');
256
+    				}
227 257
 				if (isset($matches[3])) {
228 258
 					$range = Array(
229 259
 					    'from' => (float)$matches[2],
@@ -256,8 +286,11 @@  discard block
 block discarded – undo
256 286
 				if (isset($matches[3])) {
257 287
 					$text[] = $this->texts[$matches[3]];
258 288
 				}
259
-				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
260
-				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
289
+				if (!isset($result['weather'])) {
290
+					$result['weather'] = implode(' ', $text);
291
+				} else {
292
+					$result['weather'] = $result['weather'].' / '.implode(' ', $text);
293
+				}
261 294
     			}
262 295
     		}
263 296
     		return $result;
@@ -269,8 +302,11 @@  discard block
 block discarded – undo
269 302
     		if (isset($globalMETARcycle) && $globalMETARcycle) {
270 303
             		$query = "SELECT * FROM metar WHERE metar_location = :icao";
271 304
                 } else {
272
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
273
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
305
+            		if ($globalDBdriver == 'mysql') {
306
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
307
+            		} else {
308
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
309
+            		}
274 310
                 }
275 311
                 $query_values = array(':icao' => $icao);
276 312
                  try {
@@ -325,7 +361,9 @@  discard block
 block discarded – undo
325 361
         
326 362
         public function addMETARCycle() {
327 363
     		global $globalDebug, $globalIVAO;
328
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
364
+    		if (isset($globalDebug) && $globalDebug) {
365
+    			echo "Downloading METAR cycle...";
366
+    		}
329 367
     		date_default_timezone_set("UTC");
330 368
     		$Common = new Common();
331 369
     		if (isset($globalIVAO) && $globalIVAO) {
@@ -333,7 +371,9 @@  discard block
 block discarded – undo
333 371
     		} else {
334 372
 			$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
335 373
     		}
336
-    		if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
374
+    		if (isset($globalDebug) && $globalDebug) {
375
+    			echo "Done - Updating DB...";
376
+    		}
337 377
     		$date = '';
338 378
     		foreach(explode("\n",$cycle) as $line) {
339 379
     			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
@@ -342,22 +382,32 @@  discard block
 block discarded – undo
342 382
     			} elseif ($line != '') {
343 383
     			    //$this->parse($line);
344 384
     			    //echo $line;
345
-    			    if ($date == '') $date = date('Y/m/d H:m');
385
+    			    if ($date == '') {
386
+    			    	$date = date('Y/m/d H:m');
387
+    			    }
346 388
     			    $pos = 0;
347 389
     			    $pieces = preg_split('/\s/',$line);
348
-    			    if ($pieces[0] == 'METAR') $pos++;
349
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
390
+    			    if ($pieces[0] == 'METAR') {
391
+    			    	$pos++;
392
+    			    }
393
+    			    if (strlen($pieces[$pos]) != 4) {
394
+    			    	$pos++;
395
+    			    }
350 396
 	        	    $location = $pieces[$pos];
351 397
 	        	    echo $this->addMETAR($location,$line,$date);
352 398
     			}
353 399
     			//echo $line."\n";
354 400
     		}
355
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
401
+    		if (isset($globalDebug) && $globalDebug) {
402
+    			echo "Done\n";
403
+    		}
356 404
         
357 405
         }
358 406
         public function downloadMETAR($icao) {
359 407
     		global $globalMETARurl;
360
-    		if ($globalMETARurl == '') return array();
408
+    		if ($globalMETARurl == '') {
409
+    			return array();
410
+    		}
361 411
     		date_default_timezone_set("UTC");
362 412
     		$Common = new Common();
363 413
     		$url = str_replace('{icao}',$icao,$globalMETARurl);
@@ -370,16 +420,24 @@  discard block
 block discarded – undo
370 420
     			} elseif ($line != '') {
371 421
     			    //$this->parse($line);
372 422
     			    //echo $line;
373
-    			    if ($date == '') $date = date('Y/m/d H:m');
423
+    			    if ($date == '') {
424
+    			    	$date = date('Y/m/d H:m');
425
+    			    }
374 426
     			    $pos = 0;
375 427
     			    $pieces = preg_split('/\s/',$line);
376
-    			    if ($pieces[0] == 'METAR') $pos++;
377
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
428
+    			    if ($pieces[0] == 'METAR') {
429
+    			    	$pos++;
430
+    			    }
431
+    			    if (strlen($pieces[$pos]) != 4) {
432
+    			    	$pos++;
433
+    			    }
378 434
 	        	    $location = $pieces[$pos];
379 435
 	        	    if (strlen($location == 4)) {
380 436
 	        		$this->addMETAR($location,$line,$date);
381 437
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
382
-	        	    } else return array();
438
+	        	    } else {
439
+	        	    	return array();
440
+	        	    }
383 441
     			}
384 442
     			//echo $line."\n";
385 443
     		}
Please login to merge, or discard this patch.
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -7,109 +7,109 @@  discard block
 block discarded – undo
7 7
 	public $db;
8 8
 	
9 9
 	protected $texts = Array(
10
-	    'MI' => 'Shallow',
11
-	    'PR' => 'Partial',
12
-	    'BC' => 'Low drifting',
13
-	    'BL' => 'Blowing',
14
-	    'SH' => 'Showers',
15
-	    'TS' => 'Thunderstorm',
16
-	    'FZ' => 'Freezing',
17
-	    'DZ' => 'Drizzle',
18
-	    'RA' => 'Rain',
19
-	    'SN' => 'Snow',
20
-	    'SG' => 'Snow Grains',
21
-	    'IC' => 'Ice crystals',
22
-	    'PL' => 'Ice pellets',
23
-	    'GR' => 'Hail',
24
-	    'GS' => 'Small hail',
25
-	    'UP' => 'Unknown',
26
-	    'BR' => 'Mist',
27
-	    'FG' => 'Fog',
28
-	    'FU' => 'Smoke',
29
-	    'VA' => 'Volcanic ash',
30
-	    'DU' => 'Widespread dust',
31
-	    'SA' => 'Sand',
32
-	    'HZ' => 'Haze',
33
-	    'PY' => 'Spray',
34
-	    'PO' => 'Well developed dust / sand whirls',
35
-	    'SQ' => 'Squalls',
36
-	    'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
-	    'SS' => 'Sandstorm',
38
-	    'DS' => 'Duststorm'
10
+		'MI' => 'Shallow',
11
+		'PR' => 'Partial',
12
+		'BC' => 'Low drifting',
13
+		'BL' => 'Blowing',
14
+		'SH' => 'Showers',
15
+		'TS' => 'Thunderstorm',
16
+		'FZ' => 'Freezing',
17
+		'DZ' => 'Drizzle',
18
+		'RA' => 'Rain',
19
+		'SN' => 'Snow',
20
+		'SG' => 'Snow Grains',
21
+		'IC' => 'Ice crystals',
22
+		'PL' => 'Ice pellets',
23
+		'GR' => 'Hail',
24
+		'GS' => 'Small hail',
25
+		'UP' => 'Unknown',
26
+		'BR' => 'Mist',
27
+		'FG' => 'Fog',
28
+		'FU' => 'Smoke',
29
+		'VA' => 'Volcanic ash',
30
+		'DU' => 'Widespread dust',
31
+		'SA' => 'Sand',
32
+		'HZ' => 'Haze',
33
+		'PY' => 'Spray',
34
+		'PO' => 'Well developed dust / sand whirls',
35
+		'SQ' => 'Squalls',
36
+		'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
+		'SS' => 'Sandstorm',
38
+		'DS' => 'Duststorm'
39 39
 	);
40 40
 	
41 41
 	public function __construct($dbc = null) {
42
-                $Connection = new Connection($dbc);
43
-                $this->db = $Connection->db;
44
-        }
42
+				$Connection = new Connection($dbc);
43
+				$this->db = $Connection->db;
44
+		}
45 45
 
46
-       public static function check_last_update() {
47
-    		global $globalDBdriver;
48
-    		if ($globalDBdriver == 'mysql') {
46
+	   public static function check_last_update() {
47
+			global $globalDBdriver;
48
+			if ($globalDBdriver == 'mysql') {
49 49
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(NOW(), INTERVAL 20 MINUTE)";
50 50
 		} else {
51 51
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '20 MINUTES'";
52 52
 		}
53
-                try {
54
-                        $Connection = new Connection();
55
-                        $sth = $Connection->db->prepare($query);
56
-                        $sth->execute();
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
61
-                $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
64
-        }
53
+				try {
54
+						$Connection = new Connection();
55
+						$sth = $Connection->db->prepare($query);
56
+						$sth->execute();
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
61
+				$sth->closeCursor();
62
+				if ($row['nb'] > 0) return false;
63
+				else return true;
64
+		}
65 65
 
66
-        public static function insert_last_update() {
67
-                $query = "DELETE FROM config WHERE name = 'last_update_metar';
66
+		public static function insert_last_update() {
67
+				$query = "DELETE FROM config WHERE name = 'last_update_metar';
68 68
                         INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());";
69
-                try {
70
-                        $Connection = new Connection();
71
-                        $sth = $Connection->db->prepare($query);
72
-                        $sth->execute();
73
-                } catch(PDOException $e) {
74
-                        return "error : ".$e->getMessage();
75
-                }
76
-        }
69
+				try {
70
+						$Connection = new Connection();
71
+						$sth = $Connection->db->prepare($query);
72
+						$sth->execute();
73
+				} catch(PDOException $e) {
74
+						return "error : ".$e->getMessage();
75
+				}
76
+		}
77 77
 
78 78
 
79 79
         
80
-        public function parse($data) {
81
-    		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
-    		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
-    		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
86
-    		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
-    		$result = array();
91
-    		$result['location'] = $pieces[$pos];
92
-    		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
95
-    		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
97
-    			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
101
-    			// Wind Speed
102
-    			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
80
+		public function parse($data) {
81
+			//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
+			$codes = implode('|', array_keys($this->texts));
83
+			$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
+			//$pieces = explode(' ',$data);
85
+			$pieces = preg_split('/\s/',$data);
86
+			$pos = 0;
87
+			if ($pieces[0] == 'METAR') $pos++;
88
+			elseif ($pieces[0] == 'SPECI') $pos++;
89
+			if (strlen($pieces[$pos]) != 4) $pos++;
90
+			$result = array();
91
+			$result['location'] = $pieces[$pos];
92
+			$pos++;
93
+			$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
+			$result['time'] = substr($pieces[$pos],2,4);
95
+			$c = count($pieces);
96
+			for($pos++; $pos < $c; $pos++) {
97
+				$piece = $pieces[$pos];
98
+				if ($piece == 'RMK') break;
99
+				if ($piece == 'AUTO') $result['auto'] = true;
100
+				if ($piece == 'COR') $result['correction'] = true;
101
+				// Wind Speed
102
+				if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
+					$result['wind']['direction'] = (float)$matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
105
+					if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
+					elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
+					elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108 108
 				$result['wind']['gust'] = (float)$matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110 110
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111 111
 				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
112
-    			}
112
+				}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
115 115
     				$result['wind_direction'] = (float)$matches[1];
@@ -126,35 +126,35 @@  discard block
 block discarded – undo
126 126
     				}
127 127
     			}
128 128
     			*/
129
-    			// Temperature
130
-    			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
129
+				// Temperature
130
+				if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
+					$temp = (float)$matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133 133
 					$temp = ((float)substr($matches[1], 1)) * -1;
134 134
 				}
135
-    				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
135
+					$result['temperature'] = $temp;
136
+					$dew = (float)$matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138 138
 					$dew = ((float)substr($matches[2], 1)) * -1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141
-    			}
142
-    			// QNH
143
-    			if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
-    			// #^(Q|A)(////|[0-9]{4})( )#
145
-    				if ($matches[1] == 'Q') {
146
-    					// hPa
147
-    					$result['QNH'] = $matches[2];
148
-    				} else {
149
-    					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151 141
 				}
152
-    				/*
142
+				// QNH
143
+				if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
+				// #^(Q|A)(////|[0-9]{4})( )#
145
+					if ($matches[1] == 'Q') {
146
+						// hPa
147
+						$result['QNH'] = $matches[2];
148
+					} else {
149
+						// inHg
150
+						$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151
+				}
152
+					/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
154 154
     				$result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg';
155 155
     				*/
156
-    			}
157
-                     /*
156
+				}
157
+					 /*
158 158
     			// Wind Direction
159 159
     			if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) {
160 160
     				$result['wind_direction'] = $matches[1];
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
     				$result['speed_variable'] = $matches[1];
166 166
     			}
167 167
     			*/
168
-    			// Visibility
169
-    			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
-    				if (isset($matches[3]) && strlen($matches[3]) > 0) {
168
+				// Visibility
169
+				if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
+					if (isset($matches[3]) && strlen($matches[3]) > 0) {
171 171
 					$result['visibility'] = (float)$matches[3] * 1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
@@ -180,28 +180,28 @@  discard block
 block discarded – undo
180 180
 					$result['visibility'] = '> 10000';
181 181
 					$result['weather'] = "CAVOK";
182 182
 				}
183
-    			}
184
-    			// Cloud Coverage
185
-    			if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
-    				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
-    				$type = $matches[1];
188
-    				$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';
197
-    				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
-    				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
-    				$result['cloud'][] = $cloud;
201
-    			}
202
-    			// RVR
203
-    			 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
-    				$rvr = array();
183
+				}
184
+				// Cloud Coverage
185
+				if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
+					//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
+					$type = $matches[1];
188
+					$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';
197
+					$cloud['type_code'] = $type;
198
+					$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
+					$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
+					$result['cloud'][] = $cloud;
201
+				}
202
+				// RVR
203
+				 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
+					$rvr = array();
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
@@ -210,33 +210,33 @@  discard block
 block discarded – undo
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
213
-    			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
-    			if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
-    				//print_r($matches);
216
-    				// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
-    				$result['RVR']['runway'] = $matches[1];
218
-        			$result['RVR']['deposits'] = $matches[2];
219
-        			$result['RVR']['extent'] = $matches[3];
220
-        			$result['RVR']['depth'] = $matches[4];
221
-        			$result['RVR']['friction'] = $matches[5];
222
-    			}
223
-    			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
-    				//echo $piece;
225
-    				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
213
+				//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
+				if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
+					//print_r($matches);
216
+					// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
+					$result['RVR']['runway'] = $matches[1];
218
+					$result['RVR']['deposits'] = $matches[2];
219
+					$result['RVR']['extent'] = $matches[3];
220
+					$result['RVR']['depth'] = $matches[4];
221
+					$result['RVR']['friction'] = $matches[5];
222
+				}
223
+				if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
+					//echo $piece;
225
+					//print_r($matches);
226
+					if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+					else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
232
-					    'unit' => $matches[5] ? 'FT' : 'M'
230
+						'from' => (float)$matches[2],
231
+						'to'   => (float)$matches[4],
232
+						'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
235 235
 				$result['RVR'] = $matches[1];
236 236
 				$result['RVR_range'] = $range;
237
-    			}
238
-    			// Weather
239
-    			if (preg_match($regWeather, $piece, $matches)) {
237
+				}
238
+				// Weather
239
+				if (preg_match($regWeather, $piece, $matches)) {
240 240
 				$text = Array();
241 241
 				switch ($matches[1]) {
242 242
 					case '+':
@@ -259,35 +259,35 @@  discard block
 block discarded – undo
259 259
 				}
260 260
 				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261 261
 				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
262
-    			}
263
-    		}
264
-    		return $result;
262
+				}
263
+			}
264
+			return $result;
265 265
         
266
-        }
266
+		}
267 267
         
268 268
 	public function getMETAR($icao) {
269
-    		global $globalMETARcycle, $globalDBdriver;
270
-    		if (isset($globalMETARcycle) && $globalMETARcycle) {
271
-            		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
-                } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
-                }
276
-                $query_values = array(':icao' => $icao);
277
-                 try {
278
-                        $sth = $this->db->prepare($query);
279
-                        $sth->execute($query_values);
280
-                } catch(PDOException $e) {
281
-                        return "error : ".$e->getMessage();
282
-                }
283
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
-                if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
-            		$all = $this->downloadMETAR($icao);
286
-                }
287
-                return $all;
288
-        }
269
+			global $globalMETARcycle, $globalDBdriver;
270
+			if (isset($globalMETARcycle) && $globalMETARcycle) {
271
+					$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
+				} else {
273
+					if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
+					else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
+				}
276
+				$query_values = array(':icao' => $icao);
277
+				 try {
278
+						$sth = $this->db->prepare($query);
279
+						$sth->execute($query_values);
280
+				} catch(PDOException $e) {
281
+						return "error : ".$e->getMessage();
282
+				}
283
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
+					$all = $this->downloadMETAR($icao);
286
+				}
287
+				return $all;
288
+		}
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+	   public function addMETAR($location,$metar,$date) {
291 291
 		global $globalDBdriver;
292 292
 		$date = date('Y-m-d H:i:s',strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
@@ -295,100 +295,100 @@  discard block
 block discarded – undo
295 295
 		} else {
296 296
 			$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);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
-                 try {
300
-                        $sth = $this->db->prepare($query);
301
-                        $sth->execute($query_values);
302
-                } catch(PDOException $e) {
303
-                        return "error : ".$e->getMessage();
304
-                }
305
-        }
298
+				$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
+				 try {
300
+						$sth = $this->db->prepare($query);
301
+						$sth->execute($query_values);
302
+				} catch(PDOException $e) {
303
+						return "error : ".$e->getMessage();
304
+				}
305
+		}
306 306
 
307
-       public function deleteMETAR($id) {
308
-                $query = "DELETE FROM metar WHERE id = :id";
309
-                $query_values = array(':id' => $id);
310
-                 try {
311
-                        $sth = $this->db->prepare($query);
312
-                        $sth->execute($query_values);
313
-                } catch(PDOException $e) {
314
-                        return "error : ".$e->getMessage();
315
-                }
316
-        }
317
-       public function deleteAllMETARLocation() {
318
-                $query = "DELETE FROM metar";
319
-                 try {
320
-                        $sth = $this->db->prepare($query);
321
-                        $sth->execute();
322
-                } catch(PDOException $e) {
323
-                        return "error : ".$e->getMessage();
324
-                }
325
-        }
307
+	   public function deleteMETAR($id) {
308
+				$query = "DELETE FROM metar WHERE id = :id";
309
+				$query_values = array(':id' => $id);
310
+				 try {
311
+						$sth = $this->db->prepare($query);
312
+						$sth->execute($query_values);
313
+				} catch(PDOException $e) {
314
+						return "error : ".$e->getMessage();
315
+				}
316
+		}
317
+	   public function deleteAllMETARLocation() {
318
+				$query = "DELETE FROM metar";
319
+				 try {
320
+						$sth = $this->db->prepare($query);
321
+						$sth->execute();
322
+				} catch(PDOException $e) {
323
+						return "error : ".$e->getMessage();
324
+				}
325
+		}
326 326
         
327
-        public function addMETARCycle() {
328
-    		global $globalDebug, $globalIVAO;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
-    		date_default_timezone_set("UTC");
331
-    		$Common = new Common();
332
-    		if (isset($globalIVAO) && $globalIVAO) {
333
-        		$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334
-    		} else {
327
+		public function addMETARCycle() {
328
+			global $globalDebug, $globalIVAO;
329
+			if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
+			date_default_timezone_set("UTC");
331
+			$Common = new Common();
332
+			if (isset($globalIVAO) && $globalIVAO) {
333
+				$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334
+			} else {
335 335
 			$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
336
-    		}
337
-    		if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
338
-    		$date = '';
339
-    		foreach(explode("\n",$cycle) as $line) {
340
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
341
-    				//echo "date : ".$line."\n";
342
-    				$date = $line;
343
-    			} 
344
-    			if ($line != '') {
345
-    			    //$this->parse($line);
346
-    			    //echo $line;
347
-    			    if ($date == '') $date = date('Y/m/d H:m');
348
-    			    $pos = 0;
349
-    			    $pieces = preg_split('/\s/',$line);
350
-    			    if ($pieces[0] == 'METAR') $pos++;
351
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
352
-	        	    $location = $pieces[$pos];
353
-	        	    echo $this->addMETAR($location,$line,$date);
354
-    			}
355
-    			//echo $line."\n";
356
-    		}
357
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
336
+			}
337
+			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
338
+			$date = '';
339
+			foreach(explode("\n",$cycle) as $line) {
340
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
341
+					//echo "date : ".$line."\n";
342
+					$date = $line;
343
+				} 
344
+				if ($line != '') {
345
+					//$this->parse($line);
346
+					//echo $line;
347
+					if ($date == '') $date = date('Y/m/d H:m');
348
+					$pos = 0;
349
+					$pieces = preg_split('/\s/',$line);
350
+					if ($pieces[0] == 'METAR') $pos++;
351
+					if (strlen($pieces[$pos]) != 4) $pos++;
352
+					$location = $pieces[$pos];
353
+					echo $this->addMETAR($location,$line,$date);
354
+				}
355
+				//echo $line."\n";
356
+			}
357
+			if (isset($globalDebug) && $globalDebug) echo "Done\n";
358 358
         
359
-        }
360
-        public function downloadMETAR($icao) {
361
-    		global $globalMETARurl;
362
-    		if ($globalMETARurl == '') return array();
363
-    		date_default_timezone_set("UTC");
364
-    		$Common = new Common();
365
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
366
-    		$cycle = $Common->getData($url);
367
-    		$date = '';
368
-    		foreach(explode("\n",$cycle) as $line) {
369
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
370
-    				//echo "date : ".$line."\n";
371
-    				$date = $line;
372
-    			} 
373
-    			if ($line != '') {
374
-    			    //$this->parse($line);
375
-    			    //echo $line;
376
-    			    if ($date == '') $date = date('Y/m/d H:m');
377
-    			    $pos = 0;
378
-    			    $pieces = preg_split('/\s/',$line);
379
-    			    if ($pieces[0] == 'METAR') $pos++;
380
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
381
-	        	    $location = $pieces[$pos];
382
-	        	    if (strlen($location == 4)) {
383
-	        		$this->addMETAR($location,$line,$date);
384
-	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
385
-	        	    } else return array();
386
-    			}
387
-    			//echo $line."\n";
388
-    		}
389
-    		return array();
359
+		}
360
+		public function downloadMETAR($icao) {
361
+			global $globalMETARurl;
362
+			if ($globalMETARurl == '') return array();
363
+			date_default_timezone_set("UTC");
364
+			$Common = new Common();
365
+			$url = str_replace('{icao}',$icao,$globalMETARurl);
366
+			$cycle = $Common->getData($url);
367
+			$date = '';
368
+			foreach(explode("\n",$cycle) as $line) {
369
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
370
+					//echo "date : ".$line."\n";
371
+					$date = $line;
372
+				} 
373
+				if ($line != '') {
374
+					//$this->parse($line);
375
+					//echo $line;
376
+					if ($date == '') $date = date('Y/m/d H:m');
377
+					$pos = 0;
378
+					$pieces = preg_split('/\s/',$line);
379
+					if ($pieces[0] == 'METAR') $pos++;
380
+					if (strlen($pieces[$pos]) != 4) $pos++;
381
+					$location = $pieces[$pos];
382
+					if (strlen($location == 4)) {
383
+					$this->addMETAR($location,$line,$date);
384
+					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
385
+					} else return array();
386
+				}
387
+				//echo $line."\n";
388
+			}
389
+			return array();
390 390
         
391
-        }
391
+		}
392 392
 }
393 393
 /*
394 394
 $METAR = new METAR();
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 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
         }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         public function parse($data) {
81 81
     		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82 82
     		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
83
+    		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
84 84
     		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
85
+    		$pieces = preg_split('/\s/', $data);
86 86
     		$pos = 0;
87 87
     		if ($pieces[0] == 'METAR') $pos++;
88 88
     		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
     		$result = array();
91 91
     		$result['location'] = $pieces[$pos];
92 92
     		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
93
+    		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
94
+    		$result['time'] = substr($pieces[$pos], 2, 4);
95 95
     		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
96
+    		for ($pos++; $pos < $c; $pos++) {
97 97
     			$piece = $pieces[$pos];
98 98
     			if ($piece == 'RMK') break;
99 99
     			if ($piece == 'AUTO') $result['auto'] = true;
100 100
     			if ($piece == 'COR') $result['correction'] = true;
101 101
     			// Wind Speed
102 102
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
103
+    				$result['wind']['direction'] = (float) $matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108
-				$result['wind']['gust'] = (float)$matches[3];
105
+    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
106
+    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
107
+    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
108
+				$result['wind']['gust'] = (float) $matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
110
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
111
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
112 112
     			}
113 113
 
114 114
 /*    			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
     			
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 224
     				//echo $piece;
225 225
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
226
+    				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+    				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
230
+					    'from' => (float) $matches[2],
231
+					    'to'   => (float) $matches[4],
232 232
 					    'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                  try {
278 278
                         $sth = $this->db->prepare($query);
279 279
                         $sth->execute($query_values);
280
-                } catch(PDOException $e) {
280
+                } catch (PDOException $e) {
281 281
                         return "error : ".$e->getMessage();
282 282
                 }
283 283
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -287,19 +287,19 @@  discard block
 block discarded – undo
287 287
                 return $all;
288 288
         }
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+       public function addMETAR($location, $metar, $date) {
291 291
 		global $globalDBdriver;
292
-		$date = date('Y-m-d H:i:s',strtotime($date));
292
+		$date = date('Y-m-d H:i:s', strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
294 294
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
295 295
 		} else {
296 296
 			$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);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
298
+                $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
299 299
                  try {
300 300
                         $sth = $this->db->prepare($query);
301 301
                         $sth->execute($query_values);
302
-                } catch(PDOException $e) {
302
+                } catch (PDOException $e) {
303 303
                         return "error : ".$e->getMessage();
304 304
                 }
305 305
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
                  try {
311 311
                         $sth = $this->db->prepare($query);
312 312
                         $sth->execute($query_values);
313
-                } catch(PDOException $e) {
313
+                } catch (PDOException $e) {
314 314
                         return "error : ".$e->getMessage();
315 315
                 }
316 316
         }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                  try {
320 320
                         $sth = $this->db->prepare($query);
321 321
                         $sth->execute();
322
-                } catch(PDOException $e) {
322
+                } catch (PDOException $e) {
323 323
                         return "error : ".$e->getMessage();
324 324
                 }
325 325
         }
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
     		}
337 337
     		if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
338 338
     		$date = '';
339
-    		foreach(explode("\n",$cycle) as $line) {
340
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
339
+    		foreach (explode("\n", $cycle) as $line) {
340
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
341 341
     				//echo "date : ".$line."\n";
342 342
     				$date = $line;
343 343
     			} 
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
     			    //echo $line;
347 347
     			    if ($date == '') $date = date('Y/m/d H:m');
348 348
     			    $pos = 0;
349
-    			    $pieces = preg_split('/\s/',$line);
349
+    			    $pieces = preg_split('/\s/', $line);
350 350
     			    if ($pieces[0] == 'METAR') $pos++;
351 351
     			    if (strlen($pieces[$pos]) != 4) $pos++;
352 352
 	        	    $location = $pieces[$pos];
353
-	        	    echo $this->addMETAR($location,$line,$date);
353
+	        	    echo $this->addMETAR($location, $line, $date);
354 354
     			}
355 355
     			//echo $line."\n";
356 356
     		}
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
     		if ($globalMETARurl == '') return array();
363 363
     		date_default_timezone_set("UTC");
364 364
     		$Common = new Common();
365
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
365
+    		$url = str_replace('{icao}', $icao, $globalMETARurl);
366 366
     		$cycle = $Common->getData($url);
367 367
     		$date = '';
368
-    		foreach(explode("\n",$cycle) as $line) {
369
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
368
+    		foreach (explode("\n", $cycle) as $line) {
369
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
370 370
     				//echo "date : ".$line."\n";
371 371
     				$date = $line;
372 372
     			} 
@@ -375,12 +375,12 @@  discard block
 block discarded – undo
375 375
     			    //echo $line;
376 376
     			    if ($date == '') $date = date('Y/m/d H:m');
377 377
     			    $pos = 0;
378
-    			    $pieces = preg_split('/\s/',$line);
378
+    			    $pieces = preg_split('/\s/', $line);
379 379
     			    if ($pieces[0] == 'METAR') $pos++;
380 380
     			    if (strlen($pieces[$pos]) != 4) $pos++;
381 381
 	        	    $location = $pieces[$pos];
382 382
 	        	    if (strlen($location == 4)) {
383
-	        		$this->addMETAR($location,$line,$date);
383
+	        		$this->addMETAR($location, $line, $date);
384 384
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
385 385
 	        	    } else return array();
386 386
     			}
Please login to merge, or discard this patch.
require/class.Scheduler.php 3 patches
Braces   +164 added lines, -56 removed lines patch added patch discarded remove patch
@@ -122,7 +122,9 @@  discard block
 block discarded – undo
122 122
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
123 123
 		if (count($row) > 0) {
124 124
 			return $row;
125
-		} else return array();
125
+		} else {
126
+			return array();
127
+		}
126 128
 	}
127 129
 
128 130
 	public function checkSchedule($ident) {
@@ -157,7 +159,9 @@  discard block
 block discarded – undo
157 159
 		$Common = new Common();
158 160
 		$check_date = new Datetime($date);
159 161
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
160
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
162
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
163
+			return array();
164
+		}
161 165
 		$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');
162 166
 		$json = $Common->getData($url);
163 167
 	
@@ -184,7 +188,9 @@  discard block
 block discarded – undo
184 188
 			*/
185 189
 		
186 190
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
187
-		} else return array();
191
+		} else {
192
+			return array();
193
+		}
188 194
 	}
189 195
 
190 196
 	/**
@@ -199,7 +205,9 @@  discard block
 block discarded – undo
199 205
 		date_default_timezone_set($globalTimezone);
200 206
 		$check_date = new Datetime($date);
201 207
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
202
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
208
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
209
+			return array();
210
+		}
203 211
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
204 212
 		$json = $Common->getData($url);
205 213
 		$parsed_json = json_decode($json);
@@ -212,7 +220,9 @@  discard block
 block discarded – undo
212 220
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
213 221
 
214 222
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
215
-		} else return array();
223
+		} else {
224
+			return array();
225
+		}
216 226
 	}
217 227
 
218 228
 	/**
@@ -223,7 +233,9 @@  discard block
 block discarded – undo
223 233
 	private function getRyanair($callsign) {
224 234
 		$Common = new Common();
225 235
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
226
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
236
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
237
+			return array();
238
+		}
227 239
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
228 240
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
229 241
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -237,8 +249,12 @@  discard block
 block discarded – undo
237 249
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
238 250
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
239 251
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
240
-			} else return array();
241
-		} else return array();
252
+			} else {
253
+				return array();
254
+			}
255
+		} else {
256
+			return array();
257
+		}
242 258
 	}
243 259
 
244 260
 	/**
@@ -249,7 +265,9 @@  discard block
 block discarded – undo
249 265
 	private function getSwiss($callsign) {
250 266
 		$Common = new Common();
251 267
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
252
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
268
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
269
+			return array();
270
+		}
253 271
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
254 272
 		$json = $Common->getData($url);
255 273
 		$parsed_json = json_decode($json);
@@ -269,8 +287,12 @@  discard block
 block discarded – undo
269 287
 			}
270 288
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
271 289
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
272
-			} else return array();
273
-		} else return array();
290
+			} else {
291
+				return array();
292
+			}
293
+		} else {
294
+			return array();
295
+		}
274 296
 	}
275 297
 	
276 298
 	/**
@@ -284,12 +306,18 @@  discard block
 block discarded – undo
284 306
 		$Common = new Common();
285 307
 		$check_date = new Datetime($date);
286 308
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
287
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
288
-		if ($globalBritishAirwaysKey == '') return array();
309
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
310
+			return array();
311
+		}
312
+		if ($globalBritishAirwaysKey == '') {
313
+			return array();
314
+		}
289 315
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
290 316
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
291 317
 		$json = $Common->getData($url,'get','',$headers);
292
-		if ($json == '') return array();
318
+		if ($json == '') {
319
+			return array();
320
+		}
293 321
 		$parsed_json = json_decode($json);
294 322
 		$flights = $parsed_json->{'FlightsResponse'};
295 323
 		if (count($flights) > 0) {
@@ -298,7 +326,9 @@  discard block
 block discarded – undo
298 326
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
299 327
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
300 328
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
301
-		} else return array();
329
+		} else {
330
+			return array();
331
+		}
302 332
 	}
303 333
 
304 334
 	/**
@@ -312,19 +342,27 @@  discard block
 block discarded – undo
312 342
 		$Common = new Common();
313 343
 		$check_date = new Datetime($date);
314 344
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
315
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
316
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
345
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
346
+			return array();
347
+		}
348
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
349
+			return array();
350
+		}
317 351
 		$url = "https://api.lufthansa.com/v1/oauth/token";
318 352
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
319 353
 		$data = $Common->getData($url,'post',$post);
320 354
 		$parsed_data = json_decode($data);
321
-		if (!isset($parsed_data->{'access_token'})) return array();
355
+		if (!isset($parsed_data->{'access_token'})) {
356
+			return array();
357
+		}
322 358
 		$token = $parsed_data->{'access_token'};
323 359
 		
324 360
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
325 361
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
326 362
 		$json = $Common->getData($url,'get','',$headers);
327
-		if ($json == '') return array();
363
+		if ($json == '') {
364
+			return array();
365
+		}
328 366
 		$parsed_json = json_decode($json);
329 367
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
330 368
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -332,7 +370,9 @@  discard block
 block discarded – undo
332 370
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
333 371
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
334 372
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
335
-		} else return array();
373
+		} else {
374
+			return array();
375
+		}
336 376
 	}
337 377
 
338 378
 	/**
@@ -346,14 +386,20 @@  discard block
 block discarded – undo
346 386
 		$Common = new Common();
347 387
 		$check_date = new Datetime($date);
348 388
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
349
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
350
-		if ($globalTransaviaKey == '') return array();
389
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
390
+			return array();
391
+		}
392
+		if ($globalTransaviaKey == '') {
393
+			return array();
394
+		}
351 395
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
352 396
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
353 397
 		$headers = array('apikey: '.$globalTransaviaKey);
354 398
 		$json = $Common->getData($url,'get','',$headers);
355 399
 		//echo 'result : '.$json;
356
-		if ($json == '') return array();
400
+		if ($json == '') {
401
+			return array();
402
+		}
357 403
 		$parsed_json = json_decode($json);
358 404
 		
359 405
 		if (isset($parsed_json->{'data'}[0])) {
@@ -362,7 +408,9 @@  discard block
 block discarded – undo
362 408
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
363 409
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
364 410
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
365
-		} else return array();
411
+		} else {
412
+			return array();
413
+		}
366 414
 	}
367 415
 
368 416
 	/**
@@ -373,7 +421,9 @@  discard block
 block discarded – undo
373 421
 	public function getTunisair($callsign) {
374 422
 		$Common = new Common();
375 423
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
376
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
424
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
425
+			return array();
426
+		}
377 427
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
378 428
 		$data = $Common->getData($url);
379 429
 		$table = $Common->table2array($data);
@@ -394,7 +444,9 @@  discard block
 block discarded – undo
394 444
 		$Common = new Common();
395 445
 		$check_date = new Datetime($date);
396 446
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
397
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
447
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
448
+			return array();
449
+		}
398 450
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
399 451
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
400 452
 		$data = $Common->getData($url);
@@ -404,8 +456,11 @@  discard block
 block discarded – undo
404 456
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
405 457
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
406 458
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
407
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
408
-			else return array();
459
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
460
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
461
+			} else {
462
+				return array();
463
+			}
409 464
 		}
410 465
 		return array();
411 466
 	}
@@ -420,7 +475,9 @@  discard block
 block discarded – undo
420 475
 		$Common = new Common();
421 476
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
422 477
 		$check_date = new Datetime($date);
423
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
478
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
479
+			return array();
480
+		}
424 481
 		$url = "https://www.iberia.com/web/flightDetail.do";
425 482
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
426 483
 		$data = $Common->getData($url,'post',$post);
@@ -437,7 +494,9 @@  discard block
 block discarded – undo
437 494
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
438 495
 				if ($arrivalTime == 'Hora estimada de llegada') {
439 496
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
440
-				} else $arrivalTime = substr($arrivalTime,0,5);
497
+				} else {
498
+					$arrivalTime = substr($arrivalTime,0,5);
499
+				}
441 500
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
442 501
 			}
443 502
 		}
@@ -455,7 +514,9 @@  discard block
 block discarded – undo
455 514
 		$Common = new Common();
456 515
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
457 516
 		$check_date = new Datetime($date);
458
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
517
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
518
+			return array();
519
+		}
459 520
 		$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');
460 521
 		$data = $Common->getData($url);
461 522
 		if ($data != '') {
@@ -471,7 +532,9 @@  discard block
 block discarded – undo
471 532
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
472 533
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
473 534
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
474
-				} else return array();
535
+				} else {
536
+					return array();
537
+				}
475 538
 			}
476 539
 			
477 540
 
@@ -491,7 +554,9 @@  discard block
 block discarded – undo
491 554
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
492 555
 		$check_date = new Datetime($date);
493 556
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
494
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
557
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
558
+			return array();
559
+		}
495 560
 		$data = $Common->getData($url);
496 561
 		if ($data != '') {
497 562
 			$table = $Common->text2array($data);
@@ -515,7 +580,9 @@  discard block
 block discarded – undo
515 580
 		$check_date = new Datetime($date);
516 581
 		$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";
517 582
 		//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";
518
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
583
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
584
+			return array();
585
+		}
519 586
 		$data = $Common->getData($url);
520 587
 		if ($data != '') {
521 588
 		    //echo $data;
@@ -605,7 +672,9 @@  discard block
 block discarded – undo
605 672
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
606 673
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
607 674
 		//$check_date = new Datetime($date);
608
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
675
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
676
+			return array();
677
+		}
609 678
 		$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');
610 679
 		$data = $Common->getData($url,'post',$post);
611 680
 		if ($data != '') {
@@ -637,11 +706,15 @@  discard block
 block discarded – undo
637 706
 				$airline_icao = substr($callsign, 0, 3);
638 707
 			} 
639 708
 		}
640
-		if ($airline_icao == '') return array();
709
+		if ($airline_icao == '') {
710
+			return array();
711
+		}
641 712
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
642 713
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
643 714
 		//$check_date = new Datetime($date);
644
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
715
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
716
+			return array();
717
+		}
645 718
 		$data = $Common->getData($url);
646 719
 		if ($data != '') {
647 720
 			$table = $Common->table2array($data);
@@ -684,7 +757,9 @@  discard block
 block discarded – undo
684 757
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
685 758
 		$url= "http://fr.flightaware.com/live/flight/".$callsign;
686 759
 		//$check_date = new Datetime($date);
687
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
760
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
761
+			return array();
762
+		}
688 763
 		$data = $Common->getData($url);
689 764
 		if ($data != '') {
690 765
 			$table = $Common->table2array($data);
@@ -737,11 +812,15 @@  discard block
 block discarded – undo
737 812
 		$check_date = new Datetime($date);
738 813
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
739 814
 		$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";
740
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
815
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
816
+			return array();
817
+		}
741 818
 		$data = $Common->getData($url);
742 819
 		$dom = new DomDocument();
743 820
 		$dom->loadXML($data);
744
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
821
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
822
+			return array();
823
+		}
745 824
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
746 825
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
747 826
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -750,7 +829,9 @@  discard block
 block discarded – undo
750 829
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
751 830
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
752 831
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
753
-		} else return array();
832
+		} else {
833
+			return array();
834
+		}
754 835
 	}
755 836
 
756 837
 	/**
@@ -764,7 +845,9 @@  discard block
 block discarded – undo
764 845
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
765 846
 		$check_date = new Datetime($date);
766 847
 		$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."&";
767
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
848
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
849
+			return array();
850
+		}
768 851
 		$data = $Common->getData($url);
769 852
 		if ($data != '') {
770 853
 			$table = $Common->table2array($data);
@@ -793,7 +876,9 @@  discard block
 block discarded – undo
793 876
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
794 877
 		$check_date = new Datetime($date);
795 878
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
796
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
879
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
880
+			return array();
881
+		}
797 882
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
798 883
 		$data = $Common->getData($url,'post',$post);
799 884
 		//echo $data;
@@ -803,11 +888,19 @@  discard block
 block discarded – undo
803 888
 		if ($data != '') {
804 889
 			$table = $Common->table2array($data);
805 890
 			$flight = $table;
806
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
807
-			else $departureTime = '';
808
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
809
-			else $departureAirport = '';
810
-		} else return array();
891
+			if (isset($flight[5][4])) {
892
+				$departureTime = $flight[5][4];
893
+			} else {
894
+				$departureTime = '';
895
+			}
896
+			if (isset($flight[5][2])) {
897
+				$departureAirport = $flight[5][2];
898
+			} else {
899
+				$departureAirport = '';
900
+			}
901
+		} else {
902
+			return array();
903
+		}
811 904
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
812 905
 		$data = $Common->getData($url,'post',$post);
813 906
 		if ($data != '') {
@@ -820,10 +913,14 @@  discard block
 block discarded – undo
820 913
 			    $arrivalTime = '';
821 914
 			    $arrivalAirport = '';
822 915
 			}
823
-		} else return array();
916
+		} else {
917
+			return array();
918
+		}
824 919
 		$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';
825 920
 		$json = $Common->getData($url);
826
-		if ($json == '') return array();
921
+		if ($json == '') {
922
+			return array();
923
+		}
827 924
 		$parsed_json = json_decode($json);
828 925
 		$airports = $parsed_json->{'suggestList'};
829 926
 		if (count($airports) > 0) {
@@ -838,7 +935,9 @@  discard block
 block discarded – undo
838 935
 		}
839 936
 		if (isset($DepartureAirportIata)) {
840 937
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
841
-		} else return array();
938
+		} else {
939
+			return array();
940
+		}
842 941
 	}
843 942
 
844 943
 
@@ -846,7 +945,9 @@  discard block
 block discarded – undo
846 945
 	public function fetchSchedule($ident,$date = 'NOW') {
847 946
 		global $globalSchedulesSources, $globalSchedulesFetch;
848 947
 		//$Common = new Common();
849
-		if (!$globalSchedulesFetch) return array();
948
+		if (!$globalSchedulesFetch) {
949
+			return array();
950
+		}
850 951
 		$airline_icao = '';
851 952
 		if (!is_numeric(substr($ident, 0, 3)))
852 953
 		{
@@ -1074,14 +1175,21 @@  discard block
 block discarded – undo
1074 1175
 				default:
1075 1176
 					// Randomly use a generic function to get hours
1076 1177
 					if (strlen($airline_icao) == 2) {
1077
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1178
+						if (!isset($globalSchedulesSources)) {
1179
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1180
+						}
1078 1181
 						if (count($globalSchedulesSources) > 0) {
1079 1182
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1080 1183
 							$source = $globalSchedulesSources[$rand];
1081
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1082
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1184
+							if ($source == 'flightmapper') {
1185
+								return $this->getFlightMapper($ident);
1186
+							} elseif ($source == 'costtotravel') {
1187
+								return $this->getCostToTravel($ident);
1188
+							}
1083 1189
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1084
-							elseif ($source == 'flightaware') return $this->getFlightAware($ident);
1190
+							elseif ($source == 'flightaware') {
1191
+								return $this->getFlightAware($ident);
1192
+							}
1085 1193
 						}
1086 1194
 					}
1087 1195
 			}
Please login to merge, or discard this patch.
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -8,29 +8,29 @@  discard block
 block discarded – undo
8 8
 
9 9
 class Schedule {
10 10
 	protected $cookies = array();
11
-        public $db;
11
+		public $db;
12 12
 	public function __construct($dbc = null) {
13 13
 		$Connection = new Connection($dbc);
14 14
 		$this->db = $Connection->db();
15
-        }
15
+		}
16 16
 	
17 17
 	/**
18
-	* Add schedule data to database
19
-	* @param String $ident aircraft ident
20
-	* @param String $departure_airport_icao departure airport icao
21
-	* @param String $departure_airport_time departure airport time
22
-	* @param String $arrival_airport_icao arrival airport icao
23
-	* @param String $arrival_airport_time arrival airport time
18
+	 * Add schedule data to database
19
+	 * @param String $ident aircraft ident
20
+	 * @param String $departure_airport_icao departure airport icao
21
+	 * @param String $departure_airport_time departure airport time
22
+	 * @param String $arrival_airport_icao arrival airport icao
23
+	 * @param String $arrival_airport_time arrival airport time
24 24
 	/ @param String $source source of data
25
-	*/
25
+	 */
26 26
 	
27 27
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
28 28
 		date_default_timezone_set('UTC');
29 29
 		$date = date("Y-m-d H:i:s",time());
30
-	        //if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
31
-	        //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
32
-	        $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
33
-	        $query_values = array(':ident' => $ident);
30
+			//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
31
+			//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
32
+			$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
33
+			$query_values = array(':ident' => $ident);
34 34
 		 try {
35 35
 			$sth = $this->db->prepare($query);
36 36
 			$sth->execute($query_values);
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($sth->fetchColumn() > 0) {
41 41
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
42
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
43
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
42
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
43
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
44 44
 			} elseif ($arrival_airport_time == '') {
45
-			    $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";
46
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
45
+				$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";
46
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
47 47
 			} elseif ($departure_airport_time == '') {
48
-			    $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";
49
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
48
+				$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";
49
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
50 50
 			} else {
51
-			    //$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";
52
-			    $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";
53
-			    $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);
51
+				//$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";
52
+				$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";
53
+				$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);
54 54
 			}
55 55
 			try {
56 56
 				$sth = $this->db->prepare($query);
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
 			if ($sth->fetchColumn() == 0) {
62 62
 				//$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';
63 63
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
64
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
65
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
64
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
65
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
66 66
 				} elseif ($arrival_airport_time == '') {
67
-                            	    $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';
68
-				    $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);
67
+									$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';
68
+					$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);
69 69
 				} elseif ($departure_airport_time == '') {
70
-                            	    $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';
71
-				    $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);
70
+									$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';
71
+					$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);
72 72
 				} else {
73
-                            	    $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';
74
-				    $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);
73
+									$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';
74
+					$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);
75 75
 				}
76 76
 				 try {
77 77
 					$sth = $this->db->prepare($query);
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	public function getSchedule($ident) {
107
-	        $Translation = new Translation($this->db);
108
-	        $operator = $Translation->checkTranslation($ident,false);
109
-	        if ($ident != $operator) {
110
-	    		$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 CallSign = :operator OR CallSign = :ident LIMIT 1";
111
-	    		$query_values = array(':ident' => $ident,'operator' => $operator);
112
-	    	} else {
113
-		        $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 CallSign = :ident LIMIT 1";
114
-	    		$query_values = array(':ident' => $ident);
115
-	    	}
107
+			$Translation = new Translation($this->db);
108
+			$operator = $Translation->checkTranslation($ident,false);
109
+			if ($ident != $operator) {
110
+				$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 CallSign = :operator OR CallSign = :ident LIMIT 1";
111
+				$query_values = array(':ident' => $ident,'operator' => $operator);
112
+			} else {
113
+				$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 CallSign = :ident LIMIT 1";
114
+				$query_values = array(':ident' => $ident);
115
+			}
116 116
 		 try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
@@ -128,15 +128,15 @@  discard block
 block discarded – undo
128 128
 
129 129
 	public function checkSchedule($ident) {
130 130
 		global $globalDBdriver;
131
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
132
-	        if ($globalDBdriver == 'mysql') {
131
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
132
+			if ($globalDBdriver == 'mysql') {
133 133
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE 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";
134 134
 		} else {
135 135
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident 
136 136
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
137 137
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
138 138
 		}
139
-	        $query_values = array(':ident' => $ident);
139
+			$query_values = array(':ident' => $ident);
140 140
 		 try {
141 141
 			$sth = $this->db->prepare($query);
142 142
 			$sth->execute($query_values);
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
 	}
150 150
 
151 151
 	/**
152
-	* Get flight info from Air France
153
-	* @param String $callsign The callsign
154
-	* @param String $date date we want flight number info
155
-	* @param String $carrier IATA code
156
-	* @return Flight departure and arrival airports and time
157
-	*/
152
+	 * Get flight info from Air France
153
+	 * @param String $callsign The callsign
154
+	 * @param String $date date we want flight number info
155
+	 * @param String $carrier IATA code
156
+	 * @return Flight departure and arrival airports and time
157
+	 */
158 158
 	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
159 159
 		$Common = new Common();
160 160
 		$check_date = new Datetime($date);
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
 	}
191 191
 
192 192
 	/**
193
-	* Get flight info from EasyJet
194
-	* @param String $callsign The callsign
195
-	* @param String $date date we want flight number info
196
-	* @return Flight departure and arrival airports and time
197
-	*/
193
+	 * Get flight info from EasyJet
194
+	 * @param String $callsign The callsign
195
+	 * @param String $date date we want flight number info
196
+	 * @return Flight departure and arrival airports and time
197
+	 */
198 198
 	private function getEasyJet($callsign, $date = 'NOW') {
199 199
 		global $globalTimezone;
200 200
 		$Common = new Common();
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
 	}
219 219
 
220 220
 	/**
221
-	* Get flight info from Ryanair
222
-	* @param String $callsign The callsign
223
-	* @return Flight departure and arrival airports and time
224
-	*/
221
+	 * Get flight info from Ryanair
222
+	 * @param String $callsign The callsign
223
+	 * @return Flight departure and arrival airports and time
224
+	 */
225 225
 	private function getRyanair($callsign) {
226 226
 		$Common = new Common();
227 227
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 	}
245 245
 
246 246
 	/**
247
-	* Get flight info from Swiss
248
-	* @param String $callsign The callsign
249
-	* @return Flight departure and arrival airports and time
250
-	*/
247
+	 * Get flight info from Swiss
248
+	 * @param String $callsign The callsign
249
+	 * @return Flight departure and arrival airports and time
250
+	 */
251 251
 	private function getSwiss($callsign) {
252 252
 		$Common = new Common();
253 253
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 	}
277 277
 	
278 278
 	/**
279
-	* Get flight info from British Airways API
280
-	* @param String $callsign The callsign
281
-	* @param String $date date we want flight number info
282
-	* @return Flight departure and arrival airports and time
283
-	*/
279
+	 * Get flight info from British Airways API
280
+	 * @param String $callsign The callsign
281
+	 * @param String $date date we want flight number info
282
+	 * @return Flight departure and arrival airports and time
283
+	 */
284 284
 	public function getBritishAirways($callsign, $date = 'NOW') {
285 285
 		global $globalBritishAirwaysKey;
286 286
 		$Common = new Common();
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
 	}
305 305
 
306 306
 	/**
307
-	* Get flight info from Lutfhansa API
308
-	* @param String $callsign The callsign
309
-	* @param String $date date we want flight number info
310
-	* @return Flight departure and arrival airports and time
311
-	*/
307
+	 * Get flight info from Lutfhansa API
308
+	 * @param String $callsign The callsign
309
+	 * @param String $date date we want flight number info
310
+	 * @return Flight departure and arrival airports and time
311
+	 */
312 312
 	public function getLufthansa($callsign, $date = 'NOW') {
313 313
 		global $globalLufthansaKey;
314 314
 		$Common = new Common();
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
 	}
339 339
 
340 340
 	/**
341
-	* Get flight info from Transavia API
342
-	* @param String $callsign The callsign
343
-	* @param String $date date we want flight number info
344
-	* @return Flight departure and arrival airports and time
345
-	*/
341
+	 * Get flight info from Transavia API
342
+	 * @param String $callsign The callsign
343
+	 * @param String $date date we want flight number info
344
+	 * @return Flight departure and arrival airports and time
345
+	 */
346 346
 	public function getTransavia($callsign, $date = 'NOW') {
347 347
 		global $globalTransaviaKey;
348 348
 		$Common = new Common();
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 
370 370
 	/**
371
-	* Get flight info from Tunisair
372
-	* @param String $callsign The callsign
373
-	* @return Flight departure and arrival airports and time
374
-	*/
371
+	 * Get flight info from Tunisair
372
+	 * @param String $callsign The callsign
373
+	 * @return Flight departure and arrival airports and time
374
+	 */
375 375
 	public function getTunisair($callsign) {
376 376
 		$Common = new Common();
377 377
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
 	}
389 389
 
390 390
 	/**
391
-	* Get flight info from Vueling
392
-	* @param String $callsign The callsign
393
-	* @return Flight departure and arrival airports and time
394
-	*/
391
+	 * Get flight info from Vueling
392
+	 * @param String $callsign The callsign
393
+	 * @return Flight departure and arrival airports and time
394
+	 */
395 395
 	public function getVueling($callsign,$date = 'NOW') {
396 396
 		$Common = new Common();
397 397
 		$check_date = new Datetime($date);
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
 	}
414 414
 
415 415
 	/**
416
-	* Get flight info from Iberia
417
-	* @param String $callsign The callsign
418
-	* @param String $date date we want flight number info
419
-	* @return Flight departure and arrival airports and time
420
-	*/
416
+	 * Get flight info from Iberia
417
+	 * @param String $callsign The callsign
418
+	 * @param String $date date we want flight number info
419
+	 * @return Flight departure and arrival airports and time
420
+	 */
421 421
 	public function getIberia($callsign, $date = 'NOW') {
422 422
 		$Common = new Common();
423 423
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -447,11 +447,11 @@  discard block
 block discarded – undo
447 447
 	}
448 448
 
449 449
 	/**
450
-	* Get flight info from Star Alliance
451
-	* @param String $callsign The callsign
452
-	* @param String $date date we want flight number info
453
-	* @return Flight departure and arrival airports and time
454
-	*/
450
+	 * Get flight info from Star Alliance
451
+	 * @param String $callsign The callsign
452
+	 * @param String $date date we want flight number info
453
+	 * @return Flight departure and arrival airports and time
454
+	 */
455 455
 
456 456
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
457 457
 		$Common = new Common();
@@ -483,11 +483,11 @@  discard block
 block discarded – undo
483 483
 
484 484
 
485 485
 	/**
486
-	* Get flight info from Alitalia
487
-	* @param String $callsign The callsign
488
-	* @param String $date date we want flight number info
489
-	* @return Flight departure and arrival airports and time
490
-	*/
486
+	 * Get flight info from Alitalia
487
+	 * @param String $callsign The callsign
488
+	 * @param String $date date we want flight number info
489
+	 * @return Flight departure and arrival airports and time
490
+	 */
491 491
 	private function getAlitalia($callsign, $date = 'NOW') {
492 492
 		$Common = new Common();
493 493
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -506,11 +506,11 @@  discard block
 block discarded – undo
506 506
 	}
507 507
 
508 508
 	/**
509
-	* Get flight info from Brussels airlines
510
-	* @param String $callsign The callsign
511
-	* @param String $date date we want flight number info
512
-	* @return Flight departure and arrival airports and time
513
-	*/
509
+	 * Get flight info from Brussels airlines
510
+	 * @param String $callsign The callsign
511
+	 * @param String $date date we want flight number info
512
+	 * @return Flight departure and arrival airports and time
513
+	 */
514 514
 	private function getBrussels($callsign, $date = 'NOW') {
515 515
 		$Common = new Common();
516 516
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -520,24 +520,24 @@  discard block
 block discarded – undo
520 520
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
521 521
 		$data = $Common->getData($url);
522 522
 		if ($data != '') {
523
-		    //echo $data;
524
-		    $parsed_json = json_decode($data,true);
525
-		    if (isset($parsed_json[0]['FromAirportCode'])) {
523
+			//echo $data;
524
+			$parsed_json = json_decode($data,true);
525
+			if (isset($parsed_json[0]['FromAirportCode'])) {
526 526
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
527 527
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
528 528
 			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
529 529
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
530 530
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
531
-		    }
531
+			}
532 532
 		}
533 533
 	}
534 534
 
535 535
 	/**
536
-	* Get flight info from FlightRadar24
537
-	* @param String $callsign The callsign
538
-	* @param String $date date we want flight number info
539
-	* @return Flight departure and arrival airports and time
540
-	*/
536
+	 * Get flight info from FlightRadar24
537
+	 * @param String $callsign The callsign
538
+	 * @param String $date date we want flight number info
539
+	 * @return Flight departure and arrival airports and time
540
+	 */
541 541
 /*
542 542
 	public function getFlightRadar24($callsign, $date = 'NOW') {
543 543
 		$Common = new Common();
@@ -566,11 +566,11 @@  discard block
 block discarded – undo
566 566
 	}
567 567
   */
568 568
 	/**
569
-	* Get flight info from Lufthansa
570
-	* @param String $callsign The callsign
571
-	* @param String $date date we want flight number info
572
-	* @return Flight departure and arrival airports and time
573
-	*/
569
+	 * Get flight info from Lufthansa
570
+	 * @param String $callsign The callsign
571
+	 * @param String $date date we want flight number info
572
+	 * @return Flight departure and arrival airports and time
573
+	 */
574 574
 
575 575
 /*	private function getLufthansa($callsign, $date = 'NOW') {
576 576
 		$Common = new Common();
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
 	}
599 599
   */
600 600
 	/**
601
-	* Get flight info from flytap
602
-	* @param String $callsign The callsign
603
-	* @return Flight departure and arrival airports and time
604
-	*/
601
+	 * Get flight info from flytap
602
+	 * @param String $callsign The callsign
603
+	 * @return Flight departure and arrival airports and time
604
+	 */
605 605
 	private function getFlyTap($callsign) {
606 606
 		$Common = new Common();
607 607
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -624,10 +624,10 @@  discard block
 block discarded – undo
624 624
 	}
625 625
 
626 626
 	/**
627
-	* Get flight info from flightmapper
628
-	* @param String $callsign The callsign
629
-	* @return Flight departure and arrival airports and time
630
-	*/
627
+	 * Get flight info from flightmapper
628
+	 * @param String $callsign The callsign
629
+	 * @return Flight departure and arrival airports and time
630
+	 */
631 631
 	public function getFlightMapper($callsign) {
632 632
 		$Common = new Common();
633 633
 		$airline_icao = '';
@@ -655,11 +655,11 @@  discard block
 block discarded – undo
655 655
 				$aarr = '';
656 656
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
657 657
 				if ($n == 7) {
658
-				    $departureTime = $dhour;
659
-				    $arrivalTime = $ahour;
660
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
661
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
662
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
658
+					$departureTime = $dhour;
659
+					$arrivalTime = $ahour;
660
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
661
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
662
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
663 663
 				}
664 664
 			}
665 665
 		}
@@ -667,10 +667,10 @@  discard block
 block discarded – undo
667 667
 	}
668 668
 
669 669
 	/**
670
-	* Get flight info from flightaware
671
-	* @param String $callsign The callsign
672
-	* @return Flight departure and arrival airports and time
673
-	*/
670
+	 * Get flight info from flightaware
671
+	 * @param String $callsign The callsign
672
+	 * @return Flight departure and arrival airports and time
673
+	 */
674 674
 	public function getFlightAware($callsign) {
675 675
 		$Common = new Common();
676 676
 		/*
@@ -703,10 +703,10 @@  discard block
 block discarded – undo
703 703
 	}
704 704
 
705 705
 	/**
706
-	* Get flight info from CostToTravel
707
-	* @param String $callsign The callsign
708
-	* @return Flight departure and arrival airports and time
709
-	*/
706
+	 * Get flight info from CostToTravel
707
+	 * @param String $callsign The callsign
708
+	 * @return Flight departure and arrival airports and time
709
+	 */
710 710
 	public function getCostToTravel($callsign) {
711 711
 		$Common = new Common();
712 712
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -728,11 +728,11 @@  discard block
 block discarded – undo
728 728
 	}
729 729
 
730 730
 	/**
731
-	* Get flight info from Air Canada
732
-	* @param String $callsign The callsign
733
-	* @param String $date date we want flight number info
734
-	* @return Flight departure and arrival airports and time
735
-	*/
731
+	 * Get flight info from Air Canada
732
+	 * @param String $callsign The callsign
733
+	 * @param String $date date we want flight number info
734
+	 * @return Flight departure and arrival airports and time
735
+	 */
736 736
 	private function getAirCanada($callsign,$date = 'NOW') {
737 737
 		$Common = new Common();
738 738
 		date_default_timezone_set('UTC');
@@ -756,11 +756,11 @@  discard block
 block discarded – undo
756 756
 	}
757 757
 
758 758
 	/**
759
-	* Get flight info from Vietnam Airlines
760
-	* @param String $callsign The callsign
761
-	* @param String $date date we want flight number info
762
-	* @return Flight departure and arrival airports and time
763
-	*/
759
+	 * Get flight info from Vietnam Airlines
760
+	 * @param String $callsign The callsign
761
+	 * @param String $date date we want flight number info
762
+	 * @return Flight departure and arrival airports and time
763
+	 */
764 764
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
765 765
 		$Common = new Common();
766 766
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -782,12 +782,12 @@  discard block
 block discarded – undo
782 782
 	}
783 783
 
784 784
 	/**
785
-	* Get flight info from Air Berlin
786
-	* @param String $callsign The callsign
787
-	* @param String $date date we want flight number info
788
-	* @param String $carrier airline code
789
-	* @return Flight departure and arrival airports and time
790
-	*/
785
+	 * Get flight info from Air Berlin
786
+	 * @param String $callsign The callsign
787
+	 * @param String $date date we want flight number info
788
+	 * @param String $carrier airline code
789
+	 * @return Flight departure and arrival airports and time
790
+	 */
791 791
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
792 792
 		$Common = new Common();
793 793
 		date_default_timezone_set('UTC');
@@ -816,11 +816,11 @@  discard block
 block discarded – undo
816 816
 			$table = $Common->table2array($data);
817 817
 			$flight = $table;
818 818
 			if (isset($flight[5][4])) {
819
-			    $arrivalTime = $flight[5][4];
820
-			    $arrivalAirport = $flight[5][3];
819
+				$arrivalTime = $flight[5][4];
820
+				$arrivalAirport = $flight[5][3];
821 821
 			} else {
822
-			    $arrivalTime = '';
823
-			    $arrivalAirport = '';
822
+				$arrivalTime = '';
823
+				$arrivalAirport = '';
824 824
 			}
825 825
 		} else return array();
826 826
 		$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';
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 					}
1089 1089
 			}
1090 1090
 		}
1091
-	        return array();
1091
+			return array();
1092 1092
 	}
1093 1093
 }
1094 1094
 
Please login to merge, or discard this patch.
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	/ @param String $source source of data
25 25
 	*/
26 26
 	
27
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
27
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
28 28
 		date_default_timezone_set('UTC');
29
-		$date = date("Y-m-d H:i:s",time());
29
+		$date = date("Y-m-d H:i:s", time());
30 30
 	        //if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
31 31
 	        //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
32 32
 	        $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -34,69 +34,69 @@  discard block
 block discarded – undo
34 34
 		 try {
35 35
 			$sth = $this->db->prepare($query);
36 36
 			$sth->execute($query_values);
37
-		} catch(PDOException $e) {
37
+		} catch (PDOException $e) {
38 38
 			return "error : ".$e->getMessage();
39 39
 		}
40 40
 		if ($sth->fetchColumn() > 0) {
41 41
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
42 42
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
43
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
43
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
44 44
 			} elseif ($arrival_airport_time == '') {
45 45
 			    $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";
46
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
46
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
47 47
 			} elseif ($departure_airport_time == '') {
48 48
 			    $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";
49
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
49
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
50 50
 			} else {
51 51
 			    //$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";
52 52
 			    $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";
53
-			    $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);
53
+			    $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);
54 54
 			}
55 55
 			try {
56 56
 				$sth = $this->db->prepare($query);
57 57
 				$sth->execute($query_values);
58
-			} catch(PDOException $e) {
58
+			} catch (PDOException $e) {
59 59
 				return "error : ".$e->getMessage();
60 60
 			}
61 61
 			if ($sth->fetchColumn() == 0) {
62 62
 				//$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';
63 63
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
64 64
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
65
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
65
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
66 66
 				} elseif ($arrival_airport_time == '') {
67 67
                             	    $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';
68
-				    $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);
68
+				    $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);
69 69
 				} elseif ($departure_airport_time == '') {
70 70
                             	    $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';
71
-				    $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);
71
+				    $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);
72 72
 				} else {
73 73
                             	    $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';
74
-				    $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);
74
+				    $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);
75 75
 				}
76 76
 				 try {
77 77
 					$sth = $this->db->prepare($query);
78 78
 					$sth->execute($query_values);
79
-				} catch(PDOException $e) {
79
+				} catch (PDOException $e) {
80 80
 					return "error : ".$e->getMessage();
81 81
 				}
82 82
 			} else {
83 83
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
84 84
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
85
-				$query_values = array(':ident' => $ident,':date' => $date);
85
+				$query_values = array(':ident' => $ident, ':date' => $date);
86 86
 				 try {
87 87
 					$sth = $this->db->prepare($query);
88 88
 					$sth->execute($query_values);
89
-				} catch(PDOException $e) {
89
+				} catch (PDOException $e) {
90 90
 					return "error : ".$e->getMessage();
91 91
 				}
92 92
 			}
93 93
 		} else {
94 94
 			$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)';
95
-			$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);
95
+			$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);
96 96
 			 try {
97 97
 				$sth = $this->db->prepare($query);
98 98
 				$sth->execute($query_values);
99
-			} catch(PDOException $e) {
99
+			} catch (PDOException $e) {
100 100
 				return "error : ".$e->getMessage();
101 101
 			}
102 102
 		}
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 
106 106
 	public function getSchedule($ident) {
107 107
 	        $Translation = new Translation($this->db);
108
-	        $operator = $Translation->checkTranslation($ident,false);
108
+	        $operator = $Translation->checkTranslation($ident, false);
109 109
 	        if ($ident != $operator) {
110 110
 	    		$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 CallSign = :operator OR CallSign = :ident LIMIT 1";
111
-	    		$query_values = array(':ident' => $ident,'operator' => $operator);
111
+	    		$query_values = array(':ident' => $ident, 'operator' => $operator);
112 112
 	    	} else {
113 113
 		        $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 CallSign = :ident LIMIT 1";
114 114
 	    		$query_values = array(':ident' => $ident);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		 try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
119
-		} catch(PDOException $e) {
119
+		} catch (PDOException $e) {
120 120
 			return "error : ".$e->getMessage();
121 121
 		}
122 122
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		 try {
141 141
 			$sth = $this->db->prepare($query);
142 142
 			$sth->execute($query_values);
143
-		} catch(PDOException $e) {
143
+		} catch (PDOException $e) {
144 144
 			return "error : ".$e->getMessage();
145 145
 		}
146 146
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -155,16 +155,16 @@  discard block
 block discarded – undo
155 155
 	* @param String $carrier IATA code
156 156
 	* @return Flight departure and arrival airports and time
157 157
 	*/
158
-	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
158
+	private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
159 159
 		$Common = new Common();
160 160
 		$check_date = new Datetime($date);
161
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
162
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
161
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
162
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
163 163
 		$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');
164 164
 		$json = $Common->getData($url);
165 165
 	
166 166
 		$parsed_json = json_decode($json);
167
-		if (property_exists($parsed_json,'errors') === false) {
167
+		if (property_exists($parsed_json, 'errors') === false) {
168 168
 			//$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
169 169
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
170 170
 			//$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 			//$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
175 175
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
176 176
 
177
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
177
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
178 178
 			$DepartureAirportIata = $originiata[1];
179
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
179
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
180 180
 			$ArrivalAirportIata = $destinationiata[1];
181 181
 
182 182
 			/*
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
186 186
 			*/
187 187
 		
188
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
188
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
189 189
 		} else return array();
190 190
 	}
191 191
 
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 		$Common = new Common();
201 201
 		date_default_timezone_set($globalTimezone);
202 202
 		$check_date = new Datetime($date);
203
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
204
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
203
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
204
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
205 205
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
206 206
 		$json = $Common->getData($url);
207 207
 		$parsed_json = json_decode($json);
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
214 214
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
215 215
 
216
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
216
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
217 217
 		} else return array();
218 218
 	}
219 219
 
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
 	*/
225 225
 	private function getRyanair($callsign) {
226 226
 		$Common = new Common();
227
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
228
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
227
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
228
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
229 229
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
230 230
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
231
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
232
-		$json = $Common->getData($url,'post',$post,$headers);
231
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
232
+		$json = $Common->getData($url, 'post', $post, $headers);
233 233
 		$parsed_json = json_decode($json);
234 234
 		if (isset($parsed_json->{'flightInfo'})) {
235 235
 			$flights = $parsed_json->{'flightInfo'};
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
239 239
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
240 240
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
241
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
241
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
242 242
 			} else return array();
243 243
 		} else return array();
244 244
 	}
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 	*/
251 251
 	private function getSwiss($callsign) {
252 252
 		$Common = new Common();
253
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
254
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
253
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
254
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
255 255
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
256 256
 		$json = $Common->getData($url);
257 257
 		$parsed_json = json_decode($json);
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
266 266
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
267 267
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
268
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
269
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
268
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
269
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
270 270
 				}
271 271
 			}
272 272
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
273
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
273
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
274 274
 			} else return array();
275 275
 		} else return array();
276 276
 	}
@@ -285,21 +285,21 @@  discard block
 block discarded – undo
285 285
 		global $globalBritishAirwaysKey;
286 286
 		$Common = new Common();
287 287
 		$check_date = new Datetime($date);
288
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
289
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
288
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
289
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
290 290
 		if ($globalBritishAirwaysKey == '') return array();
291 291
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
292 292
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
293
-		$json = $Common->getData($url,'get','',$headers);
293
+		$json = $Common->getData($url, 'get', '', $headers);
294 294
 		if ($json == '') return array();
295 295
 		$parsed_json = json_decode($json);
296 296
 		$flights = $parsed_json->{'FlightsResponse'};
297 297
 		if (count($flights) > 0) {
298 298
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
299 299
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
300
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
301
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
302
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
300
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
301
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
302
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
303 303
 		} else return array();
304 304
 	}
305 305
 
@@ -313,27 +313,27 @@  discard block
 block discarded – undo
313 313
 		global $globalLufthansaKey;
314 314
 		$Common = new Common();
315 315
 		$check_date = new Datetime($date);
316
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
317
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
316
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
317
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
318 318
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
319 319
 		$url = "https://api.lufthansa.com/v1/oauth/token";
320
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
321
-		$data = $Common->getData($url,'post',$post);
320
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
321
+		$data = $Common->getData($url, 'post', $post);
322 322
 		$parsed_data = json_decode($data);
323 323
 		if (!isset($parsed_data->{'access_token'})) return array();
324 324
 		$token = $parsed_data->{'access_token'};
325 325
 		
326 326
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
327
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
328
-		$json = $Common->getData($url,'get','',$headers);
327
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
328
+		$json = $Common->getData($url, 'get', '', $headers);
329 329
 		if ($json == '') return array();
330 330
 		$parsed_json = json_decode($json);
331 331
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
332 332
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
333
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
333
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
334 334
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
335
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
336
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
335
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
336
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
337 337
 		} else return array();
338 338
 	}
339 339
 
@@ -347,23 +347,23 @@  discard block
 block discarded – undo
347 347
 		global $globalTransaviaKey;
348 348
 		$Common = new Common();
349 349
 		$check_date = new Datetime($date);
350
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
351
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
350
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
351
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
352 352
 		if ($globalTransaviaKey == '') return array();
353 353
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
354 354
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
355 355
 		$headers = array('apikey: '.$globalTransaviaKey);
356
-		$json = $Common->getData($url,'get','',$headers);
356
+		$json = $Common->getData($url, 'get', '', $headers);
357 357
 		//echo 'result : '.$json;
358 358
 		if ($json == '') return array();
359 359
 		$parsed_json = json_decode($json);
360 360
 		
361 361
 		if (isset($parsed_json->{'data'}[0])) {
362 362
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
363
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
363
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
364 364
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
365
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
366
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
365
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
366
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
367 367
 		} else return array();
368 368
 	}
369 369
 
@@ -374,14 +374,14 @@  discard block
 block discarded – undo
374 374
 	*/
375 375
 	public function getTunisair($callsign) {
376 376
 		$Common = new Common();
377
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
378
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
377
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
378
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
379 379
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
380 380
 		$data = $Common->getData($url);
381 381
 		$table = $Common->table2array($data);
382 382
 		foreach ($table as $flight) {
383
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
384
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
383
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
384
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
385 385
 			}
386 386
 		}
387 387
 		return array();
@@ -392,21 +392,21 @@  discard block
 block discarded – undo
392 392
 	* @param String $callsign The callsign
393 393
 	* @return Flight departure and arrival airports and time
394 394
 	*/
395
-	public function getVueling($callsign,$date = 'NOW') {
395
+	public function getVueling($callsign, $date = 'NOW') {
396 396
 		$Common = new Common();
397 397
 		$check_date = new Datetime($date);
398
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
399
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
400
-		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
398
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
399
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
400
+		$final_date = str_replace('/', '%2F', $check_date->format('d/m/Y'));
401 401
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
402 402
 		$data = $Common->getData($url);
403
-		$data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data));
403
+		$data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data));
404 404
 		if ($data != '') {
405
-			preg_match('/flightOri=[A-Z]{3}/',$data,$result);
406
-			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
407
-			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
408
-			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
409
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
405
+			preg_match('/flightOri=[A-Z]{3}/', $data, $result);
406
+			$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
407
+			preg_match('/flightDest=[A-Z]{3}/', $data, $result);
408
+			$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
409
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling');
410 410
 			else return array();
411 411
 		}
412 412
 		return array();
@@ -420,27 +420,27 @@  discard block
 block discarded – undo
420 420
 	*/
421 421
 	public function getIberia($callsign, $date = 'NOW') {
422 422
 		$Common = new Common();
423
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
423
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
424 424
 		$check_date = new Datetime($date);
425
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
425
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
426 426
 		$url = "https://www.iberia.com/web/flightDetail.do";
427
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
428
-		$data = $Common->getData($url,'post',$post);
427
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
428
+		$data = $Common->getData($url, 'post', $post);
429 429
 		if ($data != '') {
430 430
 			$table = $Common->table2array($data);
431 431
 			//print_r($table);
432 432
 			if (count($table) > 0) {
433 433
 				$flight = $table;
434
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
435
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
434
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
435
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
436 436
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
437 437
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
438
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
439
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
438
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
439
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
440 440
 				if ($arrivalTime == 'Hora estimada de llegada') {
441
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
442
-				} else $arrivalTime = substr($arrivalTime,0,5);
443
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
441
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
442
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
443
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
444 444
 			}
445 445
 		}
446 446
 		return array();
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
 	* @return Flight departure and arrival airports and time
454 454
 	*/
455 455
 
456
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
456
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
457 457
 		$Common = new Common();
458
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
458
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
459 459
 		$check_date = new Datetime($date);
460
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
460
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
461 461
 		$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');
462 462
 		$data = $Common->getData($url);
463 463
 		if ($data != '') {
@@ -466,13 +466,13 @@  discard block
 block discarded – undo
466 466
 				$flight = $table;
467 467
 				//print_r($table);
468 468
 				if (isset($flight[25]) && isset($flight[29])) {
469
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
470
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
469
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
470
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
471 471
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
472 472
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
473
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
474
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
475
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
473
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
474
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
475
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
476 476
 				} else return array();
477 477
 			}
478 478
 			
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
 	*/
491 491
 	private function getAlitalia($callsign, $date = 'NOW') {
492 492
 		$Common = new Common();
493
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
493
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
494 494
 		$check_date = new Datetime($date);
495
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
496
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
495
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
496
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
497 497
 		$data = $Common->getData($url);
498 498
 		if ($data != '') {
499 499
 			$table = $Common->text2array($data);
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 			$ArrivalAirportIata = '';
502 502
 			$departureTime = $table[4];
503 503
 			$arrivalTime = $table[5];
504
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
504
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
505 505
 		}
506 506
 	}
507 507
 
@@ -513,21 +513,21 @@  discard block
 block discarded – undo
513 513
 	*/
514 514
 	private function getBrussels($callsign, $date = 'NOW') {
515 515
 		$Common = new Common();
516
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
516
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
517 517
 		$check_date = new Datetime($date);
518
-		$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";
518
+		$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";
519 519
 		//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";
520
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
520
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
521 521
 		$data = $Common->getData($url);
522 522
 		if ($data != '') {
523 523
 		    //echo $data;
524
-		    $parsed_json = json_decode($data,true);
524
+		    $parsed_json = json_decode($data, true);
525 525
 		    if (isset($parsed_json[0]['FromAirportCode'])) {
526 526
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
527 527
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
528
-			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
529
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
530
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
528
+			$departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate']));
529
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate']));
530
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
531 531
 		    }
532 532
 		}
533 533
 	}
@@ -604,21 +604,21 @@  discard block
 block discarded – undo
604 604
 	*/
605 605
 	private function getFlyTap($callsign) {
606 606
 		$Common = new Common();
607
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
608
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
607
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
608
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
609 609
 		//$check_date = new Datetime($date);
610
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
611
-		$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');
612
-		$data = $Common->getData($url,'post',$post);
610
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
611
+		$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');
612
+		$data = $Common->getData($url, 'post', $post);
613 613
 		if ($data != '') {
614 614
 			$table = $Common->table2array($data);
615
-			$departureTime = trim(substr($table[15][0],0,5));
616
-			$arrivalTime = trim(substr($table[35][0],0,5));
617
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
618
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
615
+			$departureTime = trim(substr($table[15][0], 0, 5));
616
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
617
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
618
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
619 619
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
620 620
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
621
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
621
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
622 622
 		}
623 623
 		return array();
624 624
 	}
@@ -640,10 +640,10 @@  discard block
 block discarded – undo
640 640
 			} 
641 641
 		}
642 642
 		if ($airline_icao == '') return array();
643
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
644
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
643
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
644
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
645 645
 		//$check_date = new Datetime($date);
646
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
646
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
647 647
 		$data = $Common->getData($url);
648 648
 		if ($data != '') {
649 649
 			$table = $Common->table2array($data);
@@ -653,13 +653,13 @@  discard block
 block discarded – undo
653 653
 				$darr = '';
654 654
 				$ahour = '';
655 655
 				$aarr = '';
656
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
656
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
657 657
 				if ($n == 7) {
658 658
 				    $departureTime = $dhour;
659 659
 				    $arrivalTime = $ahour;
660
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
661
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
662
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
660
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
661
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
662
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
663 663
 				}
664 664
 			}
665 665
 		}
@@ -683,20 +683,20 @@  discard block
 block discarded – undo
683 683
 			} 
684 684
 		}
685 685
 		*/
686
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
687
-		$url= "http://fr.flightaware.com/live/flight/".$callsign;
686
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
687
+		$url = "http://fr.flightaware.com/live/flight/".$callsign;
688 688
 		//$check_date = new Datetime($date);
689
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
689
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
690 690
 		$data = $Common->getData($url);
691 691
 		if ($data != '') {
692 692
 			$table = $Common->table2array($data);
693 693
 			if (isset($table[11][0])) {
694
-				$departureTime = str_replace('h',':',substr($table[5][0],0,5));
695
-				$arrivalTime = str_replace('h',':',substr($table[5][1],0,5));
694
+				$departureTime = str_replace('h', ':', substr($table[5][0], 0, 5));
695
+				$arrivalTime = str_replace('h', ':', substr($table[5][1], 0, 5));
696 696
 				echo $table[3][0];
697
-				sscanf($table[3][0],'%*[^(] (%3[A-Z] / %*4[A-Z])',$DepartureAirportIata);
698
-				sscanf($table[3][1],'%*[^(] (%3[A-Z] / %*4[A-Z])',$ArrivalAirportIata);
699
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightaware');
697
+				sscanf($table[3][0], '%*[^(] (%3[A-Z] / %*4[A-Z])', $DepartureAirportIata);
698
+				sscanf($table[3][1], '%*[^(] (%3[A-Z] / %*4[A-Z])', $ArrivalAirportIata);
699
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightaware');
700 700
 			}
701 701
 		}
702 702
 		return array();
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 	*/
710 710
 	public function getCostToTravel($callsign) {
711 711
 		$Common = new Common();
712
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
712
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
713 713
 		//$check_date = new Datetime($date);
714 714
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
715 715
 		$data = $Common->getData($url);
@@ -717,11 +717,11 @@  discard block
 block discarded – undo
717 717
 			$table = $Common->table2array($data);
718 718
 			//print_r($table);
719 719
 			if (isset($table[11][1])) {
720
-				$departureTime = substr($table[11][1],0,5);
721
-				$arrivalTime = substr($table[17][1],0,5);
722
-				$DepartureAirportIata = substr($table[13][1],0,3);
723
-				$ArrivalAirportIata = substr($table[15][1],0,3);
724
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
720
+				$departureTime = substr($table[11][1], 0, 5);
721
+				$arrivalTime = substr($table[17][1], 0, 5);
722
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
723
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
724
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
725 725
 			}
726 726
 		}
727 727
 		return array();
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
 	* @param String $date date we want flight number info
734 734
 	* @return Flight departure and arrival airports and time
735 735
 	*/
736
-	private function getAirCanada($callsign,$date = 'NOW') {
736
+	private function getAirCanada($callsign, $date = 'NOW') {
737 737
 		$Common = new Common();
738 738
 		date_default_timezone_set('UTC');
739 739
 		$check_date = new Datetime($date);
740
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
741
-		$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";
742
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
740
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
741
+		$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";
742
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
743 743
 		$data = $Common->getData($url);
744 744
 		$dom = new DomDocument();
745 745
 		$dom->loadXML($data);
@@ -747,11 +747,11 @@  discard block
 block discarded – undo
747 747
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
748 748
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
749 749
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
750
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
750
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
751 751
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
752 752
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
753
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
754
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
753
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
754
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
755 755
 		} else return array();
756 756
 	}
757 757
 
@@ -763,21 +763,21 @@  discard block
 block discarded – undo
763 763
 	*/
764 764
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
765 765
 		$Common = new Common();
766
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
766
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
767 767
 		$check_date = new Datetime($date);
768
-		$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."&";
769
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
768
+		$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."&";
769
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
770 770
 		$data = $Common->getData($url);
771 771
 		if ($data != '') {
772 772
 			$table = $Common->table2array($data);
773 773
 			$flight = $table;
774
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
775
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
774
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
775
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
776 776
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
777 777
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
778 778
 			$departureTime = $flight[5][1];
779 779
 			$arrivalTime = $flight[23][1];
780
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
780
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
781 781
 		}
782 782
 	}
783 783
 
@@ -788,16 +788,16 @@  discard block
 block discarded – undo
788 788
 	* @param String $carrier airline code
789 789
 	* @return Flight departure and arrival airports and time
790 790
 	*/
791
-	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
791
+	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
792 792
 		$Common = new Common();
793 793
 		date_default_timezone_set('UTC');
794 794
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
795
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
795
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
796 796
 		$check_date = new Datetime($date);
797
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
798
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
799
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
800
-		$data = $Common->getData($url,'post',$post);
797
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
798
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
799
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier);
800
+		$data = $Common->getData($url, 'post', $post);
801 801
 		//echo $data;
802 802
 		$DepartureAirportIata = '';
803 803
 		$ArrivalAirportIata = '';
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
811 811
 			else $departureAirport = '';
812 812
 		} else return array();
813
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
814
-		$data = $Common->getData($url,'post',$post);
813
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
814
+		$data = $Common->getData($url, 'post', $post);
815 815
 		if ($data != '') {
816 816
 			$table = $Common->table2array($data);
817 817
 			$flight = $table;
@@ -839,13 +839,13 @@  discard block
 block discarded – undo
839 839
 			}
840 840
 		}
841 841
 		if (isset($DepartureAirportIata)) {
842
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
842
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
843 843
 		} else return array();
844 844
 	}
845 845
 
846 846
 
847 847
 	
848
-	public function fetchSchedule($ident,$date = 'NOW') {
848
+	public function fetchSchedule($ident, $date = 'NOW') {
849 849
 		global $globalSchedulesSources, $globalSchedulesFetch;
850 850
 		//$Common = new Common();
851 851
 		if (!$globalSchedulesFetch) return array();
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 				// Brussels Airlines
916 916
 				case "BEL":
917 917
 				case "SN":
918
-					return $this->getBrussels($ident,$date);
918
+					return $this->getBrussels($ident, $date);
919 919
 /*
920 920
 				// Copa Airlines
921 921
 				case "CMP":
@@ -1000,17 +1000,17 @@  discard block
 block discarded – undo
1000 1000
 				// Air France
1001 1001
 				case "AF":
1002 1002
 				case "AFR":
1003
-					return $this->getAirFrance($ident,$date,'AF');
1003
+					return $this->getAirFrance($ident, $date, 'AF');
1004 1004
 				// HOP
1005 1005
 				case "A5":
1006 1006
 				case "HOP":
1007
-					return $this->getAirFrance($ident,$date,'A5');
1007
+					return $this->getAirFrance($ident, $date, 'A5');
1008 1008
 				// EasyJet
1009 1009
 				case "U2":
1010 1010
 				case "DS":
1011 1011
 				case "EZY":
1012 1012
 				case "EZS":
1013
-					return $this->getEasyJet($ident,$date);
1013
+					return $this->getEasyJet($ident, $date);
1014 1014
 				// Ryanair
1015 1015
 				case "FR":
1016 1016
 				case "RYR":
@@ -1060,25 +1060,25 @@  discard block
 block discarded – undo
1060 1060
 					return $this->getIberia($ident);
1061 1061
 				// Vietnam Airlines
1062 1062
 				case "HVN":
1063
-					return $this->getVietnamAirlines($ident,$date);
1063
+					return $this->getVietnamAirlines($ident, $date);
1064 1064
 				// Air Berlin
1065 1065
 				case "AB":
1066 1066
 				case "BER":
1067
-					return $this->getAirBerlin($ident,$date,'AB');
1067
+					return $this->getAirBerlin($ident, $date, 'AB');
1068 1068
 				// NIKI
1069 1069
 				case "HG":
1070 1070
 				case "NLY":
1071
-					return $this->getAirBerlin($ident,$date,'HG');
1071
+					return $this->getAirBerlin($ident, $date, 'HG');
1072 1072
 				// BelAir
1073 1073
 				case "4T":
1074 1074
 				case "BHP":
1075
-					return $this->getAirBerlin($ident,$date,'4T');
1075
+					return $this->getAirBerlin($ident, $date, '4T');
1076 1076
 				default:
1077 1077
 					// Randomly use a generic function to get hours
1078 1078
 					if (strlen($airline_icao) == 2) {
1079
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1079
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1080 1080
 						if (count($globalSchedulesSources) > 0) {
1081
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1081
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1082 1082
 							$source = $globalSchedulesSources[$rand];
1083 1083
 							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1084 1084
 							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
Please login to merge, or discard this patch.
require/class.Connection.php 4 patches
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -6,6 +6,9 @@  discard block
 block discarded – undo
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 23;
8 8
 	
9
+	/**
10
+	 * @param string $dbname
11
+	 */
9 12
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10 13
 	    global $globalDBdriver;
11 14
 	    if ($dbc === null) {
@@ -131,6 +134,9 @@  discard block
 block discarded – undo
131 134
 		return true;
132 135
 	}
133 136
 
137
+	/**
138
+	 * @param string $table
139
+	 */
134 140
 	public function tableExists($table)
135 141
 	{
136 142
 		global $globalDBdriver, $globalDBname;
@@ -180,6 +186,11 @@  discard block
 block discarded – undo
180 186
 	/*
181 187
 	* Check if index exist
182 188
 	*/
189
+
190
+	/**
191
+	 * @param string $table
192
+	 * @param string $index
193
+	 */
183 194
 	public function indexExists($table,$index)
184 195
 	{
185 196
 		global $globalDBdriver, $globalDBname;
@@ -225,6 +236,11 @@  discard block
 block discarded – undo
225 236
 	* Check if a column name exist in a table
226 237
 	* @return Boolean column exist or not
227 238
 	*/
239
+
240
+	/**
241
+	 * @param string $table
242
+	 * @param string $name
243
+	 */
228 244
 	public function checkColumnName($table,$name)
229 245
 	{
230 246
 		$query = "SELECT * FROM ".$table." LIMIT 0";
Please login to merge, or discard this patch.
Braces   +77 added lines, -30 removed lines patch added patch discarded remove patch
@@ -64,8 +64,11 @@  discard block
 block discarded – undo
64 64
 				$globalDBSname = $globalDBname;
65 65
 				$globalDBSuser = $globalDBuser;
66 66
 				$globalDBSpass = $globalDBpass;
67
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
68
-				else $globalDBSport = $globalDBport;
67
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
68
+					$globalDBSport = 3306;
69
+				} else {
70
+					$globalDBSport = $globalDBport;
71
+				}
69 72
 			} else {
70 73
 				$DBname = 'default';
71 74
 				$globalDBSdriver = $globalDBdriver;
@@ -73,8 +76,11 @@  discard block
 block discarded – undo
73 76
 				$globalDBSname = $globalDBname;
74 77
 				$globalDBSuser = $user;
75 78
 				$globalDBSpass = $pass;
76
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
77
-				else $globalDBSport = $globalDBport;
79
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
80
+					$globalDBSport = 3306;
81
+				} else {
82
+					$globalDBSport = $globalDBport;
83
+				}
78 84
 			}
79 85
 		} else {
80 86
 			$globalDBSdriver = $globalDB[$DBname]['driver'];
@@ -82,11 +88,16 @@  discard block
 block discarded – undo
82 88
 			$globalDBSname = $globalDB[$DBname]['name'];
83 89
 			$globalDBSuser = $globalDB[$DBname]['user'];
84 90
 			$globalDBSpass = $globalDB[$DBname]['pass'];
85
-			if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port'];
86
-			else $globalDBSport = 3306;
91
+			if (isset($globalDB[$DBname]['port'])) {
92
+				$globalDBSport = $globalDB[$DBname]['port'];
93
+			} else {
94
+				$globalDBSport = 3306;
95
+			}
87 96
 		}
88 97
 		// Set number of try to connect to DB
89
-		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5;
98
+		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) {
99
+			$globalDBretry = 5;
100
+		}
90 101
 		$i = 0;
91 102
 		while (true) {
92 103
 			try {
@@ -95,10 +106,16 @@  discard block
 block discarded – undo
95 106
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
96 107
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
97 108
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
98
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
99
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
100
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
101
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
109
+					if (!isset($globalDBTimeOut)) {
110
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
111
+					} else {
112
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
113
+					}
114
+					if (!isset($globalDBPersistent)) {
115
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
116
+					} else {
117
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
118
+					}
102 119
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
103 120
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
104 121
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -112,22 +129,34 @@  discard block
 block discarded – undo
112 129
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
113 130
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
114 131
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
115
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
116
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
117
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
118
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
132
+					if (!isset($globalDBTimeOut)) {
133
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
134
+					} else {
135
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
136
+					}
137
+					if (!isset($globalDBPersistent)) {
138
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
139
+					} else {
140
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
141
+					}
119 142
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
120 143
 				}
121 144
 				break;
122 145
 			} catch(PDOException $e) {
123 146
 				$i++;
124
-				if (isset($globalDebug) && $globalDebug) echo $e->getMessage()."\n";
147
+				if (isset($globalDebug) && $globalDebug) {
148
+					echo $e->getMessage()."\n";
149
+				}
125 150
 				//exit;
126
-				if ($i > $globalDBretry) return false;
151
+				if ($i > $globalDBretry) {
152
+					return false;
153
+				}
127 154
 				//return false;
128 155
 			}
129 156
 		}
130
-		if ($DBname === 'default') $this->db = $this->dbs['default'];
157
+		if ($DBname === 'default') {
158
+			$this->db = $this->dbs['default'];
159
+		}
131 160
 		return true;
132 161
 	}
133 162
 
@@ -139,7 +168,9 @@  discard block
 block discarded – undo
139 168
 		} else {
140 169
 			$query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'";
141 170
 		}
142
-		if ($this->db == NULL) return false;
171
+		if ($this->db == NULL) {
172
+			return false;
173
+		}
143 174
 		try {
144 175
 			//$Connection = new Connection();
145 176
 			$results = $this->db->query($query);
@@ -148,21 +179,28 @@  discard block
 block discarded – undo
148 179
 		}
149 180
 		if($results->rowCount()>0) {
150 181
 		    return true; 
182
+		} else {
183
+			return false;
151 184
 		}
152
-		else return false;
153 185
 	}
154 186
 
155 187
 	public function connectionExists()
156 188
 	{
157 189
 		global $globalDBdriver, $globalDBCheckConnection;
158
-		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true;
190
+		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) {
191
+			return true;
192
+		}
159 193
 		$query = "SELECT 1 + 1";
160
-		if ($this->db === null) return false;
194
+		if ($this->db === null) {
195
+			return false;
196
+		}
161 197
 		try {
162 198
 			$sum = @$this->db->query($query);
163 199
 			if ($sum instanceof \PDOStatement) {
164 200
 				$sum = $sum->fetchColumn(0);
165
-			} else $sum = 0;
201
+			} else {
202
+				$sum = 0;
203
+			}
166 204
 			if (intval($sum) !== 2) {
167 205
 			     return false;
168 206
 			}
@@ -196,8 +234,9 @@  discard block
 block discarded – undo
196 234
 		}
197 235
 		if($results->rowCount()>0) {
198 236
 		    return true; 
237
+		} else {
238
+			return false;
199 239
 		}
200
-		else return false;
201 240
 	}
202 241
 
203 242
 	/*
@@ -240,9 +279,12 @@  discard block
 block discarded – undo
240 279
 				echo "error : ".$e->getMessage()."\n";
241 280
 			}
242 281
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
243
-			if ($result['nb'] > 0) return true;
244
-			else return false;
245
-/*		} else {
282
+			if ($result['nb'] > 0) {
283
+				return true;
284
+			} else {
285
+				return false;
286
+			}
287
+			/*		} else {
246 288
 			$query = "SELECT * FROM ".$table." LIMIT 0";
247 289
 			try {
248 290
 				$results = $this->db->query($query);
@@ -280,7 +322,9 @@  discard block
 block discarded – undo
280 322
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
281 323
 				return $result['value'];
282 324
 			}
283
-		} else return $version;
325
+		} else {
326
+			return $version;
327
+		}
284 328
 	}
285 329
 	
286 330
 	/*
@@ -288,8 +332,11 @@  discard block
 block discarded – undo
288 332
 	* @return Boolean if latest version or not
289 333
 	*/
290 334
 	public function latest() {
291
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
292
-	    else return false;
335
+	    if ($this->check_schema_version() == $this->latest_schema) {
336
+	    	return true;
337
+	    } else {
338
+	    	return false;
339
+	    }
293 340
 	}
294 341
 
295 342
 }
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,18 +7,18 @@  discard block
 block discarded – undo
7 7
 	public $latest_schema = 26;
8 8
 	
9 9
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10
-	    global $globalDBdriver;
11
-	    if ($dbc === null) {
10
+		global $globalDBdriver;
11
+		if ($dbc === null) {
12 12
 		if ($this->db === null && $dbname === null) {
13
-		    if ($user === null && $pass === null) {
13
+			if ($user === null && $pass === null) {
14 14
 			$this->createDBConnection();
15
-		    } else {
15
+			} else {
16 16
 			$this->createDBConnection(null,$user,$pass);
17
-		    }
17
+			}
18 18
 		} else {
19
-		    $this->createDBConnection($dbname);
19
+			$this->createDBConnection($dbname);
20 20
 		}
21
-	    } elseif ($dbname === null || $dbname === 'default') {
21
+		} elseif ($dbname === null || $dbname === 'default') {
22 22
 		$this->db = $dbc;
23 23
 		if ($this->connectionExists() === false) {
24 24
 			/*
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 			*/
29 29
 			$this->createDBConnection();
30 30
 		}
31
-	    } else {
31
+		} else {
32 32
 		//$this->connectionExists();
33 33
 		$this->dbs[$dbname] = $dbc;
34
-	    }
34
+		}
35 35
 	}
36 36
 
37 37
 	public function db() {
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 	}
48 48
 
49 49
 	/**
50
-	* Creates the database connection
51
-	*
52
-	* @return Boolean of the database connection
53
-	*
54
-	*/
50
+	 * Creates the database connection
51
+	 *
52
+	 * @return Boolean of the database connection
53
+	 *
54
+	 */
55 55
 
56 56
 	public function createDBConnection($DBname = null, $user = null, $pass = null)
57 57
 	{
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			return false;
148 148
 		}
149 149
 		if($results->rowCount()>0) {
150
-		    return true; 
150
+			return true; 
151 151
 		}
152 152
 		else return false;
153 153
 	}
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
 				$sum = $sum->fetchColumn(0);
165 165
 			} else $sum = 0;
166 166
 			if (intval($sum) !== 2) {
167
-			     return false;
167
+				 return false;
168 168
 			}
169 169
 			
170 170
 		} catch(PDOException $e) {
171 171
 			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
172
-            			throw $e;
173
-	                }
174
-	                //echo 'error ! '.$e->getMessage();
172
+						throw $e;
173
+					}
174
+					//echo 'error ! '.$e->getMessage();
175 175
 			return false;
176 176
 		}
177 177
 		return true; 
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 		$version = 0;
269 269
 		if ($this->tableExists('aircraft')) {
270 270
 			if (!$this->tableExists('config')) {
271
-	    			$version = '1';
272
-	    			return $version;
271
+					$version = '1';
272
+					return $version;
273 273
 			} else {
274 274
 				$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
275 275
 				try {
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	* @return Boolean if latest version or not
290 290
 	*/
291 291
 	public function latest() {
292
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
293
-	    else return false;
292
+		if ($this->check_schema_version() == $this->latest_schema) return true;
293
+		else return false;
294 294
 	}
295 295
 
296 296
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 
4
-class Connection{
4
+class Connection {
5 5
 	public $db = null;
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 26;
8 8
 	
9
-	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
9
+	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) {
10 10
 	    global $globalDBdriver;
11 11
 	    if ($dbc === null) {
12 12
 		if ($this->db === null && $dbname === null) {
13 13
 		    if ($user === null && $pass === null) {
14 14
 			$this->createDBConnection();
15 15
 		    } else {
16
-			$this->createDBConnection(null,$user,$pass);
16
+			$this->createDBConnection(null, $user, $pass);
17 17
 		    }
18 18
 		} else {
19 19
 		    $this->createDBConnection($dbname);
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 		while (true) {
92 92
 			try {
93 93
 				if ($globalDBSdriver == 'mysql') {
94
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass);
94
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass);
95 95
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
96 96
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
97
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
98
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
99
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
100
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
101
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
97
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
98
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500);
99
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
100
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
101
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
102 102
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
103 103
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
104 104
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
 					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"');
109 109
 					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"');
110 110
 				} else {
111
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass);
111
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass);
112 112
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
113 113
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
114
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
115
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
116
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
117
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
118
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
114
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
115
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200);
116
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
117
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
118
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
119 119
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
120 120
 				}
121 121
 				break;
122
-			} catch(PDOException $e) {
122
+			} catch (PDOException $e) {
123 123
 				$i++;
124 124
 				if (isset($globalDebug) && $globalDebug) echo $e->getMessage()."\n";
125 125
 				//exit;
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 		try {
144 144
 			//$Connection = new Connection();
145 145
 			$results = $this->db->query($query);
146
-		} catch(PDOException $e) {
146
+		} catch (PDOException $e) {
147 147
 			return false;
148 148
 		}
149
-		if($results->rowCount()>0) {
149
+		if ($results->rowCount() > 0) {
150 150
 		    return true; 
151 151
 		}
152 152
 		else return false;
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 			     return false;
168 168
 			}
169 169
 			
170
-		} catch(PDOException $e) {
171
-			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
170
+		} catch (PDOException $e) {
171
+			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
172 172
             			throw $e;
173 173
 	                }
174 174
 	                //echo 'error ! '.$e->getMessage();
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	/*
181 181
 	* Check if index exist
182 182
 	*/
183
-	public function indexExists($table,$index)
183
+	public function indexExists($table, $index)
184 184
 	{
185 185
 		global $globalDBdriver, $globalDBname;
186 186
 		if ($globalDBdriver == 'mysql') {
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
 		try {
192 192
 			//$Connection = new Connection();
193 193
 			$results = $this->db->query($query);
194
-		} catch(PDOException $e) {
194
+		} catch (PDOException $e) {
195 195
 			return false;
196 196
 		}
197 197
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
198
-		if($nb[0]['nb'] > 0) {
198
+		if ($nb[0]['nb'] > 0) {
199 199
 			return true; 
200 200
 		}
201 201
 		else return false;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 		$query = "SELECT * FROM ".$table." LIMIT 0";
211 211
 		try {
212 212
 			$results = $this->db->query($query);
213
-		} catch(PDOException $e) {
213
+		} catch (PDOException $e) {
214 214
 			return "error : ".$e->getMessage()."\n";
215 215
 		}
216 216
 		$columns = array();
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	* Check if a column name exist in a table
227 227
 	* @return Boolean column exist or not
228 228
 	*/
229
-	public function checkColumnName($table,$name)
229
+	public function checkColumnName($table, $name)
230 230
 	{
231 231
 		global $globalDBdriver, $globalDBname;
232 232
 		if ($globalDBdriver == 'mysql') {
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 		}
237 237
 			try {
238 238
 				$sth = $this->db()->prepare($query);
239
-				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name));
240
-			} catch(PDOException $e) {
239
+				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name));
240
+			} catch (PDOException $e) {
241 241
 				echo "error : ".$e->getMessage()."\n";
242 242
 			}
243 243
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 				try {
277 277
 					$sth = $this->db->prepare($query);
278 278
 					$sth->execute();
279
-				} catch(PDOException $e) {
279
+				} catch (PDOException $e) {
280 280
 					return "error : ".$e->getMessage()."\n";
281 281
 				}
282 282
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
install/class.update_db.php 4 patches
Doc Comments   +42 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@  discard block
 block discarded – undo
10 10
 class update_db {
11 11
 	public static $db_sqlite;
12 12
 
13
+	/**
14
+	 * @param string $file
15
+	 */
13 16
 	public static function download($url, $file, $referer = '') {
14 17
 		$fp = fopen($file, 'w+');
15 18
 		$ch = curl_init();
@@ -24,6 +27,9 @@  discard block
 block discarded – undo
24 27
 		fclose($fp);
25 28
 	}
26 29
 
30
+	/**
31
+	 * @param string $in_file
32
+	 */
27 33
 	public static function gunzip($in_file,$out_file_name = '') {
28 34
 		//echo $in_file.' -> '.$out_file_name."\n";
29 35
 		$buffer_size = 4096; // read 4kb at a time
@@ -45,6 +51,9 @@  discard block
 block discarded – undo
45 51
 		}
46 52
 	}
47 53
 
54
+	/**
55
+	 * @param string $in_file
56
+	 */
48 57
 	public static function unzip($in_file) {
49 58
 		if ($in_file != '' && file_exists($in_file)) {
50 59
 			$path = pathinfo(realpath($in_file), PATHINFO_DIRNAME);
@@ -66,6 +75,9 @@  discard block
 block discarded – undo
66 75
 		}
67 76
 	}
68 77
 	
78
+	/**
79
+	 * @param string $database_file
80
+	 */
69 81
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 82
 		global $globalDebug, $globalTransaction;
71 83
 		//$query = 'TRUNCATE TABLE routes';
@@ -108,6 +120,10 @@  discard block
 block discarded – undo
108 120
 		}
109 121
                 return '';
110 122
 	}
123
+
124
+	/**
125
+	 * @param string $database_file
126
+	 */
111 127
 	public static function retrieve_route_oneworld($database_file) {
112 128
 		global $globalDebug, $globalTransaction;
113 129
 		//$query = 'TRUNCATE TABLE routes';
@@ -147,6 +163,9 @@  discard block
 block discarded – undo
147 163
                 return '';
148 164
 	}
149 165
 	
166
+	/**
167
+	 * @param string $database_file
168
+	 */
150 169
 	public static function retrieve_route_skyteam($database_file) {
151 170
 		global $globalDebug, $globalTransaction;
152 171
 		//$query = 'TRUNCATE TABLE routes';
@@ -186,6 +205,10 @@  discard block
 block discarded – undo
186 205
 		}
187 206
                 return '';
188 207
 	}
208
+
209
+	/**
210
+	 * @param string $database_file
211
+	 */
189 212
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
190 213
 		global $globalTransaction;
191 214
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -251,6 +274,9 @@  discard block
 block discarded – undo
251 274
 		return '';
252 275
 	}
253 276
 
277
+	/**
278
+	 * @param string $database_file
279
+	 */
254 280
 	public static function retrieve_modes_flarmnet($database_file) {
255 281
 		global $globalTransaction;
256 282
 		$Common = new Common();
@@ -321,6 +347,9 @@  discard block
 block discarded – undo
321 347
 		return '';
322 348
 	}
323 349
 
350
+	/**
351
+	 * @param string $database_file
352
+	 */
324 353
 	public static function retrieve_modes_ogn($database_file) {
325 354
 		global $globalTransaction;
326 355
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -389,6 +418,9 @@  discard block
 block discarded – undo
389 418
 		return '';
390 419
 	}
391 420
 
421
+	/**
422
+	 * @param string $database_file
423
+	 */
392 424
 	public static function retrieve_owner($database_file,$country = 'F') {
393 425
 		global $globalTransaction;
394 426
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -939,6 +971,10 @@  discard block
 block discarded – undo
939 971
 		return '';
940 972
         }
941 973
 
974
+	/**
975
+	 * @param string $filename
976
+	 * @param string $tletype
977
+	 */
942 978
 	public static function tle($filename,$tletype) {
943 979
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
944 980
 		global $tmp_dir, $globalTransaction;
@@ -1071,6 +1107,9 @@  discard block
 block discarded – undo
1071 1107
 
1072 1108
 	}
1073 1109
 */
1110
+	/**
1111
+	 * @param string $filename
1112
+	 */
1074 1113
 	public static function waypoints($filename) {
1075 1114
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1076 1115
 		global $tmp_dir, $globalTransaction;
@@ -1118,6 +1157,9 @@  discard block
 block discarded – undo
1118 1157
 		return '';
1119 1158
         }
1120 1159
 
1160
+	/**
1161
+	 * @param string $filename
1162
+	 */
1121 1163
 	public static function ivao_airlines($filename) {
1122 1164
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1123 1165
 		global $tmp_dir, $globalTransaction;
Please login to merge, or discard this patch.
Indentation   +382 added lines, -382 removed lines patch added patch discarded remove patch
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
 		try {
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78
-                        $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
80
-                        return "error : ".$e->getMessage();
81
-                }
78
+						$sth->execute(array(':source' => $database_file));
79
+				} catch(PDOException $e) {
80
+						return "error : ".$e->getMessage();
81
+				}
82 82
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
84
-    		update_db::connect_sqlite($database_file);
83
+			if ($globalDebug) echo " - Add routes to DB -";
84
+			update_db::connect_sqlite($database_file);
85 85
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 86
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
87 87
 		try {
88
-                        $sth = update_db::$db_sqlite->prepare($query);
89
-                        $sth->execute();
90
-                } catch(PDOException $e) {
91
-                        return "error : ".$e->getMessage();
92
-                }
88
+						$sth = update_db::$db_sqlite->prepare($query);
89
+						$sth->execute();
90
+				} catch(PDOException $e) {
91
+						return "error : ".$e->getMessage();
92
+				}
93 93
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
94 94
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$Connection = new Connection();
96 96
 		$sth_dest = $Connection->db->prepare($query_dest);
97 97
 		try {
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
99
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 101
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 102
 				$sth_dest->execute($query_dest_values);
103
-            		}
103
+					}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105 105
 		} catch(PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
109
-                return '';
109
+				return '';
110 110
 	}
111 111
 	public static function retrieve_route_oneworld($database_file) {
112 112
 		global $globalDebug, $globalTransaction;
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 		try {
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120
-                        $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
122
-                        return "error : ".$e->getMessage();
123
-                }
120
+						$sth->execute(array(':source' => 'oneworld'));
121
+				} catch(PDOException $e) {
122
+						return "error : ".$e->getMessage();
123
+				}
124 124
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
125
+			if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128 128
 		if ($fh = fopen($database_file,"r")) {
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 			if ($globalTransaction) $Connection->db->commit();
148 148
 		}
149
-                return '';
149
+				return '';
150 150
 	}
151 151
 	
152 152
 	public static function retrieve_route_skyteam($database_file) {
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 		try {
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161
-                        $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
163
-                        return "error : ".$e->getMessage();
164
-                }
161
+						$sth->execute(array(':source' => 'skyteam'));
162
+				} catch(PDOException $e) {
163
+						return "error : ".$e->getMessage();
164
+				}
165 165
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
166
+			if ($globalDebug) echo " - Add routes to DB -";
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
191 191
 		}
192
-                return '';
192
+				return '';
193 193
 	}
194 194
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
195 195
 		global $globalTransaction;
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 		try {
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201
-                        $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
203
-                        return "error : ".$e->getMessage();
204
-                }
201
+						$sth->execute(array(':source' => $database_file));
202
+				} catch(PDOException $e) {
203
+						return "error : ".$e->getMessage();
204
+				}
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
206 206
 		try {
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209
-                        $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
211
-                        return "error : ".$e->getMessage();
212
-                }
209
+						$sth->execute(array(':source' => $database_file));
210
+				} catch(PDOException $e) {
211
+						return "error : ".$e->getMessage();
212
+				}
213 213
 
214
-    		update_db::connect_sqlite($database_file);
214
+			update_db::connect_sqlite($database_file);
215 215
 		$query = 'select * from Aircraft';
216 216
 		try {
217
-                        $sth = update_db::$db_sqlite->prepare($query);
218
-                        $sth->execute();
219
-                } catch(PDOException $e) {
220
-                        return "error : ".$e->getMessage();
221
-                }
217
+						$sth = update_db::$db_sqlite->prepare($query);
218
+						$sth->execute();
219
+				} catch(PDOException $e) {
220
+						return "error : ".$e->getMessage();
221
+				}
222 222
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
223 223
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
224 224
 		
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 230
 		try {
231 231
 			if ($globalTransaction) $Connection->db->beginTransaction();
232
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
232
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 233
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236 236
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
-				    $sth_dest_owner->execute($query_dest_owner_values);
239
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+					$sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242
-            		}
242
+					}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244 244
 		} catch(PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
 		try {
250 250
 			$Connection = new Connection();
251 251
 			$sth = $Connection->db->prepare($query);
252
-                        $sth->execute(array(':source' => $database_file));
253
-                } catch(PDOException $e) {
254
-                        return "error : ".$e->getMessage();
255
-                }
252
+						$sth->execute(array(':source' => $database_file));
253
+				} catch(PDOException $e) {
254
+						return "error : ".$e->getMessage();
255
+				}
256 256
 		return '';
257 257
 	}
258 258
 
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 		try {
265 265
 			$Connection = new Connection();
266 266
 			$sth = $Connection->db->prepare($query);
267
-                        $sth->execute(array(':source' => $database_file));
268
-                } catch(PDOException $e) {
269
-                        return "error : ".$e->getMessage();
270
-                }
267
+						$sth->execute(array(':source' => $database_file));
268
+				} catch(PDOException $e) {
269
+						return "error : ".$e->getMessage();
270
+				}
271 271
 		
272 272
 		if ($fh = fopen($database_file,"r")) {
273 273
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -277,26 +277,26 @@  discard block
 block discarded – undo
277 277
 			$sth_dest = $Connection->db->prepare($query_dest);
278 278
 			try {
279 279
 				if ($globalTransaction) $Connection->db->beginTransaction();
280
-            			while (!feof($fh)) {
281
-            				$values = array();
282
-            				$line = $Common->hex2str(fgets($fh,9999));
280
+						while (!feof($fh)) {
281
+							$values = array();
282
+							$line = $Common->hex2str(fgets($fh,9999));
283 283
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
284
-            				$values['ModeS'] = substr($line,0,6);
285
-            				$values['Registration'] = trim(substr($line,69,6));
286
-            				$aircraft_name = trim(substr($line,48,6));
287
-            				// Check if we can find ICAO, else set it to GLID
288
-            				$aircraft_name_split = explode(' ',$aircraft_name);
289
-            				$search_more = '';
290
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
291
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
292
-            				$sth_search = $Connection->db->prepare($query_search);
284
+							$values['ModeS'] = substr($line,0,6);
285
+							$values['Registration'] = trim(substr($line,69,6));
286
+							$aircraft_name = trim(substr($line,48,6));
287
+							// Check if we can find ICAO, else set it to GLID
288
+							$aircraft_name_split = explode(' ',$aircraft_name);
289
+							$search_more = '';
290
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
291
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
292
+							$sth_search = $Connection->db->prepare($query_search);
293 293
 					try {
294
-                                    		$sth_search->execute();
295
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
296
-	            				//if (count($result) > 0) {
297
-	            				if (isset($result['icao']) && $result['icao'] != '') {
298
-	            				    $values['ICAOTypeCode'] = $result['icao'];
299
-	            				} 
294
+											$sth_search->execute();
295
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
296
+								//if (count($result) > 0) {
297
+								if (isset($result['icao']) && $result['icao'] != '') {
298
+									$values['ICAOTypeCode'] = $result['icao'];
299
+								} 
300 300
 					} catch(PDOException $e) {
301 301
 						return "error : ".$e->getMessage();
302 302
 					}
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
 		try {
320 320
 			$Connection = new Connection();
321 321
 			$sth = $Connection->db->prepare($query);
322
-                        $sth->execute(array(':source' => $database_file));
323
-                } catch(PDOException $e) {
324
-                        return "error : ".$e->getMessage();
325
-                }
322
+						$sth->execute(array(':source' => $database_file));
323
+				} catch(PDOException $e) {
324
+						return "error : ".$e->getMessage();
325
+				}
326 326
 		return '';
327 327
 	}
328 328
 
@@ -333,10 +333,10 @@  discard block
 block discarded – undo
333 333
 		try {
334 334
 			$Connection = new Connection();
335 335
 			$sth = $Connection->db->prepare($query);
336
-                        $sth->execute(array(':source' => $database_file));
337
-                } catch(PDOException $e) {
338
-                        return "error : ".$e->getMessage();
339
-                }
336
+						$sth->execute(array(':source' => $database_file));
337
+				} catch(PDOException $e) {
338
+						return "error : ".$e->getMessage();
339
+				}
340 340
 		
341 341
 		if ($fh = fopen($database_file,"r")) {
342 342
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -347,24 +347,24 @@  discard block
 block discarded – undo
347 347
 			try {
348 348
 				if ($globalTransaction) $Connection->db->beginTransaction();
349 349
 				$tmp = fgetcsv($fh,9999,',',"'");
350
-            			while (!feof($fh)) {
351
-            				$line = fgetcsv($fh,9999,',',"'");
350
+						while (!feof($fh)) {
351
+							$line = fgetcsv($fh,9999,',',"'");
352 352
             				
353 353
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
354 354
 					//print_r($line);
355
-            				$values['ModeS'] = $line[1];
356
-            				$values['Registration'] = $line[3];
357
-            				$aircraft_name = $line[2];
358
-            				// Check if we can find ICAO, else set it to GLID
359
-            				$aircraft_name_split = explode(' ',$aircraft_name);
360
-            				$search_more = '';
361
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
362
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
363
-            				$sth_search = $Connection->db->prepare($query_search);
355
+							$values['ModeS'] = $line[1];
356
+							$values['Registration'] = $line[3];
357
+							$aircraft_name = $line[2];
358
+							// Check if we can find ICAO, else set it to GLID
359
+							$aircraft_name_split = explode(' ',$aircraft_name);
360
+							$search_more = '';
361
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
362
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
363
+							$sth_search = $Connection->db->prepare($query_search);
364 364
 					try {
365
-                                    		$sth_search->execute();
366
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
367
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
365
+											$sth_search->execute();
366
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
367
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
368 368
 					} catch(PDOException $e) {
369 369
 						return "error : ".$e->getMessage();
370 370
 					}
@@ -387,10 +387,10 @@  discard block
 block discarded – undo
387 387
 		try {
388 388
 			$Connection = new Connection();
389 389
 			$sth = $Connection->db->prepare($query);
390
-                        $sth->execute(array(':source' => $database_file));
391
-                } catch(PDOException $e) {
392
-                        return "error : ".$e->getMessage();
393
-                }
390
+						$sth->execute(array(':source' => $database_file));
391
+				} catch(PDOException $e) {
392
+						return "error : ".$e->getMessage();
393
+				}
394 394
 		return '';
395 395
 	}
396 396
 
@@ -401,10 +401,10 @@  discard block
 block discarded – undo
401 401
 		try {
402 402
 			$Connection = new Connection();
403 403
 			$sth = $Connection->db->prepare($query);
404
-                        $sth->execute(array(':source' => $database_file));
405
-                } catch(PDOException $e) {
406
-                        return "error : ".$e->getMessage();
407
-                }
404
+						$sth->execute(array(':source' => $database_file));
405
+				} catch(PDOException $e) {
406
+						return "error : ".$e->getMessage();
407
+				}
408 408
 		
409 409
 		if ($fh = fopen($database_file,"r")) {
410 410
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -415,95 +415,95 @@  discard block
 block discarded – undo
415 415
 			try {
416 416
 				if ($globalTransaction) $Connection->db->beginTransaction();
417 417
 				$tmp = fgetcsv($fh,9999,',','"');
418
-            			while (!feof($fh)) {
419
-            				$line = fgetcsv($fh,9999,',','"');
420
-            				$values = array();
421
-            				//print_r($line);
422
-            				if ($country == 'F') {
423
-            				    $values['registration'] = $line[0];
424
-            				    $values['base'] = $line[4];
425
-            				    $values['owner'] = $line[5];
426
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
427
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
428
-					    $values['cancel'] = $line[7];
418
+						while (!feof($fh)) {
419
+							$line = fgetcsv($fh,9999,',','"');
420
+							$values = array();
421
+							//print_r($line);
422
+							if ($country == 'F') {
423
+								$values['registration'] = $line[0];
424
+								$values['base'] = $line[4];
425
+								$values['owner'] = $line[5];
426
+								if ($line[6] == '') $values['date_first_reg'] = null;
427
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
428
+						$values['cancel'] = $line[7];
429 429
 					} elseif ($country == 'EI') {
430
-					    // TODO : add modeS & reg to aircraft_modes
431
-            				    $values['registration'] = $line[0];
432
-            				    $values['base'] = $line[3];
433
-            				    $values['owner'] = $line[2];
434
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
435
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
436
-					    $values['cancel'] = '';
430
+						// TODO : add modeS & reg to aircraft_modes
431
+								$values['registration'] = $line[0];
432
+								$values['base'] = $line[3];
433
+								$values['owner'] = $line[2];
434
+								if ($line[1] == '') $values['date_first_reg'] = null;
435
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
436
+						$values['cancel'] = '';
437 437
 					} elseif ($country == 'HB') {
438
-					    // TODO : add modeS & reg to aircraft_modes
439
-            				    $values['registration'] = $line[0];
440
-            				    $values['base'] = null;
441
-            				    $values['owner'] = $line[5];
442
-            				    $values['date_first_reg'] = null;
443
-					    $values['cancel'] = '';
438
+						// TODO : add modeS & reg to aircraft_modes
439
+								$values['registration'] = $line[0];
440
+								$values['base'] = null;
441
+								$values['owner'] = $line[5];
442
+								$values['date_first_reg'] = null;
443
+						$values['cancel'] = '';
444 444
 					} elseif ($country == 'OK') {
445
-					    // TODO : add modeS & reg to aircraft_modes
446
-            				    $values['registration'] = $line[3];
447
-            				    $values['base'] = null;
448
-            				    $values['owner'] = $line[5];
449
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
451
-					    $values['cancel'] = '';
445
+						// TODO : add modeS & reg to aircraft_modes
446
+								$values['registration'] = $line[3];
447
+								$values['base'] = null;
448
+								$values['owner'] = $line[5];
449
+								if ($line[18] == '') $values['date_first_reg'] = null;
450
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
451
+						$values['cancel'] = '';
452 452
 					} elseif ($country == 'VH') {
453
-					    // TODO : add modeS & reg to aircraft_modes
454
-            				    $values['registration'] = $line[0];
455
-            				    $values['base'] = null;
456
-            				    $values['owner'] = $line[12];
457
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
458
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
459
-
460
-					    $values['cancel'] = $line[39];
453
+						// TODO : add modeS & reg to aircraft_modes
454
+								$values['registration'] = $line[0];
455
+								$values['base'] = null;
456
+								$values['owner'] = $line[12];
457
+								if ($line[28] == '') $values['date_first_reg'] = null;
458
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
459
+
460
+						$values['cancel'] = $line[39];
461 461
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
462
-            				    $values['registration'] = $line[0];
463
-            				    $values['base'] = null;
464
-            				    $values['owner'] = $line[4];
465
-            				    $values['date_first_reg'] = null;
466
-					    $values['cancel'] = '';
462
+								$values['registration'] = $line[0];
463
+								$values['base'] = null;
464
+								$values['owner'] = $line[4];
465
+								$values['date_first_reg'] = null;
466
+						$values['cancel'] = '';
467 467
 					} elseif ($country == 'CC') {
468
-            				    $values['registration'] = $line[0];
469
-            				    $values['base'] = null;
470
-            				    $values['owner'] = $line[6];
471
-            				    $values['date_first_reg'] = null;
472
-					    $values['cancel'] = '';
468
+								$values['registration'] = $line[0];
469
+								$values['base'] = null;
470
+								$values['owner'] = $line[6];
471
+								$values['date_first_reg'] = null;
472
+						$values['cancel'] = '';
473 473
 					} elseif ($country == 'HJ') {
474
-            				    $values['registration'] = $line[0];
475
-            				    $values['base'] = null;
476
-            				    $values['owner'] = $line[8];
477
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
479
-					    $values['cancel'] = '';
474
+								$values['registration'] = $line[0];
475
+								$values['base'] = null;
476
+								$values['owner'] = $line[8];
477
+								if ($line[7] == '') $values['date_first_reg'] = null;
478
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
479
+						$values['cancel'] = '';
480 480
 					} elseif ($country == 'PP') {
481
-            				    $values['registration'] = $line[0];
482
-            				    $values['base'] = null;
483
-            				    $values['owner'] = $line[4];
484
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
485
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
486
-					    $values['cancel'] = $line[7];
481
+								$values['registration'] = $line[0];
482
+								$values['base'] = null;
483
+								$values['owner'] = $line[4];
484
+								if ($line[6] == '') $values['date_first_reg'] = null;
485
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
486
+						$values['cancel'] = $line[7];
487 487
 					} elseif ($country == 'E7') {
488
-            				    $values['registration'] = $line[0];
489
-            				    $values['base'] = null;
490
-            				    $values['owner'] = $line[4];
491
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
492
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
493
-					    $values['cancel'] = '';
488
+								$values['registration'] = $line[0];
489
+								$values['base'] = null;
490
+								$values['owner'] = $line[4];
491
+								if ($line[5] == '') $values['date_first_reg'] = null;
492
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
493
+						$values['cancel'] = '';
494 494
 					} elseif ($country == '8Q') {
495
-            				    $values['registration'] = $line[0];
496
-            				    $values['base'] = null;
497
-            				    $values['owner'] = $line[3];
498
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
499
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
500
-					    $values['cancel'] = '';
495
+								$values['registration'] = $line[0];
496
+								$values['base'] = null;
497
+								$values['owner'] = $line[3];
498
+								if ($line[7] == '') $values['date_first_reg'] = null;
499
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
500
+						$values['cancel'] = '';
501 501
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
502
-            				    $values['registration'] = $line[0];
503
-            				    $values['base'] = null;
504
-            				    $values['owner'] = $line[3];
505
-            				    $values['date_first_reg'] = null;
506
-					    $values['cancel'] = '';
502
+								$values['registration'] = $line[0];
503
+								$values['base'] = null;
504
+								$values['owner'] = $line[3];
505
+								$values['date_first_reg'] = null;
506
+						$values['cancel'] = '';
507 507
 					}
508 508
 					if ($values['cancel'] == '' && $values['registration'] != null) {
509 509
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -625,20 +625,20 @@  discard block
 block discarded – undo
625 625
 		try {
626 626
 			$Connection = new Connection();
627 627
 			$sth = $Connection->db->prepare($query);
628
-                        $sth->execute();
629
-                } catch(PDOException $e) {
630
-                        return "error : ".$e->getMessage();
631
-                }
628
+						$sth->execute();
629
+				} catch(PDOException $e) {
630
+						return "error : ".$e->getMessage();
631
+				}
632 632
 
633 633
 
634 634
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
635 635
 		try {
636 636
 			$Connection = new Connection();
637 637
 			$sth = $Connection->db->prepare($query);
638
-                        $sth->execute();
639
-                } catch(PDOException $e) {
640
-                        return "error : ".$e->getMessage();
641
-                }
638
+						$sth->execute();
639
+				} catch(PDOException $e) {
640
+						return "error : ".$e->getMessage();
641
+				}
642 642
 
643 643
 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)
644 644
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
@@ -704,10 +704,10 @@  discard block
 block discarded – undo
704 704
 		try {
705 705
 			$Connection = new Connection();
706 706
 			$sth = $Connection->db->prepare($query);
707
-                        $sth->execute();
708
-                } catch(PDOException $e) {
709
-                        return "error : ".$e->getMessage();
710
-                }
707
+						$sth->execute();
708
+				} catch(PDOException $e) {
709
+						return "error : ".$e->getMessage();
710
+				}
711 711
 
712 712
 
713 713
 		if ($globalDebug) echo "Insert Not available Airport...\n";
@@ -717,10 +717,10 @@  discard block
 block discarded – undo
717 717
 		try {
718 718
 			$Connection = new Connection();
719 719
 			$sth = $Connection->db->prepare($query);
720
-                        $sth->execute($query_values);
721
-                } catch(PDOException $e) {
722
-                        return "error : ".$e->getMessage();
723
-                }
720
+						$sth->execute($query_values);
721
+				} catch(PDOException $e) {
722
+						return "error : ".$e->getMessage();
723
+				}
724 724
 		$i++;
725 725
 /*
726 726
 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 
835 835
 
836 836
 
837
-                return "success";
837
+				return "success";
838 838
 	}
839 839
 	
840 840
 	public static function translation() {
@@ -850,10 +850,10 @@  discard block
 block discarded – undo
850 850
 		try {
851 851
 			$Connection = new Connection();
852 852
 			$sth = $Connection->db->prepare($query);
853
-                        $sth->execute(array(':source' => 'translation.csv'));
854
-                } catch(PDOException $e) {
855
-                        return "error : ".$e->getMessage();
856
-                }
853
+						$sth->execute(array(':source' => 'translation.csv'));
854
+				} catch(PDOException $e) {
855
+						return "error : ".$e->getMessage();
856
+				}
857 857
 
858 858
 		
859 859
 		//update_db::unzip($out_file);
@@ -872,21 +872,21 @@  discard block
 block discarded – undo
872 872
 					$data = $row;
873 873
 					$operator = $data[2];
874 874
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
875
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
876
-                                                //echo substr($operator, 0, 2)."\n";;
877
-                                                if (count($airline_array) > 0) {
875
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
876
+												//echo substr($operator, 0, 2)."\n";;
877
+												if (count($airline_array) > 0) {
878 878
 							//print_r($airline_array);
879 879
 							$operator = $airline_array[0]['icao'].substr($operator,2);
880
-                                                }
881
-                                        }
880
+												}
881
+										}
882 882
 					
883 883
 					$operator_correct = $data[3];
884 884
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
885
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
886
-                                                if (count($airline_array) > 0) {
887
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
888
-                                            	}
889
-                                        }
885
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
886
+												if (count($airline_array) > 0) {
887
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
888
+												}
889
+										}
890 890
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
891 891
 					try {
892 892
 						$sth = $Connection->db->prepare($query);
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 			//$Connection->db->commit();
901 901
 		}
902 902
 		return '';
903
-        }
903
+		}
904 904
 	
905 905
 	public static function translation_fam() {
906 906
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -910,10 +910,10 @@  discard block
 block discarded – undo
910 910
 		try {
911 911
 			$Connection = new Connection();
912 912
 			$sth = $Connection->db->prepare($query);
913
-                        $sth->execute(array(':source' => 'website_fam'));
914
-                } catch(PDOException $e) {
915
-                        return "error : ".$e->getMessage();
916
-                }
913
+						$sth->execute(array(':source' => 'website_fam'));
914
+				} catch(PDOException $e) {
915
+						return "error : ".$e->getMessage();
916
+				}
917 917
 
918 918
 		
919 919
 		//update_db::unzip($out_file);
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 			//$Connection->db->commit();
943 943
 		}
944 944
 		return '';
945
-        }
945
+		}
946 946
 
947 947
 	public static function modes_fam() {
948 948
 		global $tmp_dir, $globalTransaction;
@@ -950,10 +950,10 @@  discard block
 block discarded – undo
950 950
 		try {
951 951
 			$Connection = new Connection();
952 952
 			$sth = $Connection->db->prepare($query);
953
-                        $sth->execute(array(':source' => 'website_fam'));
954
-                } catch(PDOException $e) {
955
-                        return "error : ".$e->getMessage();
956
-                }
953
+						$sth->execute(array(':source' => 'website_fam'));
954
+				} catch(PDOException $e) {
955
+						return "error : ".$e->getMessage();
956
+				}
957 957
 
958 958
 		
959 959
 		//update_db::unzip($out_file);
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 			if ($globalTransaction) $Connection->db->commit();
983 983
 		}
984 984
 		return '';
985
-        }
985
+		}
986 986
 
987 987
 	public static function routes_fam() {
988 988
 		global $tmp_dir, $globalTransaction;
@@ -990,10 +990,10 @@  discard block
 block discarded – undo
990 990
 		try {
991 991
 			$Connection = new Connection();
992 992
 			$sth = $Connection->db->prepare($query);
993
-                        $sth->execute(array(':source' => 'website_fam'));
994
-                } catch(PDOException $e) {
995
-                        return "error : ".$e->getMessage();
996
-                }
993
+						$sth->execute(array(':source' => 'website_fam'));
994
+				} catch(PDOException $e) {
995
+						return "error : ".$e->getMessage();
996
+				}
997 997
 
998 998
 		
999 999
 		//update_db::unzip($out_file);
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
 			if ($globalTransaction) $Connection->db->commit();
1023 1023
 		}
1024 1024
 		return '';
1025
-        }
1025
+		}
1026 1026
 
1027 1027
 	public static function tle($filename,$tletype) {
1028 1028
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1033,10 +1033,10 @@  discard block
 block discarded – undo
1033 1033
 		try {
1034 1034
 			$Connection = new Connection();
1035 1035
 			$sth = $Connection->db->prepare($query);
1036
-                        $sth->execute(array(':source' => $filename));
1037
-                } catch(PDOException $e) {
1038
-                        return "error : ".$e->getMessage();
1039
-                }
1036
+						$sth->execute(array(':source' => $filename));
1037
+				} catch(PDOException $e) {
1038
+						return "error : ".$e->getMessage();
1039
+				}
1040 1040
 		
1041 1041
 		$Connection = new Connection();
1042 1042
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1071,54 +1071,54 @@  discard block
 block discarded – undo
1071 1071
 			//$Connection->db->commit();
1072 1072
 		}
1073 1073
 		return '';
1074
-        }
1074
+		}
1075 1075
 
1076 1076
 	/**
1077
-        * Convert a HTML table to an array
1078
-        * @param String $data HTML page
1079
-        * @return Array array of the tables in HTML page
1080
-        */
1081
-        private static function table2array($data) {
1082
-                $html = str_get_html($data);
1083
-                $tabledata=array();
1084
-                foreach($html->find('tr') as $element)
1085
-                {
1086
-                        $td = array();
1087
-                        foreach( $element->find('th') as $row)
1088
-                        {
1089
-                                $td [] = trim($row->plaintext);
1090
-                        }
1091
-                        $td=array_filter($td);
1092
-                        $tabledata[] = $td;
1093
-
1094
-                        $td = array();
1095
-                        $tdi = array();
1096
-                        foreach( $element->find('td') as $row)
1097
-                        {
1098
-                                $td [] = trim($row->plaintext);
1099
-                                $tdi [] = trim($row->innertext);
1100
-                        }
1101
-                        $td=array_filter($td);
1102
-                        $tdi=array_filter($tdi);
1103
-                    //    $tabledata[]=array_merge($td,$tdi);
1104
-                        $tabledata[]=$td;
1105
-                }
1106
-                return(array_filter($tabledata));
1107
-        }
1108
-
1109
-       /**
1110
-        * Get data from form result
1111
-        * @param String $url form URL
1112
-        * @return String the result
1113
-        */
1114
-        private static function getData($url) {
1115
-                $ch = curl_init();
1116
-                curl_setopt($ch, CURLOPT_URL, $url);
1117
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1118
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1119
-                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');
1120
-                return curl_exec($ch);
1121
-        }
1077
+	 * Convert a HTML table to an array
1078
+	 * @param String $data HTML page
1079
+	 * @return Array array of the tables in HTML page
1080
+	 */
1081
+		private static function table2array($data) {
1082
+				$html = str_get_html($data);
1083
+				$tabledata=array();
1084
+				foreach($html->find('tr') as $element)
1085
+				{
1086
+						$td = array();
1087
+						foreach( $element->find('th') as $row)
1088
+						{
1089
+								$td [] = trim($row->plaintext);
1090
+						}
1091
+						$td=array_filter($td);
1092
+						$tabledata[] = $td;
1093
+
1094
+						$td = array();
1095
+						$tdi = array();
1096
+						foreach( $element->find('td') as $row)
1097
+						{
1098
+								$td [] = trim($row->plaintext);
1099
+								$tdi [] = trim($row->innertext);
1100
+						}
1101
+						$td=array_filter($td);
1102
+						$tdi=array_filter($tdi);
1103
+					//    $tabledata[]=array_merge($td,$tdi);
1104
+						$tabledata[]=$td;
1105
+				}
1106
+				return(array_filter($tabledata));
1107
+		}
1108
+
1109
+	   /**
1110
+	    * Get data from form result
1111
+	    * @param String $url form URL
1112
+	    * @return String the result
1113
+	    */
1114
+		private static function getData($url) {
1115
+				$ch = curl_init();
1116
+				curl_setopt($ch, CURLOPT_URL, $url);
1117
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1118
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1119
+				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');
1120
+				return curl_exec($ch);
1121
+		}
1122 1122
 /*
1123 1123
 	public static function waypoints() {
1124 1124
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 			if ($globalTransaction) $Connection->db->commit();
1202 1202
 		}
1203 1203
 		return '';
1204
-        }
1204
+		}
1205 1205
 
1206 1206
 	public static function ivao_airlines($filename) {
1207 1207
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1211,10 +1211,10 @@  discard block
 block discarded – undo
1211 1211
 		try {
1212 1212
 			$Connection = new Connection();
1213 1213
 			$sth = $Connection->db->prepare($query);
1214
-                        $sth->execute();
1215
-                } catch(PDOException $e) {
1216
-                        return "error : ".$e->getMessage();
1217
-                }
1214
+						$sth->execute();
1215
+				} catch(PDOException $e) {
1216
+						return "error : ".$e->getMessage();
1217
+				}
1218 1218
 
1219 1219
 		$header = NULL;
1220 1220
 		$delimiter = ':';
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
 			if ($globalTransaction) $Connection->db->commit();
1239 1239
 		}
1240 1240
 		return '';
1241
-        }
1241
+		}
1242 1242
 	
1243 1243
 	public static function update_airspace() {
1244 1244
 		global $tmp_dir, $globalDBdriver;
@@ -1248,11 +1248,11 @@  discard block
 block discarded – undo
1248 1248
 			$query = 'DROP TABLE airspace';
1249 1249
 			try {
1250 1250
 				$sth = $Connection->db->prepare($query);
1251
-                    		$sth->execute();
1252
-	                } catch(PDOException $e) {
1251
+							$sth->execute();
1252
+					} catch(PDOException $e) {
1253 1253
 				return "error : ".$e->getMessage();
1254
-	                }
1255
-	        }
1254
+					}
1255
+			}
1256 1256
 
1257 1257
 
1258 1258
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1307,10 +1307,10 @@  discard block
 block discarded – undo
1307 1307
 			$query = 'DROP TABLE countries';
1308 1308
 			try {
1309 1309
 				$sth = $Connection->db->prepare($query);
1310
-            	        	$sth->execute();
1311
-	                } catch(PDOException $e) {
1312
-    	                	echo "error : ".$e->getMessage();
1313
-	                }
1310
+							$sth->execute();
1311
+					} catch(PDOException $e) {
1312
+							echo "error : ".$e->getMessage();
1313
+					}
1314 1314
 		}
1315 1315
 		if ($globalDBdriver == 'mysql') {
1316 1316
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -1735,11 +1735,11 @@  discard block
 block discarded – undo
1735 1735
 						$query = 'DROP TABLE airspace';
1736 1736
 						try {
1737 1737
 							$sth = $Connection->db->prepare($query);
1738
-    	    	    					$sth->execute();
1739
-			            		} catch(PDOException $e) {
1738
+										$sth->execute();
1739
+								} catch(PDOException $e) {
1740 1740
 							return "error : ".$e->getMessage();
1741
-		            			}
1742
-		    			}
1741
+								}
1742
+						}
1743 1743
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1744 1744
 					update_db::insert_airspace_version($airspace_md5);
1745 1745
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -1859,12 +1859,12 @@  discard block
 block discarded – undo
1859 1859
 		echo $data;
1860 1860
 		*/
1861 1861
 		if (file_exists($tmp_dir.'aircrafts.html')) {
1862
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1863
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
1864
-		    $result = fread($fh,100000000);
1865
-		    //echo $result;
1866
-		    //var_dump(str_get_html($result));
1867
-		    //print_r(self::table2array($result));
1862
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1863
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
1864
+			$result = fread($fh,100000000);
1865
+			//echo $result;
1866
+			//var_dump(str_get_html($result));
1867
+			//print_r(self::table2array($result));
1868 1868
 		}
1869 1869
 
1870 1870
 	}
@@ -1878,10 +1878,10 @@  discard block
 block discarded – undo
1878 1878
 		try {
1879 1879
 			$Connection = new Connection();
1880 1880
 			$sth = $Connection->db->prepare($query);
1881
-                        $sth->execute();
1882
-                } catch(PDOException $e) {
1883
-                        return "error : ".$e->getMessage();
1884
-                }
1881
+						$sth->execute();
1882
+				} catch(PDOException $e) {
1883
+						return "error : ".$e->getMessage();
1884
+				}
1885 1885
 
1886 1886
 		$error = '';
1887 1887
 		if ($globalDebug) echo "Notam : Download...";
@@ -1937,8 +1937,8 @@  discard block
 block discarded – undo
1937 1937
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
1938 1938
 					$data['permanent'] = 0;
1939 1939
 				} else {
1940
-				    $data['date_end'] = NULL;
1941
-				    $data['permanent'] = 1;
1940
+					$data['date_end'] = NULL;
1941
+					$data['permanent'] = 1;
1942 1942
 				}
1943 1943
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
1944 1944
 				$NOTAM = new NOTAM();
@@ -1997,13 +1997,13 @@  discard block
 block discarded – undo
1997 1997
 		try {
1998 1998
 			$Connection = new Connection();
1999 1999
 			$sth = $Connection->db->prepare($query);
2000
-                        $sth->execute();
2001
-                } catch(PDOException $e) {
2002
-                        return "error : ".$e->getMessage();
2003
-                }
2004
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2005
-                if ($row['nb'] > 0) return false;
2006
-                else return true;
2000
+						$sth->execute();
2001
+				} catch(PDOException $e) {
2002
+						return "error : ".$e->getMessage();
2003
+				}
2004
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2005
+				if ($row['nb'] > 0) return false;
2006
+				else return true;
2007 2007
 	}
2008 2008
 
2009 2009
 	public static function insert_last_update() {
@@ -2012,10 +2012,10 @@  discard block
 block discarded – undo
2012 2012
 		try {
2013 2013
 			$Connection = new Connection();
2014 2014
 			$sth = $Connection->db->prepare($query);
2015
-                        $sth->execute();
2016
-                } catch(PDOException $e) {
2017
-                        return "error : ".$e->getMessage();
2018
-                }
2015
+						$sth->execute();
2016
+				} catch(PDOException $e) {
2017
+						return "error : ".$e->getMessage();
2018
+				}
2019 2019
 	}
2020 2020
 
2021 2021
 	public static function check_airspace_version($version) {
@@ -2023,13 +2023,13 @@  discard block
 block discarded – undo
2023 2023
 		try {
2024 2024
 			$Connection = new Connection();
2025 2025
 			$sth = $Connection->db->prepare($query);
2026
-                        $sth->execute(array(':version' => $version));
2027
-                } catch(PDOException $e) {
2028
-                        return "error : ".$e->getMessage();
2029
-                }
2030
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2031
-                if ($row['nb'] > 0) return true;
2032
-                else return false;
2026
+						$sth->execute(array(':version' => $version));
2027
+				} catch(PDOException $e) {
2028
+						return "error : ".$e->getMessage();
2029
+				}
2030
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2031
+				if ($row['nb'] > 0) return true;
2032
+				else return false;
2033 2033
 	}
2034 2034
 
2035 2035
 
@@ -2039,10 +2039,10 @@  discard block
 block discarded – undo
2039 2039
 		try {
2040 2040
 			$Connection = new Connection();
2041 2041
 			$sth = $Connection->db->prepare($query);
2042
-                        $sth->execute(array(':version' => $version));
2043
-                } catch(PDOException $e) {
2044
-                        return "error : ".$e->getMessage();
2045
-                }
2042
+						$sth->execute(array(':version' => $version));
2043
+				} catch(PDOException $e) {
2044
+						return "error : ".$e->getMessage();
2045
+				}
2046 2046
 	}
2047 2047
 
2048 2048
 	public static function check_last_notam_update() {
@@ -2055,13 +2055,13 @@  discard block
 block discarded – undo
2055 2055
 		try {
2056 2056
 			$Connection = new Connection();
2057 2057
 			$sth = $Connection->db->prepare($query);
2058
-                        $sth->execute();
2059
-                } catch(PDOException $e) {
2060
-                        return "error : ".$e->getMessage();
2061
-                }
2062
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2063
-                if ($row['nb'] > 0) return false;
2064
-                else return true;
2058
+						$sth->execute();
2059
+				} catch(PDOException $e) {
2060
+						return "error : ".$e->getMessage();
2061
+				}
2062
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2063
+				if ($row['nb'] > 0) return false;
2064
+				else return true;
2065 2065
 	}
2066 2066
 
2067 2067
 	public static function insert_last_notam_update() {
@@ -2070,10 +2070,10 @@  discard block
 block discarded – undo
2070 2070
 		try {
2071 2071
 			$Connection = new Connection();
2072 2072
 			$sth = $Connection->db->prepare($query);
2073
-                        $sth->execute();
2074
-                } catch(PDOException $e) {
2075
-                        return "error : ".$e->getMessage();
2076
-                }
2073
+						$sth->execute();
2074
+				} catch(PDOException $e) {
2075
+						return "error : ".$e->getMessage();
2076
+				}
2077 2077
 	}
2078 2078
 	public static function check_last_airspace_update() {
2079 2079
 		global $globalDBdriver;
@@ -2085,13 +2085,13 @@  discard block
 block discarded – undo
2085 2085
 		try {
2086 2086
 			$Connection = new Connection();
2087 2087
 			$sth = $Connection->db->prepare($query);
2088
-                        $sth->execute();
2089
-                } catch(PDOException $e) {
2090
-                        return "error : ".$e->getMessage();
2091
-                }
2092
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2093
-                if ($row['nb'] > 0) return false;
2094
-                else return true;
2088
+						$sth->execute();
2089
+				} catch(PDOException $e) {
2090
+						return "error : ".$e->getMessage();
2091
+				}
2092
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2093
+				if ($row['nb'] > 0) return false;
2094
+				else return true;
2095 2095
 	}
2096 2096
 
2097 2097
 	public static function insert_last_airspace_update() {
@@ -2100,10 +2100,10 @@  discard block
 block discarded – undo
2100 2100
 		try {
2101 2101
 			$Connection = new Connection();
2102 2102
 			$sth = $Connection->db->prepare($query);
2103
-                        $sth->execute();
2104
-                } catch(PDOException $e) {
2105
-                        return "error : ".$e->getMessage();
2106
-                }
2103
+						$sth->execute();
2104
+				} catch(PDOException $e) {
2105
+						return "error : ".$e->getMessage();
2106
+				}
2107 2107
 	}
2108 2108
 
2109 2109
 	public static function check_last_owner_update() {
@@ -2116,13 +2116,13 @@  discard block
 block discarded – undo
2116 2116
 		try {
2117 2117
 			$Connection = new Connection();
2118 2118
 			$sth = $Connection->db->prepare($query);
2119
-                        $sth->execute();
2120
-                } catch(PDOException $e) {
2121
-                        return "error : ".$e->getMessage();
2122
-                }
2123
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2124
-                if ($row['nb'] > 0) return false;
2125
-                else return true;
2119
+						$sth->execute();
2120
+				} catch(PDOException $e) {
2121
+						return "error : ".$e->getMessage();
2122
+				}
2123
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2124
+				if ($row['nb'] > 0) return false;
2125
+				else return true;
2126 2126
 	}
2127 2127
 
2128 2128
 	public static function insert_last_owner_update() {
@@ -2131,10 +2131,10 @@  discard block
 block discarded – undo
2131 2131
 		try {
2132 2132
 			$Connection = new Connection();
2133 2133
 			$sth = $Connection->db->prepare($query);
2134
-                        $sth->execute();
2135
-                } catch(PDOException $e) {
2136
-                        return "error : ".$e->getMessage();
2137
-                }
2134
+						$sth->execute();
2135
+				} catch(PDOException $e) {
2136
+						return "error : ".$e->getMessage();
2137
+				}
2138 2138
 	}
2139 2139
 	public static function check_last_schedules_update() {
2140 2140
 		global $globalDBdriver;
@@ -2146,13 +2146,13 @@  discard block
 block discarded – undo
2146 2146
 		try {
2147 2147
 			$Connection = new Connection();
2148 2148
 			$sth = $Connection->db->prepare($query);
2149
-                        $sth->execute();
2150
-                } catch(PDOException $e) {
2151
-                        return "error : ".$e->getMessage();
2152
-                }
2153
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2154
-                if ($row['nb'] > 0) return false;
2155
-                else return true;
2149
+						$sth->execute();
2150
+				} catch(PDOException $e) {
2151
+						return "error : ".$e->getMessage();
2152
+				}
2153
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2154
+				if ($row['nb'] > 0) return false;
2155
+				else return true;
2156 2156
 	}
2157 2157
 
2158 2158
 	public static function insert_last_schedules_update() {
@@ -2161,10 +2161,10 @@  discard block
 block discarded – undo
2161 2161
 		try {
2162 2162
 			$Connection = new Connection();
2163 2163
 			$sth = $Connection->db->prepare($query);
2164
-                        $sth->execute();
2165
-                } catch(PDOException $e) {
2166
-                        return "error : ".$e->getMessage();
2167
-                }
2164
+						$sth->execute();
2165
+				} catch(PDOException $e) {
2166
+						return "error : ".$e->getMessage();
2167
+				}
2168 2168
 	}
2169 2169
 	public static function check_last_tle_update() {
2170 2170
 		global $globalDBdriver;
@@ -2176,13 +2176,13 @@  discard block
 block discarded – undo
2176 2176
 		try {
2177 2177
 			$Connection = new Connection();
2178 2178
 			$sth = $Connection->db->prepare($query);
2179
-                        $sth->execute();
2180
-                } catch(PDOException $e) {
2181
-                        return "error : ".$e->getMessage();
2182
-                }
2183
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2184
-                if ($row['nb'] > 0) return false;
2185
-                else return true;
2179
+						$sth->execute();
2180
+				} catch(PDOException $e) {
2181
+						return "error : ".$e->getMessage();
2182
+				}
2183
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2184
+				if ($row['nb'] > 0) return false;
2185
+				else return true;
2186 2186
 	}
2187 2187
 
2188 2188
 	public static function insert_last_tle_update() {
@@ -2191,10 +2191,10 @@  discard block
 block discarded – undo
2191 2191
 		try {
2192 2192
 			$Connection = new Connection();
2193 2193
 			$sth = $Connection->db->prepare($query);
2194
-                        $sth->execute();
2195
-                } catch(PDOException $e) {
2196
-                        return "error : ".$e->getMessage();
2197
-                }
2194
+						$sth->execute();
2195
+				} catch(PDOException $e) {
2196
+						return "error : ".$e->getMessage();
2197
+				}
2198 2198
 	}
2199 2199
 	
2200 2200
 	public static function update_all() {
Please login to merge, or discard this patch.
Spacing   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
 		fclose($fp);
25 25
 	}
26 26
 
27
-	public static function gunzip($in_file,$out_file_name = '') {
27
+	public static function gunzip($in_file, $out_file_name = '') {
28 28
 		//echo $in_file.' -> '.$out_file_name."\n";
29 29
 		$buffer_size = 4096; // read 4kb at a time
30 30
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
31 31
 		if ($in_file != '' && file_exists($in_file)) {
32 32
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
33
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
34
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
35 35
 			else {
36 36
 				echo 'gzopen not available';
37 37
 				die;
38 38
 			}
39 39
 			$out_file = fopen($out_file_name, 'wb'); 
40
-			while(!gzeof($file)) {
40
+			while (!gzeof($file)) {
41 41
 				fwrite($out_file, gzread($file, $buffer_size));
42 42
 			}  
43 43
 			fclose($out_file);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		try {
62 62
 			self::$db_sqlite = new PDO('sqlite:'.$database);
63 63
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
64
-		} catch(PDOException $e) {
64
+		} catch (PDOException $e) {
65 65
 			return "error : ".$e->getMessage();
66 66
 		}
67 67
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78 78
                         $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
79
+                } catch (PDOException $e) {
80 80
                         return "error : ".$e->getMessage();
81 81
                 }
82 82
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		try {
88 88
                         $sth = update_db::$db_sqlite->prepare($query);
89 89
                         $sth->execute();
90
-                } catch(PDOException $e) {
90
+                } catch (PDOException $e) {
91 91
                         return "error : ".$e->getMessage();
92 92
                 }
93 93
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99 99
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
102 102
 				$sth_dest->execute($query_dest_values);
103 103
             		}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120 120
                         $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
121
+                } catch (PDOException $e) {
122 122
                         return "error : ".$e->getMessage();
123 123
                 }
124 124
 
125 125
     		if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128
-		if ($fh = fopen($database_file,"r")) {
128
+		if ($fh = fopen($database_file, "r")) {
129 129
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 130
 			$Connection = new Connection();
131 131
 			$sth_dest = $Connection->db->prepare($query_dest);
132 132
 			if ($globalTransaction) $Connection->db->beginTransaction();
133 133
 			while (!feof($fh)) {
134
-				$line = fgetcsv($fh,9999,',');
134
+				$line = fgetcsv($fh, 9999, ',');
135 135
 				if ($line[0] != '') {
136 136
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
137 137
 						try {
138
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
138
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
139 139
 							$sth_dest->execute($query_dest_values);
140
-						} catch(PDOException $e) {
140
+						} catch (PDOException $e) {
141 141
 							if ($globalTransaction) $Connection->db->rollBack(); 
142 142
 							return "error : ".$e->getMessage();
143 143
 						}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161 161
                         $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
162
+                } catch (PDOException $e) {
163 163
                         return "error : ".$e->getMessage();
164 164
                 }
165 165
 
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
170
-		if ($fh = fopen($database_file,"r")) {
170
+		if ($fh = fopen($database_file, "r")) {
171 171
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
172 172
 			$Connection = new Connection();
173 173
 			$sth_dest = $Connection->db->prepare($query_dest);
174 174
 			try {
175 175
 				if ($globalTransaction) $Connection->db->beginTransaction();
176 176
 				while (!feof($fh)) {
177
-					$line = fgetcsv($fh,9999,',');
177
+					$line = fgetcsv($fh, 9999, ',');
178 178
 					if ($line[0] != '') {
179
-						$datebe = explode('  -  ',$line[2]);
179
+						$datebe = explode('  -  ', $line[2]);
180 180
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
181
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
181
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
182 182
 							$sth_dest->execute($query_dest_values);
183 183
 						}
184 184
 					}
185 185
 				}
186 186
 				if ($globalTransaction) $Connection->db->commit();
187
-			} catch(PDOException $e) {
187
+			} catch (PDOException $e) {
188 188
 				if ($globalTransaction) $Connection->db->rollBack(); 
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201 201
                         $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
202
+                } catch (PDOException $e) {
203 203
                         return "error : ".$e->getMessage();
204 204
                 }
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209 209
                         $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
210
+                } catch (PDOException $e) {
211 211
                         return "error : ".$e->getMessage();
212 212
                 }
213 213
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		try {
217 217
                         $sth = update_db::$db_sqlite->prepare($query);
218 218
                         $sth->execute();
219
-                } catch(PDOException $e) {
219
+                } catch (PDOException $e) {
220 220
                         return "error : ".$e->getMessage();
221 221
                 }
222 222
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
236
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
239
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
240 240
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242 242
             		}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244
-		} catch(PDOException $e) {
244
+		} catch (PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
246 246
 		}
247 247
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			$Connection = new Connection();
251 251
 			$sth = $Connection->db->prepare($query);
252 252
                         $sth->execute(array(':source' => $database_file));
253
-                } catch(PDOException $e) {
253
+                } catch (PDOException $e) {
254 254
                         return "error : ".$e->getMessage();
255 255
                 }
256 256
 		return '';
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
 			$Connection = new Connection();
266 266
 			$sth = $Connection->db->prepare($query);
267 267
                         $sth->execute(array(':source' => $database_file));
268
-                } catch(PDOException $e) {
268
+                } catch (PDOException $e) {
269 269
                         return "error : ".$e->getMessage();
270 270
                 }
271 271
 		
272
-		if ($fh = fopen($database_file,"r")) {
272
+		if ($fh = fopen($database_file, "r")) {
273 273
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
274 274
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
275 275
 		
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
 				if ($globalTransaction) $Connection->db->beginTransaction();
280 280
             			while (!feof($fh)) {
281 281
             				$values = array();
282
-            				$line = $Common->hex2str(fgets($fh,9999));
282
+            				$line = $Common->hex2str(fgets($fh, 9999));
283 283
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
284
-            				$values['ModeS'] = substr($line,0,6);
285
-            				$values['Registration'] = trim(substr($line,69,6));
286
-            				$aircraft_name = trim(substr($line,48,6));
284
+            				$values['ModeS'] = substr($line, 0, 6);
285
+            				$values['Registration'] = trim(substr($line, 69, 6));
286
+            				$aircraft_name = trim(substr($line, 48, 6));
287 287
             				// Check if we can find ICAO, else set it to GLID
288
-            				$aircraft_name_split = explode(' ',$aircraft_name);
288
+            				$aircraft_name_split = explode(' ', $aircraft_name);
289 289
             				$search_more = '';
290 290
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
291 291
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -297,20 +297,20 @@  discard block
 block discarded – undo
297 297
 	            				if (isset($result['icao']) && $result['icao'] != '') {
298 298
 	            				    $values['ICAOTypeCode'] = $result['icao'];
299 299
 	            				} 
300
-					} catch(PDOException $e) {
300
+					} catch (PDOException $e) {
301 301
 						return "error : ".$e->getMessage();
302 302
 					}
303 303
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
304 304
 					// Add data to db
305 305
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') {
306 306
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
307
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
307
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
308 308
 						//print_r($query_dest_values);
309 309
 						$sth_dest->execute($query_dest_values);
310 310
 					}
311 311
 				}
312 312
 				if ($globalTransaction) $Connection->db->commit();
313
-			} catch(PDOException $e) {
313
+			} catch (PDOException $e) {
314 314
 				return "error : ".$e->getMessage();
315 315
 			}
316 316
 		}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 			$Connection = new Connection();
321 321
 			$sth = $Connection->db->prepare($query);
322 322
                         $sth->execute(array(':source' => $database_file));
323
-                } catch(PDOException $e) {
323
+                } catch (PDOException $e) {
324 324
                         return "error : ".$e->getMessage();
325 325
                 }
326 326
 		return '';
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
 			$Connection = new Connection();
335 335
 			$sth = $Connection->db->prepare($query);
336 336
                         $sth->execute(array(':source' => $database_file));
337
-                } catch(PDOException $e) {
337
+                } catch (PDOException $e) {
338 338
                         return "error : ".$e->getMessage();
339 339
                 }
340 340
 		
341
-		if ($fh = fopen($database_file,"r")) {
341
+		if ($fh = fopen($database_file, "r")) {
342 342
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
343 343
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
344 344
 		
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
 			$sth_dest = $Connection->db->prepare($query_dest);
347 347
 			try {
348 348
 				if ($globalTransaction) $Connection->db->beginTransaction();
349
-				$tmp = fgetcsv($fh,9999,',',"'");
349
+				$tmp = fgetcsv($fh, 9999, ',', "'");
350 350
             			while (!feof($fh)) {
351
-            				$line = fgetcsv($fh,9999,',',"'");
351
+            				$line = fgetcsv($fh, 9999, ',', "'");
352 352
             				
353 353
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
354 354
 					//print_r($line);
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
             				$values['Registration'] = $line[3];
357 357
             				$aircraft_name = $line[2];
358 358
             				// Check if we can find ICAO, else set it to GLID
359
-            				$aircraft_name_split = explode(' ',$aircraft_name);
359
+            				$aircraft_name_split = explode(' ', $aircraft_name);
360 360
             				$search_more = '';
361 361
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
362 362
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -365,20 +365,20 @@  discard block
 block discarded – undo
365 365
                                     		$sth_search->execute();
366 366
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
367 367
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
368
-					} catch(PDOException $e) {
368
+					} catch (PDOException $e) {
369 369
 						return "error : ".$e->getMessage();
370 370
 					}
371 371
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
372 372
 					// Add data to db
373 373
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
374 374
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
375
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
375
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
376 376
 						//print_r($query_dest_values);
377 377
 						$sth_dest->execute($query_dest_values);
378 378
 					}
379 379
 				}
380 380
 				if ($globalTransaction) $Connection->db->commit();
381
-			} catch(PDOException $e) {
381
+			} catch (PDOException $e) {
382 382
 				return "error : ".$e->getMessage();
383 383
 			}
384 384
 		}
@@ -388,13 +388,13 @@  discard block
 block discarded – undo
388 388
 			$Connection = new Connection();
389 389
 			$sth = $Connection->db->prepare($query);
390 390
                         $sth->execute(array(':source' => $database_file));
391
-                } catch(PDOException $e) {
391
+                } catch (PDOException $e) {
392 392
                         return "error : ".$e->getMessage();
393 393
                 }
394 394
 		return '';
395 395
 	}
396 396
 
397
-	public static function retrieve_owner($database_file,$country = 'F') {
397
+	public static function retrieve_owner($database_file, $country = 'F') {
398 398
 		global $globalTransaction;
399 399
 		//$query = 'TRUNCATE TABLE aircraft_modes';
400 400
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 			$Connection = new Connection();
403 403
 			$sth = $Connection->db->prepare($query);
404 404
                         $sth->execute(array(':source' => $database_file));
405
-                } catch(PDOException $e) {
405
+                } catch (PDOException $e) {
406 406
                         return "error : ".$e->getMessage();
407 407
                 }
408 408
 		
409
-		if ($fh = fopen($database_file,"r")) {
409
+		if ($fh = fopen($database_file, "r")) {
410 410
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
411 411
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
412 412
 		
@@ -414,9 +414,9 @@  discard block
 block discarded – undo
414 414
 			$sth_dest = $Connection->db->prepare($query_dest);
415 415
 			try {
416 416
 				if ($globalTransaction) $Connection->db->beginTransaction();
417
-				$tmp = fgetcsv($fh,9999,',','"');
417
+				$tmp = fgetcsv($fh, 9999, ',', '"');
418 418
             			while (!feof($fh)) {
419
-            				$line = fgetcsv($fh,9999,',','"');
419
+            				$line = fgetcsv($fh, 9999, ',', '"');
420 420
             				$values = array();
421 421
             				//print_r($line);
422 422
             				if ($country == 'F') {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
             				    $values['base'] = $line[4];
425 425
             				    $values['owner'] = $line[5];
426 426
             				    if ($line[6] == '') $values['date_first_reg'] = null;
427
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
427
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
428 428
 					    $values['cancel'] = $line[7];
429 429
 					} elseif ($country == 'EI') {
430 430
 					    // TODO : add modeS & reg to aircraft_modes
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
             				    $values['base'] = $line[3];
433 433
             				    $values['owner'] = $line[2];
434 434
             				    if ($line[1] == '') $values['date_first_reg'] = null;
435
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
435
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
436 436
 					    $values['cancel'] = '';
437 437
 					} elseif ($country == 'HB') {
438 438
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             				    $values['base'] = null;
448 448
             				    $values['owner'] = $line[5];
449 449
             				    if ($line[18] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
450
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
451 451
 					    $values['cancel'] = '';
452 452
 					} elseif ($country == 'VH') {
453 453
 					    // TODO : add modeS & reg to aircraft_modes
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
             				    $values['base'] = null;
456 456
             				    $values['owner'] = $line[12];
457 457
             				    if ($line[28] == '') $values['date_first_reg'] = null;
458
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
458
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
459 459
 
460 460
 					    $values['cancel'] = $line[39];
461 461
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -475,28 +475,28 @@  discard block
 block discarded – undo
475 475
             				    $values['base'] = null;
476 476
             				    $values['owner'] = $line[8];
477 477
             				    if ($line[7] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
478
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
479 479
 					    $values['cancel'] = '';
480 480
 					} elseif ($country == 'PP') {
481 481
             				    $values['registration'] = $line[0];
482 482
             				    $values['base'] = null;
483 483
             				    $values['owner'] = $line[4];
484 484
             				    if ($line[6] == '') $values['date_first_reg'] = null;
485
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
485
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
486 486
 					    $values['cancel'] = $line[7];
487 487
 					} elseif ($country == 'E7') {
488 488
             				    $values['registration'] = $line[0];
489 489
             				    $values['base'] = null;
490 490
             				    $values['owner'] = $line[4];
491 491
             				    if ($line[5] == '') $values['date_first_reg'] = null;
492
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
492
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
493 493
 					    $values['cancel'] = '';
494 494
 					} elseif ($country == '8Q') {
495 495
             				    $values['registration'] = $line[0];
496 496
             				    $values['base'] = null;
497 497
             				    $values['owner'] = $line[3];
498 498
             				    if ($line[7] == '') $values['date_first_reg'] = null;
499
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
499
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
500 500
 					    $values['cancel'] = '';
501 501
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
502 502
             				    $values['registration'] = $line[0];
@@ -506,12 +506,12 @@  discard block
 block discarded – undo
506 506
 					    $values['cancel'] = '';
507 507
 					}
508 508
 					if ($values['cancel'] == '' && $values['registration'] != null) {
509
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
509
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
510 510
 						$sth_dest->execute($query_dest_values);
511 511
 					}
512 512
 				}
513 513
 				if ($globalTransaction) $Connection->db->commit();
514
-			} catch(PDOException $e) {
514
+			} catch (PDOException $e) {
515 515
 				return "error : ".$e->getMessage();
516 516
 			}
517 517
 		}
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 			$Connection = new Connection();
627 627
 			$sth = $Connection->db->prepare($query);
628 628
                         $sth->execute();
629
-                } catch(PDOException $e) {
629
+                } catch (PDOException $e) {
630 630
                         return "error : ".$e->getMessage();
631 631
                 }
632 632
 
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 			$Connection = new Connection();
637 637
 			$sth = $Connection->db->prepare($query);
638 638
                         $sth->execute();
639
-                } catch(PDOException $e) {
639
+                } catch (PDOException $e) {
640 640
                         return "error : ".$e->getMessage();
641 641
                 }
642 642
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 		if ($globalTransaction) $Connection->db->beginTransaction();
648 648
   
649 649
 		$i = 0;
650
-		while($row = sparql_fetch_array($result))
650
+		while ($row = sparql_fetch_array($result))
651 651
 		{
652 652
 			if ($i >= 1) {
653 653
 			//print_r($row);
@@ -667,31 +667,31 @@  discard block
 block discarded – undo
667 667
 				$row['image'] = '';
668 668
 				$row['image_thumb'] = '';
669 669
 			} else {
670
-				$image = str_replace(' ','_',$row['image']);
670
+				$image = str_replace(' ', '_', $row['image']);
671 671
 				$digest = md5($image);
672
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
673
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
674
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
675
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
672
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
673
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
674
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
675
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
676 676
 			}
677 677
 			
678
-			$country = explode('-',$row['country']);
678
+			$country = explode('-', $row['country']);
679 679
 			$row['country'] = $country[0];
680 680
 			
681 681
 			$row['type'] = trim($row['type']);
682
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
682
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
683 683
 				$row['type'] = 'Military';
684 684
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
685 685
 				$row['type'] = 'small_airport';
686 686
 			}
687 687
 			
688
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
689
-			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
688
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
689
+			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
690 690
 			//print_r($query_dest_values);
691 691
 			
692 692
 			try {
693 693
 				$sth_dest->execute($query_dest_values);
694
-			} catch(PDOException $e) {
694
+			} catch (PDOException $e) {
695 695
 				return "error : ".$e->getMessage();
696 696
 			}
697 697
 			}
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			$Connection = new Connection();
706 706
 			$sth = $Connection->db->prepare($query);
707 707
                         $sth->execute();
708
-                } catch(PDOException $e) {
708
+                } catch (PDOException $e) {
709 709
                         return "error : ".$e->getMessage();
710 710
                 }
711 711
 
@@ -713,12 +713,12 @@  discard block
 block discarded – undo
713 713
 		if ($globalDebug) echo "Insert Not available Airport...\n";
714 714
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
715 715
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
716
-		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
716
+		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => '');
717 717
 		try {
718 718
 			$Connection = new Connection();
719 719
 			$sth = $Connection->db->prepare($query);
720 720
                         $sth->execute($query_values);
721
-                } catch(PDOException $e) {
721
+                } catch (PDOException $e) {
722 722
                         return "error : ".$e->getMessage();
723 723
                 }
724 724
 		$i++;
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 		echo "Download data from ourairports.com...\n";
737 737
 		$delimiter = ',';
738 738
 		$out_file = $tmp_dir.'airports.csv';
739
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
739
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
740 740
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
741 741
 		echo "Add data from ourairports.com...\n";
742 742
 
@@ -747,32 +747,32 @@  discard block
 block discarded – undo
747 747
 			//$Connection->db->beginTransaction();
748 748
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
749 749
 			{
750
-				if(!$header) $header = $row;
750
+				if (!$header) $header = $row;
751 751
 				else {
752 752
 					$data = array();
753 753
 					$data = array_combine($header, $row);
754 754
 					try {
755 755
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
756 756
 						$sth->execute(array(':icao' => $data['gps_code']));
757
-					} catch(PDOException $e) {
757
+					} catch (PDOException $e) {
758 758
 						return "error : ".$e->getMessage();
759 759
 					}
760 760
 					if ($sth->fetchColumn() > 0) {
761 761
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
762 762
 						try {
763 763
 							$sth = $Connection->db->prepare($query);
764
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
765
-						} catch(PDOException $e) {
764
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
765
+						} catch (PDOException $e) {
766 766
 							return "error : ".$e->getMessage();
767 767
 						}
768 768
 					} else {
769 769
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
770 770
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
771
-						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
771
+						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
772 772
 						try {
773 773
 							$sth = $Connection->db->prepare($query);
774 774
 							$sth->execute($query_values);
775
-						} catch(PDOException $e) {
775
+						} catch (PDOException $e) {
776 776
 							return "error : ".$e->getMessage();
777 777
 						}
778 778
 						$i++;
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 
786 786
 		echo "Download data from another free database...\n";
787 787
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
788
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
788
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
789 789
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
790 790
 		update_db::unzip($out_file);
791 791
 		$header = NULL;
@@ -797,15 +797,15 @@  discard block
 block discarded – undo
797 797
 			//$Connection->db->beginTransaction();
798 798
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
799 799
 			{
800
-				if(!$header) $header = $row;
800
+				if (!$header) $header = $row;
801 801
 				else {
802 802
 					$data = $row;
803 803
 
804 804
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
805 805
 					try {
806 806
 						$sth = $Connection->db->prepare($query);
807
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
808
-					} catch(PDOException $e) {
807
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
808
+					} catch (PDOException $e) {
809 809
 						return "error : ".$e->getMessage();
810 810
 					}
811 811
 				}
@@ -819,15 +819,15 @@  discard block
 block discarded – undo
819 819
 		try {
820 820
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
821 821
 			$sth->execute();
822
-		} catch(PDOException $e) {
822
+		} catch (PDOException $e) {
823 823
 			return "error : ".$e->getMessage();
824 824
 		}
825 825
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
826 826
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
827 827
 			try {
828 828
 				$sth2 = $Connection->db->prepare($query2);
829
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
830
-			} catch(PDOException $e) {
829
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
830
+			} catch (PDOException $e) {
831 831
 				return "error : ".$e->getMessage();
832 832
 			}
833 833
 		}
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 			$Connection = new Connection();
852 852
 			$sth = $Connection->db->prepare($query);
853 853
                         $sth->execute(array(':source' => 'translation.csv'));
854
-                } catch(PDOException $e) {
854
+                } catch (PDOException $e) {
855 855
                         return "error : ".$e->getMessage();
856 856
                 }
857 857
 
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
869 869
 			{
870 870
 				$i++;
871
-				if($i > 12) {
871
+				if ($i > 12) {
872 872
 					$data = $row;
873 873
 					$operator = $data[2];
874 874
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
                                                 //echo substr($operator, 0, 2)."\n";;
877 877
                                                 if (count($airline_array) > 0) {
878 878
 							//print_r($airline_array);
879
-							$operator = $airline_array[0]['icao'].substr($operator,2);
879
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
880 880
                                                 }
881 881
                                         }
882 882
 					
@@ -884,14 +884,14 @@  discard block
 block discarded – undo
884 884
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
885 885
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
886 886
                                                 if (count($airline_array) > 0) {
887
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
887
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
888 888
                                             	}
889 889
                                         }
890 890
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
891 891
 					try {
892 892
 						$sth = $Connection->db->prepare($query);
893
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
894
-					} catch(PDOException $e) {
893
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
894
+					} catch (PDOException $e) {
895 895
 						return "error : ".$e->getMessage();
896 896
 					}
897 897
 				}
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 			$Connection = new Connection();
912 912
 			$sth = $Connection->db->prepare($query);
913 913
                         $sth->execute(array(':source' => 'website_fam'));
914
-                } catch(PDOException $e) {
914
+                } catch (PDOException $e) {
915 915
                         return "error : ".$e->getMessage();
916 916
                 }
917 917
 
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
932 932
 					try {
933 933
 						$sth = $Connection->db->prepare($query);
934
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
935
-					} catch(PDOException $e) {
934
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
935
+					} catch (PDOException $e) {
936 936
 						return "error : ".$e->getMessage();
937 937
 					}
938 938
 				}
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 			$Connection = new Connection();
952 952
 			$sth = $Connection->db->prepare($query);
953 953
                         $sth->execute(array(':source' => 'website_fam'));
954
-                } catch(PDOException $e) {
954
+                } catch (PDOException $e) {
955 955
                         return "error : ".$e->getMessage();
956 956
                 }
957 957
 
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
972 972
 					try {
973 973
 						$sth = $Connection->db->prepare($query);
974
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
975
-					} catch(PDOException $e) {
974
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
975
+					} catch (PDOException $e) {
976 976
 						return "error : ".$e->getMessage();
977 977
 					}
978 978
 				}
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 			$Connection = new Connection();
992 992
 			$sth = $Connection->db->prepare($query);
993 993
                         $sth->execute(array(':source' => 'website_fam'));
994
-                } catch(PDOException $e) {
994
+                } catch (PDOException $e) {
995 995
                         return "error : ".$e->getMessage();
996 996
                 }
997 997
 
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1012 1012
 					try {
1013 1013
 						$sth = $Connection->db->prepare($query);
1014
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1015
-					} catch(PDOException $e) {
1014
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1015
+					} catch (PDOException $e) {
1016 1016
 						return "error : ".$e->getMessage();
1017 1017
 					}
1018 1018
 				}
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 		return '';
1025 1025
         }
1026 1026
 
1027
-	public static function tle($filename,$tletype) {
1027
+	public static function tle($filename, $tletype) {
1028 1028
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1029 1029
 		global $tmp_dir, $globalTransaction;
1030 1030
 		//$Spotter = new Spotter();
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 			$Connection = new Connection();
1035 1035
 			$sth = $Connection->db->prepare($query);
1036 1036
                         $sth->execute(array(':source' => $filename));
1037
-                } catch(PDOException $e) {
1037
+                } catch (PDOException $e) {
1038 1038
                         return "error : ".$e->getMessage();
1039 1039
                 }
1040 1040
 		
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1060 1060
 					try {
1061 1061
 						$sth = $Connection->db->prepare($query);
1062
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1063
-					} catch(PDOException $e) {
1062
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1063
+					} catch (PDOException $e) {
1064 1064
 						return "error : ".$e->getMessage();
1065 1065
 					}
1066 1066
 
@@ -1080,28 +1080,28 @@  discard block
 block discarded – undo
1080 1080
         */
1081 1081
         private static function table2array($data) {
1082 1082
                 $html = str_get_html($data);
1083
-                $tabledata=array();
1084
-                foreach($html->find('tr') as $element)
1083
+                $tabledata = array();
1084
+                foreach ($html->find('tr') as $element)
1085 1085
                 {
1086 1086
                         $td = array();
1087
-                        foreach( $element->find('th') as $row)
1087
+                        foreach ($element->find('th') as $row)
1088 1088
                         {
1089 1089
                                 $td [] = trim($row->plaintext);
1090 1090
                         }
1091
-                        $td=array_filter($td);
1091
+                        $td = array_filter($td);
1092 1092
                         $tabledata[] = $td;
1093 1093
 
1094 1094
                         $td = array();
1095 1095
                         $tdi = array();
1096
-                        foreach( $element->find('td') as $row)
1096
+                        foreach ($element->find('td') as $row)
1097 1097
                         {
1098 1098
                                 $td [] = trim($row->plaintext);
1099 1099
                                 $tdi [] = trim($row->innertext);
1100 1100
                         }
1101
-                        $td=array_filter($td);
1102
-                        $tdi=array_filter($tdi);
1101
+                        $td = array_filter($td);
1102
+                        $tdi = array_filter($tdi);
1103 1103
                     //    $tabledata[]=array_merge($td,$tdi);
1104
-                        $tabledata[]=$td;
1104
+                        $tabledata[] = $td;
1105 1105
                 }
1106 1106
                 return(array_filter($tabledata));
1107 1107
         }
@@ -1174,13 +1174,13 @@  discard block
 block discarded – undo
1174 1174
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1175 1175
 			{
1176 1176
 				$i++;
1177
-				if($i > 3 && count($row) > 2) {
1177
+				if ($i > 3 && count($row) > 2) {
1178 1178
 					$data = array_values(array_filter($row));
1179 1179
 					$cntdata = count($data);
1180 1180
 					if ($cntdata > 10) {
1181 1181
 						$value = $data[9];
1182 1182
 						
1183
-						for ($i =10;$i < $cntdata;$i++) {
1183
+						for ($i = 10; $i < $cntdata; $i++) {
1184 1184
 							$value .= ' '.$data[$i];
1185 1185
 						}
1186 1186
 						$data[9] = $value;
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1191 1191
 						try {
1192 1192
 							$sth = $Connection->db->prepare($query);
1193
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1194
-						} catch(PDOException $e) {
1193
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1194
+						} catch (PDOException $e) {
1195 1195
 							return "error : ".$e->getMessage();
1196 1196
 						}
1197 1197
 					}
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
 			$Connection = new Connection();
1213 1213
 			$sth = $Connection->db->prepare($query);
1214 1214
                         $sth->execute();
1215
-                } catch(PDOException $e) {
1215
+                } catch (PDOException $e) {
1216 1216
                         return "error : ".$e->getMessage();
1217 1217
                 }
1218 1218
 
@@ -1224,12 +1224,12 @@  discard block
 block discarded – undo
1224 1224
 			if ($globalTransaction) $Connection->db->beginTransaction();
1225 1225
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1226 1226
 			{
1227
-				if(count($row) > 1) {
1227
+				if (count($row) > 1) {
1228 1228
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1229 1229
 					try {
1230 1230
 						$sth = $Connection->db->prepare($query);
1231
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1232
-					} catch(PDOException $e) {
1231
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1232
+					} catch (PDOException $e) {
1233 1233
 						return "error : ".$e->getMessage();
1234 1234
 					}
1235 1235
 				}
@@ -1249,21 +1249,21 @@  discard block
 block discarded – undo
1249 1249
 			try {
1250 1250
 				$sth = $Connection->db->prepare($query);
1251 1251
                     		$sth->execute();
1252
-	                } catch(PDOException $e) {
1252
+	                } catch (PDOException $e) {
1253 1253
 				return "error : ".$e->getMessage();
1254 1254
 	                }
1255 1255
 	        }
1256 1256
 
1257 1257
 
1258
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1258
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1259 1259
 		else {
1260
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1260
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1261 1261
 			$query = "CREATE EXTENSION postgis";
1262
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1262
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1263 1263
 			try {
1264 1264
 				$sth = $Connection->db->prepare($query);
1265 1265
 				$sth->execute();
1266
-			} catch(PDOException $e) {
1266
+			} catch (PDOException $e) {
1267 1267
 				return "error : ".$e->getMessage();
1268 1268
 			}
1269 1269
 		}
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		include_once('class.create_db.php');
1277 1277
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1278 1278
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1279
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1279
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1280 1280
 		$error = '';
1281 1281
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1282 1282
 			if ($globalDebug) echo "Gunzip...";
@@ -1308,14 +1308,14 @@  discard block
 block discarded – undo
1308 1308
 			try {
1309 1309
 				$sth = $Connection->db->prepare($query);
1310 1310
             	        	$sth->execute();
1311
-	                } catch(PDOException $e) {
1311
+	                } catch (PDOException $e) {
1312 1312
     	                	echo "error : ".$e->getMessage();
1313 1313
 	                }
1314 1314
 		}
1315 1315
 		if ($globalDBdriver == 'mysql') {
1316
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1316
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1317 1317
 		} else {
1318
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1318
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1319 1319
 		}
1320 1320
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1321 1321
 		return $error;
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1329 1329
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1330 1330
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1331
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1331
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
1332 1332
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1333 1333
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1334 1334
 		return $error;
@@ -1348,7 +1348,7 @@  discard block
 block discarded – undo
1348 1348
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1349 1349
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1350 1350
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1351
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1351
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1352 1352
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1353 1353
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1354 1354
 		if ($error != '') {
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
 		global $tmp_dir, $globalDebug;
1362 1362
 		$error = '';
1363 1363
 		if ($globalDebug) echo "Routes : Download...";
1364
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1364
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1365 1365
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1366 1366
 			if ($globalDebug) echo "Gunzip...";
1367 1367
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 		global $tmp_dir, $globalDebug;
1378 1378
 		$error = '';
1379 1379
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1380
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1380
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1381 1381
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1382 1382
 			if ($globalDebug) echo "Gunzip...";
1383 1383
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
 		global $tmp_dir, $globalDebug;
1394 1394
 		$error = '';
1395 1395
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1396
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1396
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1397 1397
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1398 1398
 			if ($globalDebug) echo "Gunzip...";
1399 1399
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
 */
1422 1422
 		if ($globalDebug) echo "Modes : Download...";
1423 1423
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1424
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1424
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1425 1425
 
1426 1426
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1427 1427
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
 	public static function update_ModeS_flarm() {
1442 1442
 		global $tmp_dir, $globalDebug;
1443 1443
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1444
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1444
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1445 1445
 		if (file_exists($tmp_dir.'data.fln')) {
1446 1446
 			if ($globalDebug) echo "Add to DB...";
1447 1447
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 	public static function update_ModeS_ogn() {
1456 1456
 		global $tmp_dir, $globalDebug;
1457 1457
 		if ($globalDebug) echo "Modes OGN: Download...";
1458
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1458
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1459 1459
 		if (file_exists($tmp_dir.'ogn.csv')) {
1460 1460
 			if ($globalDebug) echo "Add to DB...";
1461 1461
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1470,173 +1470,173 @@  discard block
 block discarded – undo
1470 1470
 		global $tmp_dir, $globalDebug;
1471 1471
 		
1472 1472
 		if ($globalDebug) echo "Owner France: Download...";
1473
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1473
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1474 1474
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1475 1475
 			if ($globalDebug) echo "Add to DB...";
1476
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1476
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1477 1477
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1478 1478
 		if ($error != '') {
1479 1479
 			return $error;
1480 1480
 		} elseif ($globalDebug) echo "Done\n";
1481 1481
 		
1482 1482
 		if ($globalDebug) echo "Owner Ireland: Download...";
1483
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1483
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1484 1484
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1485 1485
 			if ($globalDebug) echo "Add to DB...";
1486
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1486
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1487 1487
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1488 1488
 		if ($error != '') {
1489 1489
 			return $error;
1490 1490
 		} elseif ($globalDebug) echo "Done\n";
1491 1491
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1492
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1492
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1493 1493
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1494 1494
 			if ($globalDebug) echo "Add to DB...";
1495
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1495
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1496 1496
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1497 1497
 		if ($error != '') {
1498 1498
 			return $error;
1499 1499
 		} elseif ($globalDebug) echo "Done\n";
1500 1500
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1501
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1501
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1502 1502
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1503 1503
 			if ($globalDebug) echo "Add to DB...";
1504
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1504
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1505 1505
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1506 1506
 		if ($error != '') {
1507 1507
 			return $error;
1508 1508
 		} elseif ($globalDebug) echo "Done\n";
1509 1509
 		if ($globalDebug) echo "Owner Australia: Download...";
1510
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1510
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1511 1511
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1512 1512
 			if ($globalDebug) echo "Add to DB...";
1513
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1513
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1514 1514
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1515 1515
 		if ($error != '') {
1516 1516
 			return $error;
1517 1517
 		} elseif ($globalDebug) echo "Done\n";
1518 1518
 		if ($globalDebug) echo "Owner Austria: Download...";
1519
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1519
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1520 1520
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1521 1521
 			if ($globalDebug) echo "Add to DB...";
1522
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1522
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1523 1523
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1524 1524
 		if ($error != '') {
1525 1525
 			return $error;
1526 1526
 		} elseif ($globalDebug) echo "Done\n";
1527 1527
 		if ($globalDebug) echo "Owner Chile: Download...";
1528
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1528
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1529 1529
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1530 1530
 			if ($globalDebug) echo "Add to DB...";
1531
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1531
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1532 1532
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1533 1533
 		if ($error != '') {
1534 1534
 			return $error;
1535 1535
 		} elseif ($globalDebug) echo "Done\n";
1536 1536
 		if ($globalDebug) echo "Owner Colombia: Download...";
1537
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1537
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1538 1538
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1539 1539
 			if ($globalDebug) echo "Add to DB...";
1540
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1540
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1541 1541
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1542 1542
 		if ($error != '') {
1543 1543
 			return $error;
1544 1544
 		} elseif ($globalDebug) echo "Done\n";
1545 1545
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1546
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1546
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1547 1547
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1548 1548
 			if ($globalDebug) echo "Add to DB...";
1549
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1549
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1550 1550
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1551 1551
 		if ($error != '') {
1552 1552
 			return $error;
1553 1553
 		} elseif ($globalDebug) echo "Done\n";
1554 1554
 		if ($globalDebug) echo "Owner Brazil: Download...";
1555
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1555
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1556 1556
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1557 1557
 			if ($globalDebug) echo "Add to DB...";
1558
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1558
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1559 1559
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1560 1560
 		if ($error != '') {
1561 1561
 			return $error;
1562 1562
 		} elseif ($globalDebug) echo "Done\n";
1563 1563
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1564
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1564
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1565 1565
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1566 1566
 			if ($globalDebug) echo "Add to DB...";
1567
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1567
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1568 1568
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1569 1569
 		if ($error != '') {
1570 1570
 			return $error;
1571 1571
 		} elseif ($globalDebug) echo "Done\n";
1572 1572
 		if ($globalDebug) echo "Owner Croatia: Download...";
1573
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1573
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1574 1574
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1575 1575
 			if ($globalDebug) echo "Add to DB...";
1576
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1576
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1577 1577
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1578 1578
 		if ($error != '') {
1579 1579
 			return $error;
1580 1580
 		} elseif ($globalDebug) echo "Done\n";
1581 1581
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1582
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1582
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1583 1583
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1584 1584
 			if ($globalDebug) echo "Add to DB...";
1585
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1585
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1586 1586
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1587 1587
 		if ($error != '') {
1588 1588
 			return $error;
1589 1589
 		} elseif ($globalDebug) echo "Done\n";
1590 1590
 		if ($globalDebug) echo "Owner Maldives: Download...";
1591
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1591
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1592 1592
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1593 1593
 			if ($globalDebug) echo "Add to DB...";
1594
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1594
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1595 1595
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1596 1596
 		if ($error != '') {
1597 1597
 			return $error;
1598 1598
 		} elseif ($globalDebug) echo "Done\n";
1599 1599
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1600
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1600
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1601 1601
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1602 1602
 			if ($globalDebug) echo "Add to DB...";
1603
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1603
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1604 1604
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1605 1605
 		if ($error != '') {
1606 1606
 			return $error;
1607 1607
 		} elseif ($globalDebug) echo "Done\n";
1608 1608
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1609
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1609
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1610 1610
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1611 1611
 			if ($globalDebug) echo "Add to DB...";
1612
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1612
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1613 1613
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1614 1614
 		if ($error != '') {
1615 1615
 			return $error;
1616 1616
 		} elseif ($globalDebug) echo "Done\n";
1617 1617
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1618
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1618
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1619 1619
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1620 1620
 			if ($globalDebug) echo "Add to DB...";
1621
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1621
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1622 1622
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1623 1623
 		if ($error != '') {
1624 1624
 			return $error;
1625 1625
 		} elseif ($globalDebug) echo "Done\n";
1626 1626
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1627
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1627
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1628 1628
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1629 1629
 			if ($globalDebug) echo "Add to DB...";
1630
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1630
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1631 1631
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1632 1632
 		if ($error != '') {
1633 1633
 			return $error;
1634 1634
 		} elseif ($globalDebug) echo "Done\n";
1635 1635
 		if ($globalDebug) echo "Owner Iceland: Download...";
1636
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1636
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1637 1637
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1638 1638
 			if ($globalDebug) echo "Add to DB...";
1639
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1639
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1640 1640
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1641 1641
 		if ($error != '') {
1642 1642
 			return $error;
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
 		global $tmp_dir, $globalDebug;
1649 1649
 		$error = '';
1650 1650
 		if ($globalDebug) echo "Translation : Download...";
1651
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1651
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1652 1652
 		if (file_exists($tmp_dir.'translation.zip')) {
1653 1653
 			if ($globalDebug) echo "Unzip...";
1654 1654
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
 	public static function update_translation_fam() {
1665 1665
 		global $tmp_dir, $globalDebug;
1666 1666
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1667
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1667
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1668 1668
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1669 1669
 			if ($globalDebug) echo "Gunzip...";
1670 1670
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
 	public static function update_ModeS_fam() {
1680 1680
 		global $tmp_dir, $globalDebug;
1681 1681
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1682
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1682
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1683 1683
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1684 1684
 			if ($globalDebug) echo "Gunzip...";
1685 1685
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1694,7 +1694,7 @@  discard block
 block discarded – undo
1694 1694
 	public static function update_routes_fam() {
1695 1695
 		global $tmp_dir, $globalDebug;
1696 1696
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
1697
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1697
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
1698 1698
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1699 1699
 			if ($globalDebug) echo "Gunzip...";
1700 1700
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -1713,18 +1713,18 @@  discard block
 block discarded – undo
1713 1713
 		$error = '';
1714 1714
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
1715 1715
 		if ($globalDBdriver == 'mysql') {
1716
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1716
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1717 1717
 		} else {
1718
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1718
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1719 1719
 		}
1720 1720
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
1721
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1721
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1722 1722
 			$airspace_md5 = $airspace_md5_file[0];
1723 1723
 			if (!update_db::check_airspace_version($airspace_md5)) {
1724 1724
 				if ($globalDBdriver == 'mysql') {
1725
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
1725
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
1726 1726
 				} else {
1727
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1727
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
1728 1728
 				}
1729 1729
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1730 1730
 					if ($globalDebug) echo "Gunzip...";
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
 						try {
1737 1737
 							$sth = $Connection->db->prepare($query);
1738 1738
     	    	    					$sth->execute();
1739
-			            		} catch(PDOException $e) {
1739
+			            		} catch (PDOException $e) {
1740 1740
 							return "error : ".$e->getMessage();
1741 1741
 		            			}
1742 1742
 		    			}
@@ -1754,15 +1754,15 @@  discard block
 block discarded – undo
1754 1754
 	public static function update_tle() {
1755 1755
 		global $tmp_dir, $globalDebug;
1756 1756
 		if ($globalDebug) echo "Download TLE : Download...";
1757
-		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
1758
-		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
1759
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1757
+		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt',
1758
+		'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt',
1759
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
1760 1760
 		foreach ($alltle as $filename) {
1761 1761
 			if ($globalDebug) echo "downloading ".$filename.'...';
1762
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1762
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
1763 1763
 			if (file_exists($tmp_dir.$filename)) {
1764 1764
 				if ($globalDebug) echo "Add to DB ".$filename."...";
1765
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1765
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
1766 1766
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
1767 1767
 			if ($error != '') {
1768 1768
 				echo $error."\n";
@@ -1775,32 +1775,32 @@  discard block
 block discarded – undo
1775 1775
 		global $tmp_dir, $globalDebug;
1776 1776
 		$error = '';
1777 1777
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
1778
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1778
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
1779 1779
 		if (file_exists($tmp_dir.'models.md5sum')) {
1780 1780
 			if ($globalDebug) echo "Check files...\n";
1781 1781
 			$newmodelsdb = array();
1782
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1783
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1782
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
1783
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1784 1784
 					$model = trim($row[2]);
1785 1785
 					$newmodelsdb[$model] = trim($row[0]);
1786 1786
 				}
1787 1787
 			}
1788 1788
 			$modelsdb = array();
1789 1789
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
1790
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
1791
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1790
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
1791
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1792 1792
 						$model = trim($row[2]);
1793 1793
 						$modelsdb[$model] = trim($row[0]);
1794 1794
 					}
1795 1795
 				}
1796 1796
 			}
1797
-			$diff = array_diff($newmodelsdb,$modelsdb);
1797
+			$diff = array_diff($newmodelsdb, $modelsdb);
1798 1798
 			foreach ($diff as $key => $value) {
1799 1799
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
1800
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1800
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
1801 1801
 				
1802 1802
 			}
1803
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1803
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
1804 1804
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
1805 1805
 		if ($error != '') {
1806 1806
 			return $error;
@@ -1812,32 +1812,32 @@  discard block
 block discarded – undo
1812 1812
 		global $tmp_dir, $globalDebug;
1813 1813
 		$error = '';
1814 1814
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
1815
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1815
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
1816 1816
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1817 1817
 			if ($globalDebug) echo "Check files...\n";
1818 1818
 			$newmodelsdb = array();
1819
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1820
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1819
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
1820
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1821 1821
 					$model = trim($row[2]);
1822 1822
 					$newmodelsdb[$model] = trim($row[0]);
1823 1823
 				}
1824 1824
 			}
1825 1825
 			$modelsdb = array();
1826 1826
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
1827
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
1828
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1827
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
1828
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1829 1829
 						$model = trim($row[2]);
1830 1830
 						$modelsdb[$model] = trim($row[0]);
1831 1831
 					}
1832 1832
 				}
1833 1833
 			}
1834
-			$diff = array_diff($newmodelsdb,$modelsdb);
1834
+			$diff = array_diff($newmodelsdb, $modelsdb);
1835 1835
 			foreach ($diff as $key => $value) {
1836 1836
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
1837
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
1837
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
1838 1838
 				
1839 1839
 			}
1840
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
1840
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
1841 1841
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
1842 1842
 		if ($error != '') {
1843 1843
 			return $error;
@@ -1860,8 +1860,8 @@  discard block
 block discarded – undo
1860 1860
 		*/
1861 1861
 		if (file_exists($tmp_dir.'aircrafts.html')) {
1862 1862
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1863
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
1864
-		    $result = fread($fh,100000000);
1863
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
1864
+		    $result = fread($fh, 100000000);
1865 1865
 		    //echo $result;
1866 1866
 		    //var_dump(str_get_html($result));
1867 1867
 		    //print_r(self::table2array($result));
@@ -1879,23 +1879,23 @@  discard block
 block discarded – undo
1879 1879
 			$Connection = new Connection();
1880 1880
 			$sth = $Connection->db->prepare($query);
1881 1881
                         $sth->execute();
1882
-                } catch(PDOException $e) {
1882
+                } catch (PDOException $e) {
1883 1883
                         return "error : ".$e->getMessage();
1884 1884
                 }
1885 1885
 
1886 1886
 		$error = '';
1887 1887
 		if ($globalDebug) echo "Notam : Download...";
1888
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
1888
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
1889 1889
 		if (file_exists($tmp_dir.'notam.rss')) {
1890
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
1890
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
1891 1891
 			foreach ($notams['channel']['item'] as $notam) {
1892
-				$title = explode(':',$notam['title']);
1892
+				$title = explode(':', $notam['title']);
1893 1893
 				$data['ref'] = trim($title[0]);
1894 1894
 				unset($title[0]);
1895
-				$data['title'] = trim(implode(':',$title));
1896
-				$description = strip_tags($notam['description'],'<pre>');
1897
-				preg_match(':^(.*?)<pre>:',$description,$match);
1898
-				$q = explode('/',$match[1]);
1895
+				$data['title'] = trim(implode(':', $title));
1896
+				$description = strip_tags($notam['description'], '<pre>');
1897
+				preg_match(':^(.*?)<pre>:', $description, $match);
1898
+				$q = explode('/', $match[1]);
1899 1899
 				$data['fir'] = $q[0];
1900 1900
 				$data['code'] = $q[1];
1901 1901
 				$ifrvfr = $q[2];
@@ -1911,30 +1911,30 @@  discard block
 block discarded – undo
1911 1911
 				$data['lower_limit'] = $q[5];
1912 1912
 				$data['upper_limit'] = $q[6];
1913 1913
 				$latlonrad = $q[7];
1914
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
1915
-				$latitude = $Common->convertDec($las,'latitude');
1916
-				$longitude = $Common->convertDec($lns,'longitude');
1914
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
1915
+				$latitude = $Common->convertDec($las, 'latitude');
1916
+				$longitude = $Common->convertDec($lns, 'longitude');
1917 1917
 				if ($lac == 'S') $latitude = '-'.$latitude;
1918 1918
 				if ($lnc == 'W') $longitude = '-'.$longitude;
1919 1919
 				$data['center_latitude'] = $latitude;
1920 1920
 				$data['center_longitude'] = $longitude;
1921 1921
 				$data['radius'] = intval($radius);
1922 1922
 				
1923
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
1923
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
1924 1924
 				$data['text'] = $match[1];
1925
-				preg_match(':</pre>(.*?)$:',$description,$match);
1925
+				preg_match(':</pre>(.*?)$:', $description, $match);
1926 1926
 				$fromto = $match[1];
1927
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
1927
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
1928 1928
 				$fromall = trim($match[1]);
1929
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
1929
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
1930 1930
 				$from = trim($match[1]);
1931
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
1932
-				preg_match('#TO:(.*?)$#',$fromto,$match);
1931
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
1932
+				preg_match('#TO:(.*?)$#', $fromto, $match);
1933 1933
 				$toall = trim($match[1]);
1934
-				if (!preg_match(':Permanent:',$toall)) {
1935
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
1934
+				if (!preg_match(':Permanent:', $toall)) {
1935
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
1936 1936
 					$to = trim($match[1]);
1937
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
1937
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
1938 1938
 					$data['permanent'] = 0;
1939 1939
 				} else {
1940 1940
 				    $data['date_end'] = NULL;
@@ -1942,7 +1942,7 @@  discard block
 block discarded – undo
1942 1942
 				}
1943 1943
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
1944 1944
 				$NOTAM = new NOTAM();
1945
-				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1945
+				$NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1946 1946
 				unset($data);
1947 1947
 			} 
1948 1948
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -1965,16 +1965,16 @@  discard block
 block discarded – undo
1965 1965
 				$Connection = new Connection();
1966 1966
 				$sth = $Connection->db->prepare($query);
1967 1967
 				$sth->execute();
1968
-			} catch(PDOException $e) {
1968
+			} catch (PDOException $e) {
1969 1969
 				return "error : ".$e->getMessage();
1970 1970
 			}
1971 1971
 		}
1972 1972
 		$Common = new Common();
1973 1973
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
1974
-		$airspace_json = json_decode($airspace_lst,true);
1974
+		$airspace_json = json_decode($airspace_lst, true);
1975 1975
 		foreach ($airspace_json['records'] as $airspace) {
1976 1976
 			if ($globalDebug) echo $airspace['name']."...\n";
1977
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
1977
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
1978 1978
 			if (file_exists($tmp_dir.$airspace['name'])) {
1979 1979
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
1980 1980
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
 			$Connection = new Connection();
1999 1999
 			$sth = $Connection->db->prepare($query);
2000 2000
                         $sth->execute();
2001
-                } catch(PDOException $e) {
2001
+                } catch (PDOException $e) {
2002 2002
                         return "error : ".$e->getMessage();
2003 2003
                 }
2004 2004
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2013,7 +2013,7 @@  discard block
 block discarded – undo
2013 2013
 			$Connection = new Connection();
2014 2014
 			$sth = $Connection->db->prepare($query);
2015 2015
                         $sth->execute();
2016
-                } catch(PDOException $e) {
2016
+                } catch (PDOException $e) {
2017 2017
                         return "error : ".$e->getMessage();
2018 2018
                 }
2019 2019
 	}
@@ -2024,7 +2024,7 @@  discard block
 block discarded – undo
2024 2024
 			$Connection = new Connection();
2025 2025
 			$sth = $Connection->db->prepare($query);
2026 2026
                         $sth->execute(array(':version' => $version));
2027
-                } catch(PDOException $e) {
2027
+                } catch (PDOException $e) {
2028 2028
                         return "error : ".$e->getMessage();
2029 2029
                 }
2030 2030
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2040,7 +2040,7 @@  discard block
 block discarded – undo
2040 2040
 			$Connection = new Connection();
2041 2041
 			$sth = $Connection->db->prepare($query);
2042 2042
                         $sth->execute(array(':version' => $version));
2043
-                } catch(PDOException $e) {
2043
+                } catch (PDOException $e) {
2044 2044
                         return "error : ".$e->getMessage();
2045 2045
                 }
2046 2046
 	}
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
 			$Connection = new Connection();
2057 2057
 			$sth = $Connection->db->prepare($query);
2058 2058
                         $sth->execute();
2059
-                } catch(PDOException $e) {
2059
+                } catch (PDOException $e) {
2060 2060
                         return "error : ".$e->getMessage();
2061 2061
                 }
2062 2062
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2071,7 +2071,7 @@  discard block
 block discarded – undo
2071 2071
 			$Connection = new Connection();
2072 2072
 			$sth = $Connection->db->prepare($query);
2073 2073
                         $sth->execute();
2074
-                } catch(PDOException $e) {
2074
+                } catch (PDOException $e) {
2075 2075
                         return "error : ".$e->getMessage();
2076 2076
                 }
2077 2077
 	}
@@ -2086,7 +2086,7 @@  discard block
 block discarded – undo
2086 2086
 			$Connection = new Connection();
2087 2087
 			$sth = $Connection->db->prepare($query);
2088 2088
                         $sth->execute();
2089
-                } catch(PDOException $e) {
2089
+                } catch (PDOException $e) {
2090 2090
                         return "error : ".$e->getMessage();
2091 2091
                 }
2092 2092
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2101,7 +2101,7 @@  discard block
 block discarded – undo
2101 2101
 			$Connection = new Connection();
2102 2102
 			$sth = $Connection->db->prepare($query);
2103 2103
                         $sth->execute();
2104
-                } catch(PDOException $e) {
2104
+                } catch (PDOException $e) {
2105 2105
                         return "error : ".$e->getMessage();
2106 2106
                 }
2107 2107
 	}
@@ -2117,7 +2117,7 @@  discard block
 block discarded – undo
2117 2117
 			$Connection = new Connection();
2118 2118
 			$sth = $Connection->db->prepare($query);
2119 2119
                         $sth->execute();
2120
-                } catch(PDOException $e) {
2120
+                } catch (PDOException $e) {
2121 2121
                         return "error : ".$e->getMessage();
2122 2122
                 }
2123 2123
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2132,7 +2132,7 @@  discard block
 block discarded – undo
2132 2132
 			$Connection = new Connection();
2133 2133
 			$sth = $Connection->db->prepare($query);
2134 2134
                         $sth->execute();
2135
-                } catch(PDOException $e) {
2135
+                } catch (PDOException $e) {
2136 2136
                         return "error : ".$e->getMessage();
2137 2137
                 }
2138 2138
 	}
@@ -2147,7 +2147,7 @@  discard block
 block discarded – undo
2147 2147
 			$Connection = new Connection();
2148 2148
 			$sth = $Connection->db->prepare($query);
2149 2149
                         $sth->execute();
2150
-                } catch(PDOException $e) {
2150
+                } catch (PDOException $e) {
2151 2151
                         return "error : ".$e->getMessage();
2152 2152
                 }
2153 2153
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2162,7 +2162,7 @@  discard block
 block discarded – undo
2162 2162
 			$Connection = new Connection();
2163 2163
 			$sth = $Connection->db->prepare($query);
2164 2164
                         $sth->execute();
2165
-                } catch(PDOException $e) {
2165
+                } catch (PDOException $e) {
2166 2166
                         return "error : ".$e->getMessage();
2167 2167
                 }
2168 2168
 	}
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
 			$Connection = new Connection();
2178 2178
 			$sth = $Connection->db->prepare($query);
2179 2179
                         $sth->execute();
2180
-                } catch(PDOException $e) {
2180
+                } catch (PDOException $e) {
2181 2181
                         return "error : ".$e->getMessage();
2182 2182
                 }
2183 2183
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
 			$Connection = new Connection();
2193 2193
 			$sth = $Connection->db->prepare($query);
2194 2194
                         $sth->execute();
2195
-                } catch(PDOException $e) {
2195
+                } catch (PDOException $e) {
2196 2196
                         return "error : ".$e->getMessage();
2197 2197
                 }
2198 2198
 	}
Please login to merge, or discard this patch.
Braces   +768 added lines, -267 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 		curl_setopt($ch, CURLOPT_URL, $url);
17 17
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
18 18
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
19
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
19
+		if ($referer != '') {
20
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
21
+		}
20 22
 		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');
21 23
 		curl_setopt($ch, CURLOPT_FILE, $fp);
22 24
 		curl_exec($ch);
@@ -27,12 +29,16 @@  discard block
 block discarded – undo
27 29
 	public static function gunzip($in_file,$out_file_name = '') {
28 30
 		//echo $in_file.' -> '.$out_file_name."\n";
29 31
 		$buffer_size = 4096; // read 4kb at a time
30
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32
+		if ($out_file_name == '') {
33
+			$out_file_name = str_replace('.gz', '', $in_file);
34
+		}
31 35
 		if ($in_file != '' && file_exists($in_file)) {
32 36
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
35
-			else {
37
+			if (function_exists('gzopen')) {
38
+				$file = gzopen($in_file,'rb');
39
+			} elseif (function_exists('gzopen64')) {
40
+				$file = gzopen64($in_file,'rb');
41
+			} else {
36 42
 				echo 'gzopen not available';
37 43
 				die;
38 44
 			}
@@ -53,8 +59,12 @@  discard block
 block discarded – undo
53 59
 			if ($res === TRUE) {
54 60
 				$zip->extractTo($path);
55 61
 				$zip->close();
56
-			} else return false;
57
-		} else return false;
62
+			} else {
63
+				return false;
64
+			}
65
+		} else {
66
+			return false;
67
+		}
58 68
 	}
59 69
 	
60 70
 	public static function connect_sqlite($database) {
@@ -69,7 +79,9 @@  discard block
 block discarded – undo
69 79
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 80
 		global $globalDebug, $globalTransaction;
71 81
 		//$query = 'TRUNCATE TABLE routes';
72
-		if ($globalDebug) echo " - Delete previous routes from DB -";
82
+		if ($globalDebug) {
83
+			echo " - Delete previous routes from DB -";
84
+		}
73 85
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
74 86
 		$Connection = new Connection();
75 87
 		try {
@@ -80,7 +92,9 @@  discard block
 block discarded – undo
80 92
                         return "error : ".$e->getMessage();
81 93
                 }
82 94
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
95
+    		if ($globalDebug) {
96
+    			echo " - Add routes to DB -";
97
+    		}
84 98
     		update_db::connect_sqlite($database_file);
85 99
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 100
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -95,15 +109,21 @@  discard block
 block discarded – undo
95 109
 		$Connection = new Connection();
96 110
 		$sth_dest = $Connection->db->prepare($query_dest);
97 111
 		try {
98
-			if ($globalTransaction) $Connection->db->beginTransaction();
112
+			if ($globalTransaction) {
113
+				$Connection->db->beginTransaction();
114
+			}
99 115
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 116
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 117
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$sth_dest->execute($query_dest_values);
103 119
             		}
104
-			if ($globalTransaction) $Connection->db->commit();
120
+			if ($globalTransaction) {
121
+				$Connection->db->commit();
122
+			}
105 123
 		} catch(PDOException $e) {
106
-			if ($globalTransaction) $Connection->db->rollBack(); 
124
+			if ($globalTransaction) {
125
+				$Connection->db->rollBack();
126
+			}
107 127
 			return "error : ".$e->getMessage();
108 128
 		}
109 129
                 return '';
@@ -111,7 +131,9 @@  discard block
 block discarded – undo
111 131
 	public static function retrieve_route_oneworld($database_file) {
112 132
 		global $globalDebug, $globalTransaction;
113 133
 		//$query = 'TRUNCATE TABLE routes';
114
-		if ($globalDebug) echo " - Delete previous routes from DB -";
134
+		if ($globalDebug) {
135
+			echo " - Delete previous routes from DB -";
136
+		}
115 137
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
116 138
 		$Connection = new Connection();
117 139
 		try {
@@ -122,14 +144,18 @@  discard block
 block discarded – undo
122 144
                         return "error : ".$e->getMessage();
123 145
                 }
124 146
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
147
+    		if ($globalDebug) {
148
+    			echo " - Add routes to DB -";
149
+    		}
126 150
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 151
 		$Spotter = new Spotter();
128 152
 		if ($fh = fopen($database_file,"r")) {
129 153
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 154
 			$Connection = new Connection();
131 155
 			$sth_dest = $Connection->db->prepare($query_dest);
132
-			if ($globalTransaction) $Connection->db->beginTransaction();
156
+			if ($globalTransaction) {
157
+				$Connection->db->beginTransaction();
158
+			}
133 159
 			while (!feof($fh)) {
134 160
 				$line = fgetcsv($fh,9999,',');
135 161
 				if ($line[0] != '') {
@@ -138,13 +164,17 @@  discard block
 block discarded – undo
138 164
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139 165
 							$sth_dest->execute($query_dest_values);
140 166
 						} catch(PDOException $e) {
141
-							if ($globalTransaction) $Connection->db->rollBack(); 
167
+							if ($globalTransaction) {
168
+								$Connection->db->rollBack();
169
+							}
142 170
 							return "error : ".$e->getMessage();
143 171
 						}
144 172
 					}
145 173
 				}
146 174
 			}
147
-			if ($globalTransaction) $Connection->db->commit();
175
+			if ($globalTransaction) {
176
+				$Connection->db->commit();
177
+			}
148 178
 		}
149 179
                 return '';
150 180
 	}
@@ -152,7 +182,9 @@  discard block
 block discarded – undo
152 182
 	public static function retrieve_route_skyteam($database_file) {
153 183
 		global $globalDebug, $globalTransaction;
154 184
 		//$query = 'TRUNCATE TABLE routes';
155
-		if ($globalDebug) echo " - Delete previous routes from DB -";
185
+		if ($globalDebug) {
186
+			echo " - Delete previous routes from DB -";
187
+		}
156 188
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
157 189
 		$Connection = new Connection();
158 190
 		try {
@@ -163,7 +195,9 @@  discard block
 block discarded – undo
163 195
                         return "error : ".$e->getMessage();
164 196
                 }
165 197
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
198
+    		if ($globalDebug) {
199
+    			echo " - Add routes to DB -";
200
+    		}
167 201
 
168 202
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 203
 		$Spotter = new Spotter();
@@ -172,7 +206,9 @@  discard block
 block discarded – undo
172 206
 			$Connection = new Connection();
173 207
 			$sth_dest = $Connection->db->prepare($query_dest);
174 208
 			try {
175
-				if ($globalTransaction) $Connection->db->beginTransaction();
209
+				if ($globalTransaction) {
210
+					$Connection->db->beginTransaction();
211
+				}
176 212
 				while (!feof($fh)) {
177 213
 					$line = fgetcsv($fh,9999,',');
178 214
 					if ($line[0] != '') {
@@ -183,9 +219,13 @@  discard block
 block discarded – undo
183 219
 						}
184 220
 					}
185 221
 				}
186
-				if ($globalTransaction) $Connection->db->commit();
222
+				if ($globalTransaction) {
223
+					$Connection->db->commit();
224
+				}
187 225
 			} catch(PDOException $e) {
188
-				if ($globalTransaction) $Connection->db->rollBack(); 
226
+				if ($globalTransaction) {
227
+					$Connection->db->rollBack();
228
+				}
189 229
 				return "error : ".$e->getMessage();
190 230
 			}
191 231
 		}
@@ -228,11 +268,16 @@  discard block
 block discarded – undo
228 268
 		$sth_dest = $Connection->db->prepare($query_dest);
229 269
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 270
 		try {
231
-			if ($globalTransaction) $Connection->db->beginTransaction();
271
+			if ($globalTransaction) {
272
+				$Connection->db->beginTransaction();
273
+			}
232 274
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 275
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234
-				if ($values['UserString4'] == 'M') $type = 'military';
235
-				else $type = null;
276
+				if ($values['UserString4'] == 'M') {
277
+					$type = 'military';
278
+				} else {
279
+					$type = null;
280
+				}
236 281
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 282
 				$sth_dest->execute($query_dest_values);
238 283
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -240,7 +285,9 @@  discard block
 block discarded – undo
240 285
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 286
 				}
242 287
             		}
243
-			if ($globalTransaction) $Connection->db->commit();
288
+			if ($globalTransaction) {
289
+				$Connection->db->commit();
290
+			}
244 291
 		} catch(PDOException $e) {
245 292
 			return "error : ".$e->getMessage();
246 293
 		}
@@ -276,7 +323,9 @@  discard block
 block discarded – undo
276 323
 			$Connection = new Connection();
277 324
 			$sth_dest = $Connection->db->prepare($query_dest);
278 325
 			try {
279
-				if ($globalTransaction) $Connection->db->beginTransaction();
326
+				if ($globalTransaction) {
327
+					$Connection->db->beginTransaction();
328
+				}
280 329
             			while (!feof($fh)) {
281 330
             				$values = array();
282 331
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -287,7 +336,9 @@  discard block
 block discarded – undo
287 336
             				// Check if we can find ICAO, else set it to GLID
288 337
             				$aircraft_name_split = explode(' ',$aircraft_name);
289 338
             				$search_more = '';
290
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
339
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
340
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
341
+            				}
291 342
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
292 343
             				$sth_search = $Connection->db->prepare($query_search);
293 344
 					try {
@@ -300,7 +351,9 @@  discard block
 block discarded – undo
300 351
 					} catch(PDOException $e) {
301 352
 						return "error : ".$e->getMessage();
302 353
 					}
303
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
354
+					if (!isset($values['ICAOTypeCode'])) {
355
+						$values['ICAOTypeCode'] = 'GLID';
356
+					}
304 357
 					// Add data to db
305 358
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') {
306 359
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -309,7 +362,9 @@  discard block
 block discarded – undo
309 362
 						$sth_dest->execute($query_dest_values);
310 363
 					}
311 364
 				}
312
-				if ($globalTransaction) $Connection->db->commit();
365
+				if ($globalTransaction) {
366
+					$Connection->db->commit();
367
+				}
313 368
 			} catch(PDOException $e) {
314 369
 				return "error : ".$e->getMessage();
315 370
 			}
@@ -345,7 +400,9 @@  discard block
 block discarded – undo
345 400
 			$Connection = new Connection();
346 401
 			$sth_dest = $Connection->db->prepare($query_dest);
347 402
 			try {
348
-				if ($globalTransaction) $Connection->db->beginTransaction();
403
+				if ($globalTransaction) {
404
+					$Connection->db->beginTransaction();
405
+				}
349 406
 				$tmp = fgetcsv($fh,9999,',',"'");
350 407
             			while (!feof($fh)) {
351 408
             				$line = fgetcsv($fh,9999,',',"'");
@@ -358,13 +415,17 @@  discard block
 block discarded – undo
358 415
             				// Check if we can find ICAO, else set it to GLID
359 416
             				$aircraft_name_split = explode(' ',$aircraft_name);
360 417
             				$search_more = '';
361
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
418
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
419
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
420
+            				}
362 421
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
363 422
             				$sth_search = $Connection->db->prepare($query_search);
364 423
 					try {
365 424
                                     		$sth_search->execute();
366 425
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
367
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
426
+	            				if (isset($result['icao']) && $result['icao'] != '') {
427
+	            					$values['ICAOTypeCode'] = $result['icao'];
428
+	            				}
368 429
 					} catch(PDOException $e) {
369 430
 						return "error : ".$e->getMessage();
370 431
 					}
@@ -377,7 +438,9 @@  discard block
 block discarded – undo
377 438
 						$sth_dest->execute($query_dest_values);
378 439
 					}
379 440
 				}
380
-				if ($globalTransaction) $Connection->db->commit();
441
+				if ($globalTransaction) {
442
+					$Connection->db->commit();
443
+				}
381 444
 			} catch(PDOException $e) {
382 445
 				return "error : ".$e->getMessage();
383 446
 			}
@@ -413,7 +476,9 @@  discard block
 block discarded – undo
413 476
 			$Connection = new Connection();
414 477
 			$sth_dest = $Connection->db->prepare($query_dest);
415 478
 			try {
416
-				if ($globalTransaction) $Connection->db->beginTransaction();
479
+				if ($globalTransaction) {
480
+					$Connection->db->beginTransaction();
481
+				}
417 482
 				$tmp = fgetcsv($fh,9999,',','"');
418 483
             			while (!feof($fh)) {
419 484
             				$line = fgetcsv($fh,9999,',','"');
@@ -423,16 +488,22 @@  discard block
 block discarded – undo
423 488
             				    $values['registration'] = $line[0];
424 489
             				    $values['base'] = $line[4];
425 490
             				    $values['owner'] = $line[5];
426
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
427
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
491
+            				    if ($line[6] == '') {
492
+            				    	$values['date_first_reg'] = null;
493
+            				    } else {
494
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
+					    }
428 496
 					    $values['cancel'] = $line[7];
429 497
 					} elseif ($country == 'EI') {
430 498
 					    // TODO : add modeS & reg to aircraft_modes
431 499
             				    $values['registration'] = $line[0];
432 500
             				    $values['base'] = $line[3];
433 501
             				    $values['owner'] = $line[2];
434
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
435
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
502
+            				    if ($line[1] == '') {
503
+            				    	$values['date_first_reg'] = null;
504
+            				    } else {
505
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
506
+					    }
436 507
 					    $values['cancel'] = '';
437 508
 					} elseif ($country == 'HB') {
438 509
 					    // TODO : add modeS & reg to aircraft_modes
@@ -446,16 +517,22 @@  discard block
 block discarded – undo
446 517
             				    $values['registration'] = $line[3];
447 518
             				    $values['base'] = null;
448 519
             				    $values['owner'] = $line[5];
449
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
520
+            				    if ($line[18] == '') {
521
+            				    	$values['date_first_reg'] = null;
522
+            				    } else {
523
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
524
+					    }
451 525
 					    $values['cancel'] = '';
452 526
 					} elseif ($country == 'VH') {
453 527
 					    // TODO : add modeS & reg to aircraft_modes
454 528
             				    $values['registration'] = $line[0];
455 529
             				    $values['base'] = null;
456 530
             				    $values['owner'] = $line[12];
457
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
458
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
531
+            				    if ($line[28] == '') {
532
+            				    	$values['date_first_reg'] = null;
533
+            				    } else {
534
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
535
+					    }
459 536
 
460 537
 					    $values['cancel'] = $line[39];
461 538
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -474,29 +551,41 @@  discard block
 block discarded – undo
474 551
             				    $values['registration'] = $line[0];
475 552
             				    $values['base'] = null;
476 553
             				    $values['owner'] = $line[8];
477
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
554
+            				    if ($line[7] == '') {
555
+            				    	$values['date_first_reg'] = null;
556
+            				    } else {
557
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
558
+					    }
479 559
 					    $values['cancel'] = '';
480 560
 					} elseif ($country == 'PP') {
481 561
             				    $values['registration'] = $line[0];
482 562
             				    $values['base'] = null;
483 563
             				    $values['owner'] = $line[4];
484
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
485
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
564
+            				    if ($line[6] == '') {
565
+            				    	$values['date_first_reg'] = null;
566
+            				    } else {
567
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
568
+					    }
486 569
 					    $values['cancel'] = $line[7];
487 570
 					} elseif ($country == 'E7') {
488 571
             				    $values['registration'] = $line[0];
489 572
             				    $values['base'] = null;
490 573
             				    $values['owner'] = $line[4];
491
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
492
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
574
+            				    if ($line[5] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
578
+					    }
493 579
 					    $values['cancel'] = '';
494 580
 					} elseif ($country == '8Q') {
495 581
             				    $values['registration'] = $line[0];
496 582
             				    $values['base'] = null;
497 583
             				    $values['owner'] = $line[3];
498
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
499
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
584
+            				    if ($line[7] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
588
+					    }
500 589
 					    $values['cancel'] = '';
501 590
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
502 591
             				    $values['registration'] = $line[0];
@@ -510,7 +599,9 @@  discard block
 block discarded – undo
510 599
 						$sth_dest->execute($query_dest_values);
511 600
 					}
512 601
 				}
513
-				if ($globalTransaction) $Connection->db->commit();
602
+				if ($globalTransaction) {
603
+					$Connection->db->commit();
604
+				}
514 605
 			} catch(PDOException $e) {
515 606
 				return "error : ".$e->getMessage();
516 607
 			}
@@ -644,25 +735,45 @@  discard block
 block discarded – undo
644 735
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
645 736
 		$Connection = new Connection();
646 737
 		$sth_dest = $Connection->db->prepare($query_dest);
647
-		if ($globalTransaction) $Connection->db->beginTransaction();
738
+		if ($globalTransaction) {
739
+			$Connection->db->beginTransaction();
740
+		}
648 741
   
649 742
 		$i = 0;
650 743
 		while($row = sparql_fetch_array($result))
651 744
 		{
652 745
 			if ($i >= 1) {
653 746
 			//print_r($row);
654
-			if (!isset($row['iata'])) $row['iata'] = '';
655
-			if (!isset($row['icao'])) $row['icao'] = '';
656
-			if (!isset($row['type'])) $row['type'] = '';
657
-			if (!isset($row['altitude'])) $row['altitude'] = '';
747
+			if (!isset($row['iata'])) {
748
+				$row['iata'] = '';
749
+			}
750
+			if (!isset($row['icao'])) {
751
+				$row['icao'] = '';
752
+			}
753
+			if (!isset($row['type'])) {
754
+				$row['type'] = '';
755
+			}
756
+			if (!isset($row['altitude'])) {
757
+				$row['altitude'] = '';
758
+			}
658 759
 			if (isset($row['city_bis'])) {
659 760
 				$row['city'] = $row['city_bis'];
660 761
 			}
661
-			if (!isset($row['city'])) $row['city'] = '';
662
-			if (!isset($row['country'])) $row['country'] = '';
663
-			if (!isset($row['homepage'])) $row['homepage'] = '';
664
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
665
-			if (!isset($row['name'])) continue;
762
+			if (!isset($row['city'])) {
763
+				$row['city'] = '';
764
+			}
765
+			if (!isset($row['country'])) {
766
+				$row['country'] = '';
767
+			}
768
+			if (!isset($row['homepage'])) {
769
+				$row['homepage'] = '';
770
+			}
771
+			if (!isset($row['wikipedia_page'])) {
772
+				$row['wikipedia_page'] = '';
773
+			}
774
+			if (!isset($row['name'])) {
775
+				continue;
776
+			}
666 777
 			if (!isset($row['image'])) {
667 778
 				$row['image'] = '';
668 779
 				$row['image_thumb'] = '';
@@ -698,7 +809,9 @@  discard block
 block discarded – undo
698 809
 
699 810
 			$i++;
700 811
 		}
701
-		if ($globalTransaction) $Connection->db->commit();
812
+		if ($globalTransaction) {
813
+			$Connection->db->commit();
814
+		}
702 815
 		echo "Delete duplicate rows...\n";
703 816
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
704 817
 		try {
@@ -710,7 +823,9 @@  discard block
 block discarded – undo
710 823
                 }
711 824
 
712 825
 
713
-		if ($globalDebug) echo "Insert Not available Airport...\n";
826
+		if ($globalDebug) {
827
+			echo "Insert Not available Airport...\n";
828
+		}
714 829
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
715 830
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
716 831
 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
@@ -737,7 +852,9 @@  discard block
 block discarded – undo
737 852
 		$delimiter = ',';
738 853
 		$out_file = $tmp_dir.'airports.csv';
739 854
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
740
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
855
+		if (!file_exists($out_file) || !is_readable($out_file)) {
856
+			return FALSE;
857
+		}
741 858
 		echo "Add data from ourairports.com...\n";
742 859
 
743 860
 		$header = NULL;
@@ -747,8 +864,9 @@  discard block
 block discarded – undo
747 864
 			//$Connection->db->beginTransaction();
748 865
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
749 866
 			{
750
-				if(!$header) $header = $row;
751
-				else {
867
+				if(!$header) {
868
+					$header = $row;
869
+				} else {
752 870
 					$data = array();
753 871
 					$data = array_combine($header, $row);
754 872
 					try {
@@ -786,7 +904,9 @@  discard block
 block discarded – undo
786 904
 		echo "Download data from another free database...\n";
787 905
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
788 906
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
789
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
907
+		if (!file_exists($out_file) || !is_readable($out_file)) {
908
+			return FALSE;
909
+		}
790 910
 		update_db::unzip($out_file);
791 911
 		$header = NULL;
792 912
 		echo "Add data from another free database...\n";
@@ -797,8 +917,9 @@  discard block
 block discarded – undo
797 917
 			//$Connection->db->beginTransaction();
798 918
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
799 919
 			{
800
-				if(!$header) $header = $row;
801
-				else {
920
+				if(!$header) {
921
+					$header = $row;
922
+				} else {
802 923
 					$data = $row;
803 924
 
804 925
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -964,7 +1085,9 @@  discard block
 block discarded – undo
964 1085
 			$i = 0;
965 1086
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
966 1087
 			//$Connection->db->beginTransaction();
967
-			if ($globalTransaction) $Connection->db->beginTransaction();
1088
+			if ($globalTransaction) {
1089
+				$Connection->db->beginTransaction();
1090
+			}
968 1091
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
969 1092
 			{
970 1093
 				if ($i > 0) {
@@ -979,7 +1102,9 @@  discard block
 block discarded – undo
979 1102
 				$i++;
980 1103
 			}
981 1104
 			fclose($handle);
982
-			if ($globalTransaction) $Connection->db->commit();
1105
+			if ($globalTransaction) {
1106
+				$Connection->db->commit();
1107
+			}
983 1108
 		}
984 1109
 		return '';
985 1110
         }
@@ -1004,7 +1129,9 @@  discard block
 block discarded – undo
1004 1129
 			$i = 0;
1005 1130
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1006 1131
 			//$Connection->db->beginTransaction();
1007
-			if ($globalTransaction) $Connection->db->beginTransaction();
1132
+			if ($globalTransaction) {
1133
+				$Connection->db->beginTransaction();
1134
+			}
1008 1135
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1009 1136
 			{
1010 1137
 				if ($i > 0) {
@@ -1019,7 +1146,9 @@  discard block
 block discarded – undo
1019 1146
 				$i++;
1020 1147
 			}
1021 1148
 			fclose($handle);
1022
-			if ($globalTransaction) $Connection->db->commit();
1149
+			if ($globalTransaction) {
1150
+				$Connection->db->commit();
1151
+			}
1023 1152
 		}
1024 1153
 		return '';
1025 1154
         }
@@ -1170,7 +1299,9 @@  discard block
 block discarded – undo
1170 1299
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1171 1300
 		{
1172 1301
 			$i = 0;
1173
-			if ($globalTransaction) $Connection->db->beginTransaction();
1302
+			if ($globalTransaction) {
1303
+				$Connection->db->beginTransaction();
1304
+			}
1174 1305
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1175 1306
 			{
1176 1307
 				$i++;
@@ -1198,7 +1329,9 @@  discard block
 block discarded – undo
1198 1329
 				}
1199 1330
 			}
1200 1331
 			fclose($handle);
1201
-			if ($globalTransaction) $Connection->db->commit();
1332
+			if ($globalTransaction) {
1333
+				$Connection->db->commit();
1334
+			}
1202 1335
 		}
1203 1336
 		return '';
1204 1337
         }
@@ -1221,7 +1354,9 @@  discard block
 block discarded – undo
1221 1354
 		$Connection = new Connection();
1222 1355
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1223 1356
 		{
1224
-			if ($globalTransaction) $Connection->db->beginTransaction();
1357
+			if ($globalTransaction) {
1358
+				$Connection->db->beginTransaction();
1359
+			}
1225 1360
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1226 1361
 			{
1227 1362
 				if(count($row) > 1) {
@@ -1235,7 +1370,9 @@  discard block
 block discarded – undo
1235 1370
 				}
1236 1371
 			}
1237 1372
 			fclose($handle);
1238
-			if ($globalTransaction) $Connection->db->commit();
1373
+			if ($globalTransaction) {
1374
+				$Connection->db->commit();
1375
+			}
1239 1376
 		}
1240 1377
 		return '';
1241 1378
         }
@@ -1255,8 +1392,9 @@  discard block
 block discarded – undo
1255 1392
 	        }
1256 1393
 
1257 1394
 
1258
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1259
-		else {
1395
+		if ($globalDBdriver == 'mysql') {
1396
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1397
+		} else {
1260 1398
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1261 1399
 			$query = "CREATE EXTENSION postgis";
1262 1400
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1275,20 +1413,30 @@  discard block
 block discarded – undo
1275 1413
 		global $tmp_dir, $globalDebug;
1276 1414
 		include_once('class.create_db.php');
1277 1415
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1278
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1416
+		if ($globalDebug) {
1417
+			echo "NOTAM from FlightAirMap website : Download...";
1418
+		}
1279 1419
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1280 1420
 		$error = '';
1281 1421
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1282
-			if ($globalDebug) echo "Gunzip...";
1422
+			if ($globalDebug) {
1423
+				echo "Gunzip...";
1424
+			}
1283 1425
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1284
-			if ($globalDebug) echo "Add to DB...";
1426
+			if ($globalDebug) {
1427
+				echo "Add to DB...";
1428
+			}
1285 1429
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1286 1430
 			$NOTAM = new NOTAM();
1287 1431
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1288
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1432
+		} else {
1433
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1434
+		}
1289 1435
 		if ($error != '') {
1290 1436
 			return $error;
1291
-		} elseif ($globalDebug) echo "Done\n";
1437
+		} elseif ($globalDebug) {
1438
+			echo "Done\n";
1439
+		}
1292 1440
 		return '';
1293 1441
 	}
1294 1442
 
@@ -1342,67 +1490,111 @@  discard block
 block discarded – undo
1342 1490
 		//if ($globalDebug) echo "IVAO : Download...";
1343 1491
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1344 1492
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1345
-			if ($globalDebug) echo "Unzip...";
1493
+			if ($globalDebug) {
1494
+				echo "Unzip...";
1495
+			}
1346 1496
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1347
-			if ($globalDebug) echo "Add to DB...";
1497
+			if ($globalDebug) {
1498
+				echo "Add to DB...";
1499
+			}
1348 1500
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1349
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1501
+			if ($globalDebug) {
1502
+				echo "Copy airlines logos to airlines images directory...";
1503
+			}
1350 1504
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1351
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1352
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1353
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1505
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1506
+					$error = "Failed to copy airlines logo.";
1507
+				}
1508
+			} else {
1509
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1510
+			}
1511
+		} else {
1512
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1513
+		}
1354 1514
 		if ($error != '') {
1355 1515
 			return $error;
1356
-		} elseif ($globalDebug) echo "Done\n";
1516
+		} elseif ($globalDebug) {
1517
+			echo "Done\n";
1518
+		}
1357 1519
 		return '';
1358 1520
 	}
1359 1521
 
1360 1522
 	public static function update_routes() {
1361 1523
 		global $tmp_dir, $globalDebug;
1362 1524
 		$error = '';
1363
-		if ($globalDebug) echo "Routes : Download...";
1525
+		if ($globalDebug) {
1526
+			echo "Routes : Download...";
1527
+		}
1364 1528
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1365 1529
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1366
-			if ($globalDebug) echo "Gunzip...";
1530
+			if ($globalDebug) {
1531
+				echo "Gunzip...";
1532
+			}
1367 1533
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1368
-			if ($globalDebug) echo "Add to DB...";
1534
+			if ($globalDebug) {
1535
+				echo "Add to DB...";
1536
+			}
1369 1537
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1370
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1538
+		} else {
1539
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1540
+		}
1371 1541
 		if ($error != '') {
1372 1542
 			return $error;
1373
-		} elseif ($globalDebug) echo "Done\n";
1543
+		} elseif ($globalDebug) {
1544
+			echo "Done\n";
1545
+		}
1374 1546
 		return '';
1375 1547
 	}
1376 1548
 	public static function update_oneworld() {
1377 1549
 		global $tmp_dir, $globalDebug;
1378 1550
 		$error = '';
1379
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1551
+		if ($globalDebug) {
1552
+			echo "Schedules Oneworld : Download...";
1553
+		}
1380 1554
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1381 1555
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1382
-			if ($globalDebug) echo "Gunzip...";
1556
+			if ($globalDebug) {
1557
+				echo "Gunzip...";
1558
+			}
1383 1559
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1384
-			if ($globalDebug) echo "Add to DB...";
1560
+			if ($globalDebug) {
1561
+				echo "Add to DB...";
1562
+			}
1385 1563
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1386
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1564
+		} else {
1565
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1566
+		}
1387 1567
 		if ($error != '') {
1388 1568
 			return $error;
1389
-		} elseif ($globalDebug) echo "Done\n";
1569
+		} elseif ($globalDebug) {
1570
+			echo "Done\n";
1571
+		}
1390 1572
 		return '';
1391 1573
 	}
1392 1574
 	public static function update_skyteam() {
1393 1575
 		global $tmp_dir, $globalDebug;
1394 1576
 		$error = '';
1395
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1577
+		if ($globalDebug) {
1578
+			echo "Schedules Skyteam : Download...";
1579
+		}
1396 1580
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1397 1581
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1398
-			if ($globalDebug) echo "Gunzip...";
1582
+			if ($globalDebug) {
1583
+				echo "Gunzip...";
1584
+			}
1399 1585
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1400
-			if ($globalDebug) echo "Add to DB...";
1586
+			if ($globalDebug) {
1587
+				echo "Add to DB...";
1588
+			}
1401 1589
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1402
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1590
+		} else {
1591
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1592
+		}
1403 1593
 		if ($error != '') {
1404 1594
 			return $error;
1405
-		} elseif ($globalDebug) echo "Done\n";
1595
+		} elseif ($globalDebug) {
1596
+			echo "Done\n";
1597
+		}
1406 1598
 		return '';
1407 1599
 	}
1408 1600
 	public static function update_ModeS() {
@@ -1419,291 +1611,509 @@  discard block
 block discarded – undo
1419 1611
 			exit;
1420 1612
 		} elseif ($globalDebug) echo "Done\n";
1421 1613
 */
1422
-		if ($globalDebug) echo "Modes : Download...";
1423
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1614
+		if ($globalDebug) {
1615
+			echo "Modes : Download...";
1616
+		}
1617
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1424 1618
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1425 1619
 
1426 1620
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1427 1621
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1428
-			if ($globalDebug) echo "Unzip...";
1429
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1622
+			if ($globalDebug) {
1623
+				echo "Unzip...";
1624
+			}
1625
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1430 1626
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1431
-			if ($globalDebug) echo "Add to DB...";
1627
+			if ($globalDebug) {
1628
+				echo "Add to DB...";
1629
+			}
1432 1630
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1433 1631
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1434
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1632
+		} else {
1633
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1634
+		}
1435 1635
 		if ($error != '') {
1436 1636
 			return $error;
1437
-		} elseif ($globalDebug) echo "Done\n";
1637
+		} elseif ($globalDebug) {
1638
+			echo "Done\n";
1639
+		}
1438 1640
 		return '';
1439 1641
 	}
1440 1642
 
1441 1643
 	public static function update_ModeS_flarm() {
1442 1644
 		global $tmp_dir, $globalDebug;
1443
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1645
+		if ($globalDebug) {
1646
+			echo "Modes Flarmnet: Download...";
1647
+		}
1444 1648
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1445 1649
 		if (file_exists($tmp_dir.'data.fln')) {
1446
-			if ($globalDebug) echo "Add to DB...";
1650
+			if ($globalDebug) {
1651
+				echo "Add to DB...";
1652
+			}
1447 1653
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1448
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1654
+		} else {
1655
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1656
+		}
1449 1657
 		if ($error != '') {
1450 1658
 			return $error;
1451
-		} elseif ($globalDebug) echo "Done\n";
1659
+		} elseif ($globalDebug) {
1660
+			echo "Done\n";
1661
+		}
1452 1662
 		return '';
1453 1663
 	}
1454 1664
 
1455 1665
 	public static function update_ModeS_ogn() {
1456 1666
 		global $tmp_dir, $globalDebug;
1457
-		if ($globalDebug) echo "Modes OGN: Download...";
1667
+		if ($globalDebug) {
1668
+			echo "Modes OGN: Download...";
1669
+		}
1458 1670
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1459 1671
 		if (file_exists($tmp_dir.'ogn.csv')) {
1460
-			if ($globalDebug) echo "Add to DB...";
1672
+			if ($globalDebug) {
1673
+				echo "Add to DB...";
1674
+			}
1461 1675
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1462
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1676
+		} else {
1677
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1678
+		}
1463 1679
 		if ($error != '') {
1464 1680
 			return $error;
1465
-		} elseif ($globalDebug) echo "Done\n";
1681
+		} elseif ($globalDebug) {
1682
+			echo "Done\n";
1683
+		}
1466 1684
 		return '';
1467 1685
 	}
1468 1686
 
1469 1687
 	public static function update_owner() {
1470 1688
 		global $tmp_dir, $globalDebug;
1471 1689
 		
1472
-		if ($globalDebug) echo "Owner France: Download...";
1690
+		if ($globalDebug) {
1691
+			echo "Owner France: Download...";
1692
+		}
1473 1693
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1474 1694
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1475
-			if ($globalDebug) echo "Add to DB...";
1695
+			if ($globalDebug) {
1696
+				echo "Add to DB...";
1697
+			}
1476 1698
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1477
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1699
+		} else {
1700
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1701
+		}
1478 1702
 		if ($error != '') {
1479 1703
 			return $error;
1480
-		} elseif ($globalDebug) echo "Done\n";
1704
+		} elseif ($globalDebug) {
1705
+			echo "Done\n";
1706
+		}
1481 1707
 		
1482
-		if ($globalDebug) echo "Owner Ireland: Download...";
1708
+		if ($globalDebug) {
1709
+			echo "Owner Ireland: Download...";
1710
+		}
1483 1711
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1484 1712
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1485
-			if ($globalDebug) echo "Add to DB...";
1713
+			if ($globalDebug) {
1714
+				echo "Add to DB...";
1715
+			}
1486 1716
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1487
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1717
+		} else {
1718
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1719
+		}
1488 1720
 		if ($error != '') {
1489 1721
 			return $error;
1490
-		} elseif ($globalDebug) echo "Done\n";
1491
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1722
+		} elseif ($globalDebug) {
1723
+			echo "Done\n";
1724
+		}
1725
+		if ($globalDebug) {
1726
+			echo "Owner Switzerland: Download...";
1727
+		}
1492 1728
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1493 1729
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1494
-			if ($globalDebug) echo "Add to DB...";
1730
+			if ($globalDebug) {
1731
+				echo "Add to DB...";
1732
+			}
1495 1733
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1496
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1734
+		} else {
1735
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1736
+		}
1497 1737
 		if ($error != '') {
1498 1738
 			return $error;
1499
-		} elseif ($globalDebug) echo "Done\n";
1500
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
1739
+		} elseif ($globalDebug) {
1740
+			echo "Done\n";
1741
+		}
1742
+		if ($globalDebug) {
1743
+			echo "Owner Czech Republic: Download...";
1744
+		}
1501 1745
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1502 1746
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1503
-			if ($globalDebug) echo "Add to DB...";
1747
+			if ($globalDebug) {
1748
+				echo "Add to DB...";
1749
+			}
1504 1750
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1505
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1751
+		} else {
1752
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1753
+		}
1506 1754
 		if ($error != '') {
1507 1755
 			return $error;
1508
-		} elseif ($globalDebug) echo "Done\n";
1509
-		if ($globalDebug) echo "Owner Australia: Download...";
1756
+		} elseif ($globalDebug) {
1757
+			echo "Done\n";
1758
+		}
1759
+		if ($globalDebug) {
1760
+			echo "Owner Australia: Download...";
1761
+		}
1510 1762
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1511 1763
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1512
-			if ($globalDebug) echo "Add to DB...";
1764
+			if ($globalDebug) {
1765
+				echo "Add to DB...";
1766
+			}
1513 1767
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1514
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1768
+		} else {
1769
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1770
+		}
1515 1771
 		if ($error != '') {
1516 1772
 			return $error;
1517
-		} elseif ($globalDebug) echo "Done\n";
1518
-		if ($globalDebug) echo "Owner Austria: Download...";
1773
+		} elseif ($globalDebug) {
1774
+			echo "Done\n";
1775
+		}
1776
+		if ($globalDebug) {
1777
+			echo "Owner Austria: Download...";
1778
+		}
1519 1779
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1520 1780
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1521
-			if ($globalDebug) echo "Add to DB...";
1781
+			if ($globalDebug) {
1782
+				echo "Add to DB...";
1783
+			}
1522 1784
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1523
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1785
+		} else {
1786
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1787
+		}
1524 1788
 		if ($error != '') {
1525 1789
 			return $error;
1526
-		} elseif ($globalDebug) echo "Done\n";
1527
-		if ($globalDebug) echo "Owner Chile: Download...";
1790
+		} elseif ($globalDebug) {
1791
+			echo "Done\n";
1792
+		}
1793
+		if ($globalDebug) {
1794
+			echo "Owner Chile: Download...";
1795
+		}
1528 1796
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1529 1797
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1530
-			if ($globalDebug) echo "Add to DB...";
1798
+			if ($globalDebug) {
1799
+				echo "Add to DB...";
1800
+			}
1531 1801
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1532
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1802
+		} else {
1803
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1804
+		}
1533 1805
 		if ($error != '') {
1534 1806
 			return $error;
1535
-		} elseif ($globalDebug) echo "Done\n";
1536
-		if ($globalDebug) echo "Owner Colombia: Download...";
1807
+		} elseif ($globalDebug) {
1808
+			echo "Done\n";
1809
+		}
1810
+		if ($globalDebug) {
1811
+			echo "Owner Colombia: Download...";
1812
+		}
1537 1813
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1538 1814
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1539
-			if ($globalDebug) echo "Add to DB...";
1815
+			if ($globalDebug) {
1816
+				echo "Add to DB...";
1817
+			}
1540 1818
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1541
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1819
+		} else {
1820
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1821
+		}
1542 1822
 		if ($error != '') {
1543 1823
 			return $error;
1544
-		} elseif ($globalDebug) echo "Done\n";
1545
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1824
+		} elseif ($globalDebug) {
1825
+			echo "Done\n";
1826
+		}
1827
+		if ($globalDebug) {
1828
+			echo "Owner Bosnia Herzegobina: Download...";
1829
+		}
1546 1830
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1547 1831
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1548
-			if ($globalDebug) echo "Add to DB...";
1832
+			if ($globalDebug) {
1833
+				echo "Add to DB...";
1834
+			}
1549 1835
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1550
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1836
+		} else {
1837
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1838
+		}
1551 1839
 		if ($error != '') {
1552 1840
 			return $error;
1553
-		} elseif ($globalDebug) echo "Done\n";
1554
-		if ($globalDebug) echo "Owner Brazil: Download...";
1841
+		} elseif ($globalDebug) {
1842
+			echo "Done\n";
1843
+		}
1844
+		if ($globalDebug) {
1845
+			echo "Owner Brazil: Download...";
1846
+		}
1555 1847
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1556 1848
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1557
-			if ($globalDebug) echo "Add to DB...";
1849
+			if ($globalDebug) {
1850
+				echo "Add to DB...";
1851
+			}
1558 1852
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1559
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1853
+		} else {
1854
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1855
+		}
1560 1856
 		if ($error != '') {
1561 1857
 			return $error;
1562
-		} elseif ($globalDebug) echo "Done\n";
1563
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1858
+		} elseif ($globalDebug) {
1859
+			echo "Done\n";
1860
+		}
1861
+		if ($globalDebug) {
1862
+			echo "Owner Cayman Islands: Download...";
1863
+		}
1564 1864
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1565 1865
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1566
-			if ($globalDebug) echo "Add to DB...";
1866
+			if ($globalDebug) {
1867
+				echo "Add to DB...";
1868
+			}
1567 1869
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1568
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1870
+		} else {
1871
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1872
+		}
1569 1873
 		if ($error != '') {
1570 1874
 			return $error;
1571
-		} elseif ($globalDebug) echo "Done\n";
1572
-		if ($globalDebug) echo "Owner Croatia: Download...";
1875
+		} elseif ($globalDebug) {
1876
+			echo "Done\n";
1877
+		}
1878
+		if ($globalDebug) {
1879
+			echo "Owner Croatia: Download...";
1880
+		}
1573 1881
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1574 1882
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1575
-			if ($globalDebug) echo "Add to DB...";
1883
+			if ($globalDebug) {
1884
+				echo "Add to DB...";
1885
+			}
1576 1886
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1577
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1887
+		} else {
1888
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1889
+		}
1578 1890
 		if ($error != '') {
1579 1891
 			return $error;
1580
-		} elseif ($globalDebug) echo "Done\n";
1581
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
1892
+		} elseif ($globalDebug) {
1893
+			echo "Done\n";
1894
+		}
1895
+		if ($globalDebug) {
1896
+			echo "Owner Luxembourg: Download...";
1897
+		}
1582 1898
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1583 1899
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1584
-			if ($globalDebug) echo "Add to DB...";
1900
+			if ($globalDebug) {
1901
+				echo "Add to DB...";
1902
+			}
1585 1903
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1586
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1904
+		} else {
1905
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1906
+		}
1587 1907
 		if ($error != '') {
1588 1908
 			return $error;
1589
-		} elseif ($globalDebug) echo "Done\n";
1590
-		if ($globalDebug) echo "Owner Maldives: Download...";
1909
+		} elseif ($globalDebug) {
1910
+			echo "Done\n";
1911
+		}
1912
+		if ($globalDebug) {
1913
+			echo "Owner Maldives: Download...";
1914
+		}
1591 1915
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1592 1916
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1593
-			if ($globalDebug) echo "Add to DB...";
1917
+			if ($globalDebug) {
1918
+				echo "Add to DB...";
1919
+			}
1594 1920
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1595
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1921
+		} else {
1922
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1923
+		}
1596 1924
 		if ($error != '') {
1597 1925
 			return $error;
1598
-		} elseif ($globalDebug) echo "Done\n";
1599
-		if ($globalDebug) echo "Owner New Zealand: Download...";
1926
+		} elseif ($globalDebug) {
1927
+			echo "Done\n";
1928
+		}
1929
+		if ($globalDebug) {
1930
+			echo "Owner New Zealand: Download...";
1931
+		}
1600 1932
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1601 1933
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1602
-			if ($globalDebug) echo "Add to DB...";
1934
+			if ($globalDebug) {
1935
+				echo "Add to DB...";
1936
+			}
1603 1937
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1604
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1938
+		} else {
1939
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1940
+		}
1605 1941
 		if ($error != '') {
1606 1942
 			return $error;
1607
-		} elseif ($globalDebug) echo "Done\n";
1608
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1943
+		} elseif ($globalDebug) {
1944
+			echo "Done\n";
1945
+		}
1946
+		if ($globalDebug) {
1947
+			echo "Owner Papua New Guinea: Download...";
1948
+		}
1609 1949
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1610 1950
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1611
-			if ($globalDebug) echo "Add to DB...";
1951
+			if ($globalDebug) {
1952
+				echo "Add to DB...";
1953
+			}
1612 1954
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1613
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1955
+		} else {
1956
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1957
+		}
1614 1958
 		if ($error != '') {
1615 1959
 			return $error;
1616
-		} elseif ($globalDebug) echo "Done\n";
1617
-		if ($globalDebug) echo "Owner Slovakia: Download...";
1960
+		} elseif ($globalDebug) {
1961
+			echo "Done\n";
1962
+		}
1963
+		if ($globalDebug) {
1964
+			echo "Owner Slovakia: Download...";
1965
+		}
1618 1966
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1619 1967
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1620
-			if ($globalDebug) echo "Add to DB...";
1968
+			if ($globalDebug) {
1969
+				echo "Add to DB...";
1970
+			}
1621 1971
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1622
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1972
+		} else {
1973
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1974
+		}
1623 1975
 		if ($error != '') {
1624 1976
 			return $error;
1625
-		} elseif ($globalDebug) echo "Done\n";
1626
-		if ($globalDebug) echo "Owner Ecuador: Download...";
1977
+		} elseif ($globalDebug) {
1978
+			echo "Done\n";
1979
+		}
1980
+		if ($globalDebug) {
1981
+			echo "Owner Ecuador: Download...";
1982
+		}
1627 1983
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1628 1984
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1629
-			if ($globalDebug) echo "Add to DB...";
1985
+			if ($globalDebug) {
1986
+				echo "Add to DB...";
1987
+			}
1630 1988
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1631
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1989
+		} else {
1990
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1991
+		}
1632 1992
 		if ($error != '') {
1633 1993
 			return $error;
1634
-		} elseif ($globalDebug) echo "Done\n";
1635
-		if ($globalDebug) echo "Owner Iceland: Download...";
1994
+		} elseif ($globalDebug) {
1995
+			echo "Done\n";
1996
+		}
1997
+		if ($globalDebug) {
1998
+			echo "Owner Iceland: Download...";
1999
+		}
1636 2000
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1637 2001
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1638
-			if ($globalDebug) echo "Add to DB...";
2002
+			if ($globalDebug) {
2003
+				echo "Add to DB...";
2004
+			}
1639 2005
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1640
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2006
+		} else {
2007
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2008
+		}
1641 2009
 		if ($error != '') {
1642 2010
 			return $error;
1643
-		} elseif ($globalDebug) echo "Done\n";
2011
+		} elseif ($globalDebug) {
2012
+			echo "Done\n";
2013
+		}
1644 2014
 		return '';
1645 2015
 	}
1646 2016
 
1647 2017
 	public static function update_translation() {
1648 2018
 		global $tmp_dir, $globalDebug;
1649 2019
 		$error = '';
1650
-		if ($globalDebug) echo "Translation : Download...";
2020
+		if ($globalDebug) {
2021
+			echo "Translation : Download...";
2022
+		}
1651 2023
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1652 2024
 		if (file_exists($tmp_dir.'translation.zip')) {
1653
-			if ($globalDebug) echo "Unzip...";
2025
+			if ($globalDebug) {
2026
+				echo "Unzip...";
2027
+			}
1654 2028
 			update_db::unzip($tmp_dir.'translation.zip');
1655
-			if ($globalDebug) echo "Add to DB...";
2029
+			if ($globalDebug) {
2030
+				echo "Add to DB...";
2031
+			}
1656 2032
 			$error = update_db::translation();
1657
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2033
+		} else {
2034
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2035
+		}
1658 2036
 		if ($error != '') {
1659 2037
 			return $error;
1660
-		} elseif ($globalDebug) echo "Done\n";
2038
+		} elseif ($globalDebug) {
2039
+			echo "Done\n";
2040
+		}
1661 2041
 		return '';
1662 2042
 	}
1663 2043
 
1664 2044
 	public static function update_translation_fam() {
1665 2045
 		global $tmp_dir, $globalDebug;
1666
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2046
+		if ($globalDebug) {
2047
+			echo "Translation from FlightAirMap website : Download...";
2048
+		}
1667 2049
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1668 2050
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1669
-			if ($globalDebug) echo "Gunzip...";
2051
+			if ($globalDebug) {
2052
+				echo "Gunzip...";
2053
+			}
1670 2054
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1671
-			if ($globalDebug) echo "Add to DB...";
2055
+			if ($globalDebug) {
2056
+				echo "Add to DB...";
2057
+			}
1672 2058
 			$error = update_db::translation_fam();
1673
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2059
+		} else {
2060
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2061
+		}
1674 2062
 		if ($error != '') {
1675 2063
 			return $error;
1676
-		} elseif ($globalDebug) echo "Done\n";
2064
+		} elseif ($globalDebug) {
2065
+			echo "Done\n";
2066
+		}
1677 2067
 		return '';
1678 2068
 	}
1679 2069
 	public static function update_ModeS_fam() {
1680 2070
 		global $tmp_dir, $globalDebug;
1681
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2071
+		if ($globalDebug) {
2072
+			echo "ModeS from FlightAirMap website : Download...";
2073
+		}
1682 2074
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1683 2075
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1684
-			if ($globalDebug) echo "Gunzip...";
2076
+			if ($globalDebug) {
2077
+				echo "Gunzip...";
2078
+			}
1685 2079
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1686
-			if ($globalDebug) echo "Add to DB...";
2080
+			if ($globalDebug) {
2081
+				echo "Add to DB...";
2082
+			}
1687 2083
 			$error = update_db::modes_fam();
1688
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2084
+		} else {
2085
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2086
+		}
1689 2087
 		if ($error != '') {
1690 2088
 			return $error;
1691
-		} elseif ($globalDebug) echo "Done\n";
2089
+		} elseif ($globalDebug) {
2090
+			echo "Done\n";
2091
+		}
1692 2092
 		return '';
1693 2093
 	}
1694 2094
 	public static function update_routes_fam() {
1695 2095
 		global $tmp_dir, $globalDebug;
1696
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2096
+		if ($globalDebug) {
2097
+			echo "Routes from FlightAirMap website : Download...";
2098
+		}
1697 2099
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1698 2100
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1699
-			if ($globalDebug) echo "Gunzip...";
2101
+			if ($globalDebug) {
2102
+				echo "Gunzip...";
2103
+			}
1700 2104
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
1701
-			if ($globalDebug) echo "Add to DB...";
2105
+			if ($globalDebug) {
2106
+				echo "Add to DB...";
2107
+			}
1702 2108
 			$error = update_db::routes_fam();
1703
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2109
+		} else {
2110
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2111
+		}
1704 2112
 		if ($error != '') {
1705 2113
 			return $error;
1706
-		} elseif ($globalDebug) echo "Done\n";
2114
+		} elseif ($globalDebug) {
2115
+			echo "Done\n";
2116
+		}
1707 2117
 		return '';
1708 2118
 	}
1709 2119
 
@@ -1711,7 +2121,9 @@  discard block
 block discarded – undo
1711 2121
 		global $tmp_dir, $globalDebug, $globalDBdriver;
1712 2122
 		include_once('class.create_db.php');
1713 2123
 		$error = '';
1714
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2124
+		if ($globalDebug) {
2125
+			echo "Airspace from FlightAirMap website : Download...";
2126
+		}
1715 2127
 		if ($globalDBdriver == 'mysql') {
1716 2128
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1717 2129
 		} else {
@@ -1727,9 +2139,13 @@  discard block
 block discarded – undo
1727 2139
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1728 2140
 				}
1729 2141
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1730
-					if ($globalDebug) echo "Gunzip...";
2142
+					if ($globalDebug) {
2143
+						echo "Gunzip...";
2144
+					}
1731 2145
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
1732
-					if ($globalDebug) echo "Add to DB...";
2146
+					if ($globalDebug) {
2147
+						echo "Add to DB...";
2148
+					}
1733 2149
 					$Connection = new Connection();
1734 2150
 					if ($Connection->tableExists('airspace')) {
1735 2151
 						$query = 'DROP TABLE airspace';
@@ -1742,31 +2158,47 @@  discard block
 block discarded – undo
1742 2158
 		    			}
1743 2159
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1744 2160
 					update_db::insert_airspace_version($airspace_md5);
1745
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2161
+				} else {
2162
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2163
+				}
1746 2164
 			}
1747
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2165
+		} else {
2166
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2167
+		}
1748 2168
 		if ($error != '') {
1749 2169
 			return $error;
1750
-		} elseif ($globalDebug) echo "Done\n";
2170
+		} elseif ($globalDebug) {
2171
+			echo "Done\n";
2172
+		}
1751 2173
 		return '';
1752 2174
 	}
1753 2175
 
1754 2176
 	public static function update_tle() {
1755 2177
 		global $tmp_dir, $globalDebug;
1756
-		if ($globalDebug) echo "Download TLE : Download...";
2178
+		if ($globalDebug) {
2179
+			echo "Download TLE : Download...";
2180
+		}
1757 2181
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
1758 2182
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
1759 2183
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1760 2184
 		foreach ($alltle as $filename) {
1761
-			if ($globalDebug) echo "downloading ".$filename.'...';
2185
+			if ($globalDebug) {
2186
+				echo "downloading ".$filename.'...';
2187
+			}
1762 2188
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1763 2189
 			if (file_exists($tmp_dir.$filename)) {
1764
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2190
+				if ($globalDebug) {
2191
+					echo "Add to DB ".$filename."...";
2192
+				}
1765 2193
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1766
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2194
+			} else {
2195
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2196
+			}
1767 2197
 			if ($error != '') {
1768 2198
 				echo $error."\n";
1769
-			} elseif ($globalDebug) echo "Done\n";
2199
+			} elseif ($globalDebug) {
2200
+				echo "Done\n";
2201
+			}
1770 2202
 		}
1771 2203
 		return '';
1772 2204
 	}
@@ -1774,10 +2206,14 @@  discard block
 block discarded – undo
1774 2206
 	public static function update_models() {
1775 2207
 		global $tmp_dir, $globalDebug;
1776 2208
 		$error = '';
1777
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2209
+		if ($globalDebug) {
2210
+			echo "Models from FlightAirMap website : Download...";
2211
+		}
1778 2212
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1779 2213
 		if (file_exists($tmp_dir.'models.md5sum')) {
1780
-			if ($globalDebug) echo "Check files...\n";
2214
+			if ($globalDebug) {
2215
+				echo "Check files...\n";
2216
+			}
1781 2217
 			$newmodelsdb = array();
1782 2218
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1783 2219
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1796,25 +2232,35 @@  discard block
 block discarded – undo
1796 2232
 			}
1797 2233
 			$diff = array_diff($newmodelsdb,$modelsdb);
1798 2234
 			foreach ($diff as $key => $value) {
1799
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2235
+				if ($globalDebug) {
2236
+					echo 'Downloading model '.$key.' ...'."\n";
2237
+				}
1800 2238
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1801 2239
 				
1802 2240
 			}
1803 2241
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1804
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2242
+		} else {
2243
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2244
+		}
1805 2245
 		if ($error != '') {
1806 2246
 			return $error;
1807
-		} elseif ($globalDebug) echo "Done\n";
2247
+		} elseif ($globalDebug) {
2248
+			echo "Done\n";
2249
+		}
1808 2250
 		return '';
1809 2251
 	}
1810 2252
 
1811 2253
 	public static function update_space_models() {
1812 2254
 		global $tmp_dir, $globalDebug;
1813 2255
 		$error = '';
1814
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2256
+		if ($globalDebug) {
2257
+			echo "Space models from FlightAirMap website : Download...";
2258
+		}
1815 2259
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1816 2260
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1817
-			if ($globalDebug) echo "Check files...\n";
2261
+			if ($globalDebug) {
2262
+				echo "Check files...\n";
2263
+			}
1818 2264
 			$newmodelsdb = array();
1819 2265
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1820 2266
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1833,15 +2279,21 @@  discard block
 block discarded – undo
1833 2279
 			}
1834 2280
 			$diff = array_diff($newmodelsdb,$modelsdb);
1835 2281
 			foreach ($diff as $key => $value) {
1836
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2282
+				if ($globalDebug) {
2283
+					echo 'Downloading space model '.$key.' ...'."\n";
2284
+				}
1837 2285
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
1838 2286
 				
1839 2287
 			}
1840 2288
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
1841
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2289
+		} else {
2290
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2291
+		}
1842 2292
 		if ($error != '') {
1843 2293
 			return $error;
1844
-		} elseif ($globalDebug) echo "Done\n";
2294
+		} elseif ($globalDebug) {
2295
+			echo "Done\n";
2296
+		}
1845 2297
 		return '';
1846 2298
 	}
1847 2299
 
@@ -1884,7 +2336,9 @@  discard block
 block discarded – undo
1884 2336
                 }
1885 2337
 
1886 2338
 		$error = '';
1887
-		if ($globalDebug) echo "Notam : Download...";
2339
+		if ($globalDebug) {
2340
+			echo "Notam : Download...";
2341
+		}
1888 2342
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
1889 2343
 		if (file_exists($tmp_dir.'notam.rss')) {
1890 2344
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -1899,14 +2353,30 @@  discard block
 block discarded – undo
1899 2353
 				$data['fir'] = $q[0];
1900 2354
 				$data['code'] = $q[1];
1901 2355
 				$ifrvfr = $q[2];
1902
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
1903
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
1904
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
1905
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
1906
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
1907
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
1908
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
1909
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2356
+				if ($ifrvfr == 'IV') {
2357
+					$data['rules'] = 'IFR/VFR';
2358
+				}
2359
+				if ($ifrvfr == 'I') {
2360
+					$data['rules'] = 'IFR';
2361
+				}
2362
+				if ($ifrvfr == 'V') {
2363
+					$data['rules'] = 'VFR';
2364
+				}
2365
+				if ($q[4] == 'A') {
2366
+					$data['scope'] = 'Airport warning';
2367
+				}
2368
+				if ($q[4] == 'E') {
2369
+					$data['scope'] = 'Enroute warning';
2370
+				}
2371
+				if ($q[4] == 'W') {
2372
+					$data['scope'] = 'Navigation warning';
2373
+				}
2374
+				if ($q[4] == 'AE') {
2375
+					$data['scope'] = 'Airport/Enroute warning';
2376
+				}
2377
+				if ($q[4] == 'AW') {
2378
+					$data['scope'] = 'Airport/Navigation warning';
2379
+				}
1910 2380
 				//$data['scope'] = $q[4];
1911 2381
 				$data['lower_limit'] = $q[5];
1912 2382
 				$data['upper_limit'] = $q[6];
@@ -1914,8 +2384,12 @@  discard block
 block discarded – undo
1914 2384
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
1915 2385
 				$latitude = $Common->convertDec($las,'latitude');
1916 2386
 				$longitude = $Common->convertDec($lns,'longitude');
1917
-				if ($lac == 'S') $latitude = '-'.$latitude;
1918
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2387
+				if ($lac == 'S') {
2388
+					$latitude = '-'.$latitude;
2389
+				}
2390
+				if ($lnc == 'W') {
2391
+					$longitude = '-'.$longitude;
2392
+				}
1919 2393
 				$data['center_latitude'] = $latitude;
1920 2394
 				$data['center_longitude'] = $longitude;
1921 2395
 				$data['radius'] = intval($radius);
@@ -1945,10 +2419,14 @@  discard block
 block discarded – undo
1945 2419
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1946 2420
 				unset($data);
1947 2421
 			} 
1948
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2422
+		} else {
2423
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2424
+		}
1949 2425
 		if ($error != '') {
1950 2426
 			return $error;
1951
-		} elseif ($globalDebug) echo "Done\n";
2427
+		} elseif ($globalDebug) {
2428
+			echo "Done\n";
2429
+		}
1952 2430
 		return '';
1953 2431
 	}
1954 2432
 	
@@ -1973,7 +2451,9 @@  discard block
 block discarded – undo
1973 2451
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
1974 2452
 		$airspace_json = json_decode($airspace_lst,true);
1975 2453
 		foreach ($airspace_json['records'] as $airspace) {
1976
-			if ($globalDebug) echo $airspace['name']."...\n";
2454
+			if ($globalDebug) {
2455
+				echo $airspace['name']."...\n";
2456
+			}
1977 2457
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
1978 2458
 			if (file_exists($tmp_dir.$airspace['name'])) {
1979 2459
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2002,8 +2482,11 @@  discard block
 block discarded – undo
2002 2482
                         return "error : ".$e->getMessage();
2003 2483
                 }
2004 2484
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2005
-                if ($row['nb'] > 0) return false;
2006
-                else return true;
2485
+                if ($row['nb'] > 0) {
2486
+                	return false;
2487
+                } else {
2488
+                	return true;
2489
+                }
2007 2490
 	}
2008 2491
 
2009 2492
 	public static function insert_last_update() {
@@ -2028,8 +2511,11 @@  discard block
 block discarded – undo
2028 2511
                         return "error : ".$e->getMessage();
2029 2512
                 }
2030 2513
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2031
-                if ($row['nb'] > 0) return true;
2032
-                else return false;
2514
+                if ($row['nb'] > 0) {
2515
+                	return true;
2516
+                } else {
2517
+                	return false;
2518
+                }
2033 2519
 	}
2034 2520
 
2035 2521
 
@@ -2060,8 +2546,11 @@  discard block
 block discarded – undo
2060 2546
                         return "error : ".$e->getMessage();
2061 2547
                 }
2062 2548
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2063
-                if ($row['nb'] > 0) return false;
2064
-                else return true;
2549
+                if ($row['nb'] > 0) {
2550
+                	return false;
2551
+                } else {
2552
+                	return true;
2553
+                }
2065 2554
 	}
2066 2555
 
2067 2556
 	public static function insert_last_notam_update() {
@@ -2090,8 +2579,11 @@  discard block
 block discarded – undo
2090 2579
                         return "error : ".$e->getMessage();
2091 2580
                 }
2092 2581
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2093
-                if ($row['nb'] > 0) return false;
2094
-                else return true;
2582
+                if ($row['nb'] > 0) {
2583
+                	return false;
2584
+                } else {
2585
+                	return true;
2586
+                }
2095 2587
 	}
2096 2588
 
2097 2589
 	public static function insert_last_airspace_update() {
@@ -2121,8 +2613,11 @@  discard block
 block discarded – undo
2121 2613
                         return "error : ".$e->getMessage();
2122 2614
                 }
2123 2615
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2124
-                if ($row['nb'] > 0) return false;
2125
-                else return true;
2616
+                if ($row['nb'] > 0) {
2617
+                	return false;
2618
+                } else {
2619
+                	return true;
2620
+                }
2126 2621
 	}
2127 2622
 
2128 2623
 	public static function insert_last_owner_update() {
@@ -2151,8 +2646,11 @@  discard block
 block discarded – undo
2151 2646
                         return "error : ".$e->getMessage();
2152 2647
                 }
2153 2648
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2154
-                if ($row['nb'] > 0) return false;
2155
-                else return true;
2649
+                if ($row['nb'] > 0) {
2650
+                	return false;
2651
+                } else {
2652
+                	return true;
2653
+                }
2156 2654
 	}
2157 2655
 
2158 2656
 	public static function insert_last_schedules_update() {
@@ -2181,8 +2679,11 @@  discard block
 block discarded – undo
2181 2679
                         return "error : ".$e->getMessage();
2182 2680
                 }
2183 2681
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2184
-                if ($row['nb'] > 0) return false;
2185
-                else return true;
2682
+                if ($row['nb'] > 0) {
2683
+                	return false;
2684
+                } else {
2685
+                	return true;
2686
+                }
2186 2687
 	}
2187 2688
 
2188 2689
 	public static function insert_last_tle_update() {
Please login to merge, or discard this patch.
require/libs/Predict/Predict.php 4 patches
Doc Comments   +3 added lines, -17 removed lines patch added patch discarded remove patch
@@ -146,20 +146,6 @@  discard block
 block discarded – undo
146 146
 
147 147
     /** Predict first pass after a certain time.
148 148
      *
149
-     *  @param Predict_Sat $sat   The satellite data.
150
-     *  @param Predict_QTH $qth   The observer's location data.
151
-     *  @param float       $start Starting time.
152
-     *  @param int         $maxdt The maximum number of days to look ahead (0 for no limit).
153
-     *
154
-     *  @return Predict_Pass or NULL if there was an error.
155
-     *
156
-     * This function will find the first upcoming pass with AOS no earlier than
157
-     * t = start and no later than t = (start+maxdt).
158
-     *
159
-     *  note For no time limit use maxdt = 0.0
160
-     *
161
-     *  note the data in sat will be corrupt (future) and must be refreshed
162
-     *       by the caller, if the caller will need it later on
163 149
      */
164 150
     public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt)
165 151
     {
@@ -407,7 +393,7 @@  discard block
 block discarded – undo
407 393
      *  @param Predict_QTH $qth   The observer's location (QTH) data.
408 394
      *  @param float       $start The julian date where calculation should start.
409 395
      *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
410
-     *  @return The julain date of the next AOS or 0.0 if the satellite has no AOS.
396
+     *  @return double julain date of the next AOS or 0.0 if the satellite has no AOS.
411 397
      *
412 398
      * This function finds the time of AOS for the first coming pass taking place
413 399
      * no earlier that start.
@@ -563,7 +549,7 @@  discard block
 block discarded – undo
563 549
      *  @param Predict_QTH $qth The QTH observer location data.
564 550
      *  @param float       $start The time where calculation should start. (Julian Date)
565 551
      *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
566
-     *  @return The time (julian date) of the next LOS or 0.0 if the satellite has no LOS.
552
+     *  @return double time (julian date) of the next LOS or 0.0 if the satellite has no LOS.
567 553
      *
568 554
      * This function finds the time of LOS for the first coming pass taking place
569 555
      * no earlier that start.
@@ -648,7 +634,7 @@  discard block
 block discarded – undo
648 634
      *  @param Predict_Sat $sat   The satellite to find AOS for.
649 635
      *  @param Predict_QTH $qth   The ground station.
650 636
      *  @param float       $start Start time, prefereably now.
651
-     *  @return The time of the previous AOS or 0.0 if the satellite has no AOS.
637
+     *  @return double time of the previous AOS or 0.0 if the satellite has no AOS.
652 638
      *
653 639
      * This function can be used to find the AOS time in the past of the
654 640
      * current pass.
Please login to merge, or discard this patch.
Indentation   +791 added lines, -791 removed lines patch added patch discarded remove patch
@@ -52,824 +52,824 @@
 block discarded – undo
52 52
  */
53 53
 class Predict
54 54
 {
55
-    const de2ra    =  1.74532925E-2;   /* Degrees to Radians */
56
-    const pi       =  3.1415926535898; /* Pi */
57
-    const pio2     =  1.5707963267949; /* Pi/2 */
58
-    const x3pio2   =  4.71238898;      /* 3*Pi/2 */
59
-    const twopi    =  6.2831853071796; /* 2*Pi  */
60
-    const e6a      =  1.0E-6;
61
-    const tothrd   =  6.6666667E-1;    /* 2/3 */
62
-    const xj2      =  1.0826158E-3;    /* J2 Harmonic */
63
-    const xj3      = -2.53881E-6;      /* J3 Harmonic */
64
-    const xj4      = -1.65597E-6;      /* J4 Harmonic */
65
-    const xke      =  7.43669161E-2;
66
-    const xkmper   =  6.378135E3;      /* Earth radius km */
67
-    const xmnpda   =  1.44E3;          /* Minutes per day */
68
-    const km2mi    =  0.621371;        /* Kilometers per Mile */
69
-    const ae       =  1.0;
70
-    const ck2      =  5.413079E-4;
71
-    const ck4      =  6.209887E-7;
72
-    const __f      =  3.352779E-3;
73
-    const ge       =  3.986008E5;
74
-    const __s__    =  1.012229;
75
-    const qoms2t   =  1.880279E-09;
76
-    const secday   =  8.6400E4;        /* Seconds per day */
77
-    const omega_E  =  1.0027379;
78
-    const omega_ER =  6.3003879;
79
-    const zns      =  1.19459E-5;
80
-    const c1ss     =  2.9864797E-6;
81
-    const zes      =  1.675E-2;
82
-    const znl      =  1.5835218E-4;
83
-    const c1l      =  4.7968065E-7;
84
-    const zel      =  5.490E-2;
85
-    const zcosis   =  9.1744867E-1;
86
-    const zsinis   =  3.9785416E-1;
87
-    const zsings   = -9.8088458E-1;
88
-    const zcosgs   =  1.945905E-1;
89
-    const zcoshs   =  1;
90
-    const zsinhs   =  0;
91
-    const q22      =  1.7891679E-6;
92
-    const q31      =  2.1460748E-6;
93
-    const q33      =  2.2123015E-7;
94
-    const g22      =  5.7686396;
95
-    const g32      =  9.5240898E-1;
96
-    const g44      =  1.8014998;
97
-    const g52      =  1.0508330;
98
-    const g54      =  4.4108898;
99
-    const root22   =  1.7891679E-6;
100
-    const root32   =  3.7393792E-7;
101
-    const root44   =  7.3636953E-9;
102
-    const root52   =  1.1428639E-7;
103
-    const root54   =  2.1765803E-9;
104
-    const thdt     =  4.3752691E-3;
105
-    const rho      =  1.5696615E-1;
106
-    const mfactor  =  7.292115E-5;
107
-    const __sr__   =  6.96000E5;      /*Solar radius - kilometers (IAU 76)*/
108
-    const AU       =  1.49597870E8;   /*Astronomical unit - kilometers (IAU 76)*/
109
-
110
-    /* visibility constants */
111
-    const SAT_VIS_NONE     = 0;
112
-    const SAT_VIS_VISIBLE  = 1;
113
-    const SAT_VIS_DAYLIGHT = 2;
114
-    const SAT_VIS_ECLIPSED = 3;
115
-
116
-    /* preferences */
117
-    public $minEle     = 10; // Minimum elevation
118
-    public $timeRes    = 10; // Pass details: time resolution
119
-    public $numEntries = 20; // Pass details: number of entries
120
-    public $threshold  = -6; // Twilight threshold
121
-
122
-    /**
123
-     *  Predict the next pass.
124
-     *
125
-     * This function simply wraps the get_pass function using the current time
126
-     * as parameter.
127
-     *
128
-     * Note: the data in sat will be corrupt (future) and must be refreshed
129
-     *       by the caller, if the caller will need it later on (eg. if the caller
130
-     *       is GtkSatList).
131
-     *
132
-     * @param Predict_Sat $sat   The satellite data.
133
-     * @param Predict_QTH $qth   The observer data.
134
-     * @param int         $maxdt The maximum number of days to look ahead.
135
-     *
136
-     * @return Predict_Pass Pointer instance or NULL if no pass can be
137
-     *         found.
138
-     */
139
-    public function get_next_pass(Predict_Sat $sat, Predict_QTH $qth, $maxdt)
140
-    {
141
-        /* get the current time and call the get_pass function */
142
-        $now = Predict_Time::get_current_daynum();
143
-
144
-        return $this->get_pass($sat, $qth, $now, $maxdt);
145
-    }
146
-
147
-    /** Predict first pass after a certain time.
148
-     *
149
-     *  @param Predict_Sat $sat   The satellite data.
150
-     *  @param Predict_QTH $qth   The observer's location data.
151
-     *  @param float       $start Starting time.
152
-     *  @param int         $maxdt The maximum number of days to look ahead (0 for no limit).
153
-     *
154
-     *  @return Predict_Pass or NULL if there was an error.
155
-     *
156
-     * This function will find the first upcoming pass with AOS no earlier than
157
-     * t = start and no later than t = (start+maxdt).
158
-     *
159
-     *  note For no time limit use maxdt = 0.0
160
-     *
161
-     *  note the data in sat will be corrupt (future) and must be refreshed
162
-     *       by the caller, if the caller will need it later on
163
-     */
164
-    public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt)
165
-    {
166
-        $aos = 0.0;    /* time of AOS */
167
-        $tca = 0.0;    /* time of TCA */
168
-        $los = 0.0;    /* time of LOS */
169
-        $dt = 0.0;     /* time diff */
170
-        $step = 0.0;   /* time step */
171
-        $t0 = $start;
172
-        $tres = 0.0;   /* required time resolution */
173
-        $max_el = 0.0; /* maximum elevation */
174
-        $pass = null;
175
-        $detail = null;
176
-        $done = false;
177
-        $iter = 0;      /* number of iterations */
178
-        /* FIXME: watchdog */
179
-
180
-        /*copy sat_in to a working structure*/
181
-        $sat         = clone $sat_in;
182
-        $sat_working = clone $sat_in;
183
-
184
-        /* get time resolution; sat-cfg stores it in seconds */
185
-        $tres = $this->timeRes / 86400.0;
186
-
187
-        /* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL
55
+	const de2ra    =  1.74532925E-2;   /* Degrees to Radians */
56
+	const pi       =  3.1415926535898; /* Pi */
57
+	const pio2     =  1.5707963267949; /* Pi/2 */
58
+	const x3pio2   =  4.71238898;      /* 3*Pi/2 */
59
+	const twopi    =  6.2831853071796; /* 2*Pi  */
60
+	const e6a      =  1.0E-6;
61
+	const tothrd   =  6.6666667E-1;    /* 2/3 */
62
+	const xj2      =  1.0826158E-3;    /* J2 Harmonic */
63
+	const xj3      = -2.53881E-6;      /* J3 Harmonic */
64
+	const xj4      = -1.65597E-6;      /* J4 Harmonic */
65
+	const xke      =  7.43669161E-2;
66
+	const xkmper   =  6.378135E3;      /* Earth radius km */
67
+	const xmnpda   =  1.44E3;          /* Minutes per day */
68
+	const km2mi    =  0.621371;        /* Kilometers per Mile */
69
+	const ae       =  1.0;
70
+	const ck2      =  5.413079E-4;
71
+	const ck4      =  6.209887E-7;
72
+	const __f      =  3.352779E-3;
73
+	const ge       =  3.986008E5;
74
+	const __s__    =  1.012229;
75
+	const qoms2t   =  1.880279E-09;
76
+	const secday   =  8.6400E4;        /* Seconds per day */
77
+	const omega_E  =  1.0027379;
78
+	const omega_ER =  6.3003879;
79
+	const zns      =  1.19459E-5;
80
+	const c1ss     =  2.9864797E-6;
81
+	const zes      =  1.675E-2;
82
+	const znl      =  1.5835218E-4;
83
+	const c1l      =  4.7968065E-7;
84
+	const zel      =  5.490E-2;
85
+	const zcosis   =  9.1744867E-1;
86
+	const zsinis   =  3.9785416E-1;
87
+	const zsings   = -9.8088458E-1;
88
+	const zcosgs   =  1.945905E-1;
89
+	const zcoshs   =  1;
90
+	const zsinhs   =  0;
91
+	const q22      =  1.7891679E-6;
92
+	const q31      =  2.1460748E-6;
93
+	const q33      =  2.2123015E-7;
94
+	const g22      =  5.7686396;
95
+	const g32      =  9.5240898E-1;
96
+	const g44      =  1.8014998;
97
+	const g52      =  1.0508330;
98
+	const g54      =  4.4108898;
99
+	const root22   =  1.7891679E-6;
100
+	const root32   =  3.7393792E-7;
101
+	const root44   =  7.3636953E-9;
102
+	const root52   =  1.1428639E-7;
103
+	const root54   =  2.1765803E-9;
104
+	const thdt     =  4.3752691E-3;
105
+	const rho      =  1.5696615E-1;
106
+	const mfactor  =  7.292115E-5;
107
+	const __sr__   =  6.96000E5;      /*Solar radius - kilometers (IAU 76)*/
108
+	const AU       =  1.49597870E8;   /*Astronomical unit - kilometers (IAU 76)*/
109
+
110
+	/* visibility constants */
111
+	const SAT_VIS_NONE     = 0;
112
+	const SAT_VIS_VISIBLE  = 1;
113
+	const SAT_VIS_DAYLIGHT = 2;
114
+	const SAT_VIS_ECLIPSED = 3;
115
+
116
+	/* preferences */
117
+	public $minEle     = 10; // Minimum elevation
118
+	public $timeRes    = 10; // Pass details: time resolution
119
+	public $numEntries = 20; // Pass details: number of entries
120
+	public $threshold  = -6; // Twilight threshold
121
+
122
+	/**
123
+	 *  Predict the next pass.
124
+	 *
125
+	 * This function simply wraps the get_pass function using the current time
126
+	 * as parameter.
127
+	 *
128
+	 * Note: the data in sat will be corrupt (future) and must be refreshed
129
+	 *       by the caller, if the caller will need it later on (eg. if the caller
130
+	 *       is GtkSatList).
131
+	 *
132
+	 * @param Predict_Sat $sat   The satellite data.
133
+	 * @param Predict_QTH $qth   The observer data.
134
+	 * @param int         $maxdt The maximum number of days to look ahead.
135
+	 *
136
+	 * @return Predict_Pass Pointer instance or NULL if no pass can be
137
+	 *         found.
138
+	 */
139
+	public function get_next_pass(Predict_Sat $sat, Predict_QTH $qth, $maxdt)
140
+	{
141
+		/* get the current time and call the get_pass function */
142
+		$now = Predict_Time::get_current_daynum();
143
+
144
+		return $this->get_pass($sat, $qth, $now, $maxdt);
145
+	}
146
+
147
+	/** Predict first pass after a certain time.
148
+	 *
149
+	 *  @param Predict_Sat $sat   The satellite data.
150
+	 *  @param Predict_QTH $qth   The observer's location data.
151
+	 *  @param float       $start Starting time.
152
+	 *  @param int         $maxdt The maximum number of days to look ahead (0 for no limit).
153
+	 *
154
+	 *  @return Predict_Pass or NULL if there was an error.
155
+	 *
156
+	 * This function will find the first upcoming pass with AOS no earlier than
157
+	 * t = start and no later than t = (start+maxdt).
158
+	 *
159
+	 *  note For no time limit use maxdt = 0.0
160
+	 *
161
+	 *  note the data in sat will be corrupt (future) and must be refreshed
162
+	 *       by the caller, if the caller will need it later on
163
+	 */
164
+	public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt)
165
+	{
166
+		$aos = 0.0;    /* time of AOS */
167
+		$tca = 0.0;    /* time of TCA */
168
+		$los = 0.0;    /* time of LOS */
169
+		$dt = 0.0;     /* time diff */
170
+		$step = 0.0;   /* time step */
171
+		$t0 = $start;
172
+		$tres = 0.0;   /* required time resolution */
173
+		$max_el = 0.0; /* maximum elevation */
174
+		$pass = null;
175
+		$detail = null;
176
+		$done = false;
177
+		$iter = 0;      /* number of iterations */
178
+		/* FIXME: watchdog */
179
+
180
+		/*copy sat_in to a working structure*/
181
+		$sat         = clone $sat_in;
182
+		$sat_working = clone $sat_in;
183
+
184
+		/* get time resolution; sat-cfg stores it in seconds */
185
+		$tres = $this->timeRes / 86400.0;
186
+
187
+		/* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL
188 188
             or we run out of time
189 189
             FIXME: we should have a safety break
190 190
         */
191
-        while (!$done) {
192
-            /* Find los of next pass or of current pass */
193
-            $los = $this->find_los($sat, $qth, $t0, $maxdt); // See if a pass is ongoing
194
-            $aos = $this->find_aos($sat, $qth, $t0, $maxdt);
195
-            /* sat_log_log(SAT_LOG_LEVEL_MSG, "%s:%s:%d: found aos %f and los %f for t0=%f", */
196
-            /*          __FILE__,  */
197
-            /*          __FUNCTION__, */
198
-            /*          __LINE__, */
199
-            /*          aos, */
200
-            /*          los,  */
201
-            /*          t0); */
202
-            if ($aos > $los) {
203
-                // los is from an currently happening pass, find previous aos
204
-                $aos = $this->find_prev_aos($sat, $qth, $t0);
205
-            }
206
-
207
-            /* aos = 0.0 means no aos */
208
-            if ($aos == 0.0) {
209
-                $done = true;
210
-            } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) {
211
-                /* check whether we are within time limits;
191
+		while (!$done) {
192
+			/* Find los of next pass or of current pass */
193
+			$los = $this->find_los($sat, $qth, $t0, $maxdt); // See if a pass is ongoing
194
+			$aos = $this->find_aos($sat, $qth, $t0, $maxdt);
195
+			/* sat_log_log(SAT_LOG_LEVEL_MSG, "%s:%s:%d: found aos %f and los %f for t0=%f", */
196
+			/*          __FILE__,  */
197
+			/*          __FUNCTION__, */
198
+			/*          __LINE__, */
199
+			/*          aos, */
200
+			/*          los,  */
201
+			/*          t0); */
202
+			if ($aos > $los) {
203
+				// los is from an currently happening pass, find previous aos
204
+				$aos = $this->find_prev_aos($sat, $qth, $t0);
205
+			}
206
+
207
+			/* aos = 0.0 means no aos */
208
+			if ($aos == 0.0) {
209
+				$done = true;
210
+			} else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) {
211
+				/* check whether we are within time limits;
212 212
                     maxdt = 0 mean no time limit.
213 213
                 */
214
-                $done = true;
215
-            } else {
216
-                //los = find_los (sat, qth, aos + 0.001, maxdt); // +1.5 min later
217
-                $dt = $los - $aos;
214
+				$done = true;
215
+			} else {
216
+				//los = find_los (sat, qth, aos + 0.001, maxdt); // +1.5 min later
217
+				$dt = $los - $aos;
218 218
 
219
-                /* get time step, which will give us the max number of entries */
220
-                $step = $dt / $this->numEntries;
219
+				/* get time step, which will give us the max number of entries */
220
+				$step = $dt / $this->numEntries;
221 221
 
222
-                /* but if this is smaller than the required resolution
222
+				/* but if this is smaller than the required resolution
223 223
                     we go with the resolution
224 224
                 */
225
-                if ($step < $tres) {
226
-                    $step = $tres;
227
-                }
228
-
229
-                /* create a pass_t entry; FIXME: g_try_new in 2.8 */
230
-                $pass = new Predict_Pass();
231
-
232
-                $pass->aos      = $aos;
233
-                $pass->los      = $los;
234
-                $pass->max_el   = 0.0;
235
-                $pass->aos_az   = 0.0;
236
-                $pass->los_az   = 0.0;
237
-                $pass->maxel_az = 0.0;
238
-                $pass->vis      = '---';
239
-                $pass->satname  = $sat->nickname;
240
-                $pass->details  = array();
241
-
242
-                /* iterate over each time step */
243
-                for ($t = $pass->aos; $t <= $pass->los; $t += $step) {
244
-
245
-                    /* calculate satellite data */
246
-                    $this->predict_calc($sat, $qth, $t);
247
-
248
-                    /* in the first iter we want to store
225
+				if ($step < $tres) {
226
+					$step = $tres;
227
+				}
228
+
229
+				/* create a pass_t entry; FIXME: g_try_new in 2.8 */
230
+				$pass = new Predict_Pass();
231
+
232
+				$pass->aos      = $aos;
233
+				$pass->los      = $los;
234
+				$pass->max_el   = 0.0;
235
+				$pass->aos_az   = 0.0;
236
+				$pass->los_az   = 0.0;
237
+				$pass->maxel_az = 0.0;
238
+				$pass->vis      = '---';
239
+				$pass->satname  = $sat->nickname;
240
+				$pass->details  = array();
241
+
242
+				/* iterate over each time step */
243
+				for ($t = $pass->aos; $t <= $pass->los; $t += $step) {
244
+
245
+					/* calculate satellite data */
246
+					$this->predict_calc($sat, $qth, $t);
247
+
248
+					/* in the first iter we want to store
249 249
                         pass->aos_az
250 250
                     */
251
-                    if ($t == $pass->aos) {
252
-                        $pass->aos_az = $sat->az;
253
-                        $pass->orbit  = $sat->orbit;
254
-                    }
255
-
256
-                    /* append details to sat->details */
257
-                    $detail             = new Predict_PassDetail();
258
-                    $detail->time       = $t;
259
-                    $detail->pos->x     = $sat->pos->x;
260
-                    $detail->pos->y     = $sat->pos->y;
261
-                    $detail->pos->z     = $sat->pos->z;
262
-                    $detail->pos->w     = $sat->pos->w;
263
-                    $detail->vel->x     = $sat->vel->x;
264
-                    $detail->vel->y     = $sat->vel->y;
265
-                    $detail->vel->z     = $sat->vel->z;
266
-                    $detail->vel->w     = $sat->vel->w;
267
-                    $detail->velo       = $sat->velo;
268
-                    $detail->az         = $sat->az;
269
-                    $detail->el         = $sat->el;
270
-                    $detail->range      = $sat->range;
271
-                    $detail->range_rate = $sat->range_rate;
272
-                    $detail->lat        = $sat->ssplat;
273
-                    $detail->lon        = $sat->ssplon;
274
-                    $detail->alt        = $sat->alt;
275
-                    $detail->ma         = $sat->ma;
276
-                    $detail->phase      = $sat->phase;
277
-                    $detail->footprint  = $sat->footprint;
278
-                    $detail->orbit      = $sat->orbit;
279
-                    $detail->vis        = $this->get_sat_vis($sat, $qth, $t);
280
-
281
-                    /* also store visibility "bit" */
282
-                    switch ($detail->vis) {
283
-                        case self::SAT_VIS_VISIBLE:
284
-                            $pass->vis[0] = 'V';
285
-                            break;
286
-                        case self::SAT_VIS_DAYLIGHT:
287
-                            $pass->vis[1] = 'D';
288
-                            break;
289
-                        case self::SAT_VIS_ECLIPSED:
290
-                            $pass->vis[2] = 'E';
291
-                            break;
292
-                        default:
293
-                            break;
294
-                    }
295
-
296
-                    // Using an array, no need to prepend and reverse the list
297
-                    // as gpredict does
298
-                    $pass->details[] = $detail;
299
-
300
-                    // Look up apparent magnitude if this is a visible pass
301
-                    if ($detail->vis === self::SAT_VIS_VISIBLE) {
302
-                        $apmag = $sat->calculateApparentMagnitude($t, $qth);
303
-                        if ($pass->max_apparent_magnitude === null || $apmag < $pass->max_apparent_magnitude) {
304
-                            $pass->max_apparent_magnitude = $apmag;
305
-                        }
306
-                    }
307
-
308
-                    /* store elevation if greater than the
251
+					if ($t == $pass->aos) {
252
+						$pass->aos_az = $sat->az;
253
+						$pass->orbit  = $sat->orbit;
254
+					}
255
+
256
+					/* append details to sat->details */
257
+					$detail             = new Predict_PassDetail();
258
+					$detail->time       = $t;
259
+					$detail->pos->x     = $sat->pos->x;
260
+					$detail->pos->y     = $sat->pos->y;
261
+					$detail->pos->z     = $sat->pos->z;
262
+					$detail->pos->w     = $sat->pos->w;
263
+					$detail->vel->x     = $sat->vel->x;
264
+					$detail->vel->y     = $sat->vel->y;
265
+					$detail->vel->z     = $sat->vel->z;
266
+					$detail->vel->w     = $sat->vel->w;
267
+					$detail->velo       = $sat->velo;
268
+					$detail->az         = $sat->az;
269
+					$detail->el         = $sat->el;
270
+					$detail->range      = $sat->range;
271
+					$detail->range_rate = $sat->range_rate;
272
+					$detail->lat        = $sat->ssplat;
273
+					$detail->lon        = $sat->ssplon;
274
+					$detail->alt        = $sat->alt;
275
+					$detail->ma         = $sat->ma;
276
+					$detail->phase      = $sat->phase;
277
+					$detail->footprint  = $sat->footprint;
278
+					$detail->orbit      = $sat->orbit;
279
+					$detail->vis        = $this->get_sat_vis($sat, $qth, $t);
280
+
281
+					/* also store visibility "bit" */
282
+					switch ($detail->vis) {
283
+						case self::SAT_VIS_VISIBLE:
284
+							$pass->vis[0] = 'V';
285
+							break;
286
+						case self::SAT_VIS_DAYLIGHT:
287
+							$pass->vis[1] = 'D';
288
+							break;
289
+						case self::SAT_VIS_ECLIPSED:
290
+							$pass->vis[2] = 'E';
291
+							break;
292
+						default:
293
+							break;
294
+					}
295
+
296
+					// Using an array, no need to prepend and reverse the list
297
+					// as gpredict does
298
+					$pass->details[] = $detail;
299
+
300
+					// Look up apparent magnitude if this is a visible pass
301
+					if ($detail->vis === self::SAT_VIS_VISIBLE) {
302
+						$apmag = $sat->calculateApparentMagnitude($t, $qth);
303
+						if ($pass->max_apparent_magnitude === null || $apmag < $pass->max_apparent_magnitude) {
304
+							$pass->max_apparent_magnitude = $apmag;
305
+						}
306
+					}
307
+
308
+					/* store elevation if greater than the
309 309
                         previously stored one
310 310
                     */
311
-                    if ($sat->el > $max_el) {
312
-                        $max_el         = $sat->el;
313
-                        $tca            = $t;
314
-                        $pass->maxel_az = $sat->az;
315
-                    }
316
-
317
-                    /*     g_print ("TIME: %f\tAZ: %f\tEL: %f (MAX: %f)\n", */
318
-                    /*           t, sat->az, sat->el, max_el); */
319
-                }
320
-
321
-                /* calculate satellite data */
322
-                $this->predict_calc($sat, $qth, $pass->los);
323
-                /* store los_az, max_el and tca */
324
-                $pass->los_az = $sat->az;
325
-                $pass->max_el = $max_el;
326
-                $pass->tca    = $tca;
327
-
328
-                /* check whether this pass is good */
329
-                if ($max_el >= $this->minEle) {
330
-                    $done = true;
331
-                } else {
332
-                    $done = false;
333
-                    $t0 = $los + 0.014; // +20 min
334
-                    $pass = null;
335
-                }
336
-
337
-                $iter++;
338
-            }
339
-        }
340
-
341
-        return $pass;
342
-    }
343
-
344
-    /**
345
-     * Calculate satellite visibility.
346
-     *
347
-     * @param Predict_Sat $sat     The satellite structure.
348
-     * @param Predict_QTH $qth     The QTH
349
-     * @param float       $jul_utc The time at which the visibility should be calculated.
350
-     *
351
-     * @return int The visiblity constant, 0, 1, 2, or 3 (see above)
352
-     */
353
-    public function get_sat_vis(Predict_Sat $sat, Predict_QTH $qth, $jul_utc)
354
-    {
355
-        /* gboolean sat_sun_status;
311
+					if ($sat->el > $max_el) {
312
+						$max_el         = $sat->el;
313
+						$tca            = $t;
314
+						$pass->maxel_az = $sat->az;
315
+					}
316
+
317
+					/*     g_print ("TIME: %f\tAZ: %f\tEL: %f (MAX: %f)\n", */
318
+					/*           t, sat->az, sat->el, max_el); */
319
+				}
320
+
321
+				/* calculate satellite data */
322
+				$this->predict_calc($sat, $qth, $pass->los);
323
+				/* store los_az, max_el and tca */
324
+				$pass->los_az = $sat->az;
325
+				$pass->max_el = $max_el;
326
+				$pass->tca    = $tca;
327
+
328
+				/* check whether this pass is good */
329
+				if ($max_el >= $this->minEle) {
330
+					$done = true;
331
+				} else {
332
+					$done = false;
333
+					$t0 = $los + 0.014; // +20 min
334
+					$pass = null;
335
+				}
336
+
337
+				$iter++;
338
+			}
339
+		}
340
+
341
+		return $pass;
342
+	}
343
+
344
+	/**
345
+	 * Calculate satellite visibility.
346
+	 *
347
+	 * @param Predict_Sat $sat     The satellite structure.
348
+	 * @param Predict_QTH $qth     The QTH
349
+	 * @param float       $jul_utc The time at which the visibility should be calculated.
350
+	 *
351
+	 * @return int The visiblity constant, 0, 1, 2, or 3 (see above)
352
+	 */
353
+	public function get_sat_vis(Predict_Sat $sat, Predict_QTH $qth, $jul_utc)
354
+	{
355
+		/* gboolean sat_sun_status;
356 356
         gdouble  sun_el;
357 357
         gdouble  threshold;
358 358
         gdouble  eclipse_depth;
359 359
         sat_vis_t vis = SAT_VIS_NONE; */
360 360
 
361
-        $eclipse_depth  = 0.0;
362
-        $zero_vector    = new Predict_Vector();
363
-        $obs_geodetic   = new Predict_Geodetic();
364
-
365
-        /* Solar ECI position vector  */
366
-        $solar_vector = new Predict_Vector();
367
-
368
-        /* Solar observed az and el vector  */
369
-        $solar_set = new Predict_ObsSet();
370
-
371
-        /* FIXME: could be passed as parameter */
372
-        $obs_geodetic->lon   = $qth->lon * self::de2ra;
373
-        $obs_geodetic->lat   = $qth->lat * self::de2ra;
374
-        $obs_geodetic->alt   = $qth->alt / 1000.0;
375
-        $obs_geodetic->theta = 0;
376
-
377
-        Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector);
378
-        Predict_SGPObs::Calculate_Obs($jul_utc, $solar_vector, $zero_vector, $obs_geodetic, $solar_set);
379
-
380
-        if (Predict_Solar::Sat_Eclipsed($sat->pos, $solar_vector, $eclipse_depth)) {
381
-            /* satellite is eclipsed */
382
-            $sat_sun_status = false;
383
-        } else {
384
-            /* satellite in sunlight => may be visible */
385
-            $sat_sun_status = true;
386
-        }
387
-
388
-        if ($sat_sun_status) {
389
-            $sun_el = Predict_Math::Degrees($solar_set->el);
390
-
391
-            if ($sun_el <= $this->threshold && $sat->el >= 0.0) {
392
-                $vis = self::SAT_VIS_VISIBLE;
393
-            } else {
394
-                $vis = self::SAT_VIS_DAYLIGHT;
395
-            }
396
-        } else {
397
-            $vis = self::SAT_VIS_ECLIPSED;
398
-        }
399
-
400
-        return $vis;
401
-    }
402
-
403
-    /** Find the AOS time of the next pass.
404
-     *  @author Alexandru Csete, OZ9AEC
405
-     *  @author John A. Magliacane, KD2BD
406
-     *  @param Predict_Sat $sat   The satellite data.
407
-     *  @param Predict_QTH $qth   The observer's location (QTH) data.
408
-     *  @param float       $start The julian date where calculation should start.
409
-     *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
410
-     *  @return The julain date of the next AOS or 0.0 if the satellite has no AOS.
411
-     *
412
-     * This function finds the time of AOS for the first coming pass taking place
413
-     * no earlier that start.
414
-     * If the satellite is currently within range, the function first calls
415
-     * find_los to get the next LOS time. Then the calculations are done using
416
-     * the new start time.
417
-     *
418
-     */
419
-    public function find_aos(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt)
420
-    {
421
-        $t = $start;
422
-        $aostime = 0.0;
423
-
424
-
425
-        /* make sure current sat values are
361
+		$eclipse_depth  = 0.0;
362
+		$zero_vector    = new Predict_Vector();
363
+		$obs_geodetic   = new Predict_Geodetic();
364
+
365
+		/* Solar ECI position vector  */
366
+		$solar_vector = new Predict_Vector();
367
+
368
+		/* Solar observed az and el vector  */
369
+		$solar_set = new Predict_ObsSet();
370
+
371
+		/* FIXME: could be passed as parameter */
372
+		$obs_geodetic->lon   = $qth->lon * self::de2ra;
373
+		$obs_geodetic->lat   = $qth->lat * self::de2ra;
374
+		$obs_geodetic->alt   = $qth->alt / 1000.0;
375
+		$obs_geodetic->theta = 0;
376
+
377
+		Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector);
378
+		Predict_SGPObs::Calculate_Obs($jul_utc, $solar_vector, $zero_vector, $obs_geodetic, $solar_set);
379
+
380
+		if (Predict_Solar::Sat_Eclipsed($sat->pos, $solar_vector, $eclipse_depth)) {
381
+			/* satellite is eclipsed */
382
+			$sat_sun_status = false;
383
+		} else {
384
+			/* satellite in sunlight => may be visible */
385
+			$sat_sun_status = true;
386
+		}
387
+
388
+		if ($sat_sun_status) {
389
+			$sun_el = Predict_Math::Degrees($solar_set->el);
390
+
391
+			if ($sun_el <= $this->threshold && $sat->el >= 0.0) {
392
+				$vis = self::SAT_VIS_VISIBLE;
393
+			} else {
394
+				$vis = self::SAT_VIS_DAYLIGHT;
395
+			}
396
+		} else {
397
+			$vis = self::SAT_VIS_ECLIPSED;
398
+		}
399
+
400
+		return $vis;
401
+	}
402
+
403
+	/** Find the AOS time of the next pass.
404
+	 *  @author Alexandru Csete, OZ9AEC
405
+	 *  @author John A. Magliacane, KD2BD
406
+	 *  @param Predict_Sat $sat   The satellite data.
407
+	 *  @param Predict_QTH $qth   The observer's location (QTH) data.
408
+	 *  @param float       $start The julian date where calculation should start.
409
+	 *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
410
+	 *  @return The julain date of the next AOS or 0.0 if the satellite has no AOS.
411
+	 *
412
+	 * This function finds the time of AOS for the first coming pass taking place
413
+	 * no earlier that start.
414
+	 * If the satellite is currently within range, the function first calls
415
+	 * find_los to get the next LOS time. Then the calculations are done using
416
+	 * the new start time.
417
+	 *
418
+	 */
419
+	public function find_aos(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt)
420
+	{
421
+		$t = $start;
422
+		$aostime = 0.0;
423
+
424
+
425
+		/* make sure current sat values are
426 426
             in sync with the time
427 427
         */
428
-        $this->predict_calc($sat, $qth, $start);
429
-
430
-        /* check whether satellite has aos */
431
-        if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
432
-            ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
433
-            !$this->has_aos($sat, $qth)) {
434
-
435
-            return 0.0;
436
-        }
437
-
438
-        if ($sat->el > 0.0) {
439
-            $t = $this->find_los($sat, $qth, $start, $maxdt) + 0.014; // +20 min
440
-        }
441
-
442
-        /* invalid time (potentially returned by find_los) */
443
-        if ($t < 0.1) {
444
-            return 0.0;
445
-        }
446
-
447
-        /* update satellite data */
448
-        $this->predict_calc($sat, $qth, $t);
449
-
450
-        /* use upper time limit */
451
-        if ($maxdt > 0.0) {
452
-
453
-            /* coarse time steps */
454
-            while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) {
455
-                $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
456
-                $this->predict_calc($sat, $qth, $t);
457
-            }
458
-
459
-            /* fine steps */
460
-            while (($aostime == 0.0) && ($t <= ($start + $maxdt))) {
461
-
462
-                if (abs($sat->el) < 0.005) {
463
-                    $aostime = $t;
464
-                } else {
465
-                    $t -= $sat->el * sqrt($sat->alt) / 530000.0;
466
-                    $this->predict_calc($sat, $qth, $t);
467
-                }
468
-            }
469
-        } else {
470
-            /* don't use upper time limit */
471
-
472
-            /* coarse time steps */
473
-            while ($sat->el < -1.0) {
474
-
475
-                $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
476
-                $this->predict_calc($sat, $qth, $t);
477
-            }
478
-
479
-            /* fine steps */
480
-            while ($aostime == 0.0) {
481
-
482
-                if (abs($sat->el) < 0.005) {
483
-                    $aostime = $t;
484
-                } else {
485
-                    $t -= $sat->el * sqrt($sat->alt) / 530000.0;
486
-                    $this->predict_calc($sat, $qth, $t);
487
-                }
488
-
489
-            }
490
-        }
491
-
492
-        return $aostime;
493
-    }
494
-
495
-    /** SGP4SDP4 driver for doing AOS/LOS calculations.
496
-     *  @param Predict_Sat $sat The satellite data.
497
-     *  @param Predict_QTH $qth The QTH observer location data.
498
-     *  @param float       $t   The time for calculation (Julian Date)
499
-     *
500
-     */
501
-    public function predict_calc(Predict_Sat $sat, Predict_QTH $qth, $t)
502
-    {
503
-        $obs_set      = new Predict_ObsSet();
504
-        $sat_geodetic = new Predict_Geodetic();
505
-        $obs_geodetic = new Predict_Geodetic();
506
-
507
-        $obs_geodetic->lon   = $qth->lon * self::de2ra;
508
-        $obs_geodetic->lat   = $qth->lat * self::de2ra;
509
-        $obs_geodetic->alt   = $qth->alt / 1000.0;
510
-        $obs_geodetic->theta = 0;
511
-
512
-        $sat->jul_utc = $t;
513
-        $sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda;
514
-
515
-        /* call the norad routines according to the deep-space flag */
516
-        $sgpsdp = Predict_SGPSDP::getInstance($sat);
517
-        if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
518
-            $sgpsdp->SDP4($sat, $sat->tsince);
519
-        } else {
520
-            $sgpsdp->SGP4($sat, $sat->tsince);
521
-        }
522
-
523
-        Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
524
-
525
-        /* get the velocity of the satellite */
526
-        $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
527
-        $sat->velo = $sat->vel->w;
528
-        Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
529
-        Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic);
530
-
531
-        while ($sat_geodetic->lon < -self::pi) {
532
-            $sat_geodetic->lon += self::twopi;
533
-        }
534
-
535
-        while ($sat_geodetic->lon > (self::pi)) {
536
-            $sat_geodetic->lon -= self::twopi;
537
-        }
538
-
539
-        $sat->az = Predict_Math::Degrees($obs_set->az);
540
-        $sat->el = Predict_Math::Degrees($obs_set->el);
541
-        $sat->range = $obs_set->range;
542
-        $sat->range_rate = $obs_set->range_rate;
543
-        $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat);
544
-        $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
545
-        $sat->alt = $sat_geodetic->alt;
546
-        $sat->ma = Predict_Math::Degrees($sat->phase);
547
-        $sat->ma *= 256.0 / 360.0;
548
-        $sat->phase = Predict_Math::Degrees($sat->phase);
549
-
550
-        /* same formulas, but the one from predict is nicer */
551
-        //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w);
552
-        $sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt));
553
-        $age = $sat->jul_utc - $sat->jul_epoch;
554
-        $sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi +
555
-                        $age * $sat->tle->bstar * self::ae) * $age +
556
-                        $sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1;
557
-    }
558
-
559
-    /** Find the LOS time of the next pass.
560
-     *  @author Alexandru Csete, OZ9AEC
561
-     *  @author John A. Magliacane, KD2BD
562
-     *  @param Predict_Sat $sat The satellite data.
563
-     *  @param Predict_QTH $qth The QTH observer location data.
564
-     *  @param float       $start The time where calculation should start. (Julian Date)
565
-     *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
566
-     *  @return The time (julian date) of the next LOS or 0.0 if the satellite has no LOS.
567
-     *
568
-     * This function finds the time of LOS for the first coming pass taking place
569
-     * no earlier that start.
570
-     * If the satellite is currently out of range, the function first calls
571
-     * find_aos to get the next AOS time. Then the calculations are done using
572
-     * the new start time.
573
-     * The function has a built-in watchdog to ensure that we don't end up in
574
-     * lengthy loops.
575
-     *
576
-     */
577
-    public function find_los(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt)
578
-    {
579
-        $t = $start;
580
-        $lostime = 0.0;
581
-
582
-
583
-        $this->predict_calc($sat, $qth, $start);
584
-
585
-        /* check whether satellite has aos */
586
-        if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
587
-            ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
588
-            !$this->has_aos ($sat, $qth)) {
589
-
590
-            return 0.0;
591
-        }
592
-
593
-        if ($sat->el < 0.0) {
594
-            $t = $this->find_aos($sat, $qth, $start, $maxdt) + 0.001; // +1.5 min
595
-        }
596
-
597
-        /* invalid time (potentially returned by find_aos) */
598
-        if ($t < 0.01) {
599
-            return 0.0;
600
-        }
601
-
602
-        /* update satellite data */
603
-        $this->predict_calc($sat, $qth, $t);
604
-
605
-        /* use upper time limit */
606
-        if ($maxdt > 0.0) {
607
-
608
-            /* coarse steps */
609
-            while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) {
610
-                $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
611
-                $this->predict_calc($sat, $qth, $t);
612
-            }
613
-
614
-            /* fine steps */
615
-            while (($lostime == 0.0) && ($t <= ($start + $maxdt)))  {
616
-
617
-                $t += $sat->el * sqrt($sat->alt) / 502500.0;
618
-                $this->predict_calc($sat, $qth, $t);
619
-
620
-                if (abs($sat->el) < 0.005) {
621
-                    $lostime = $t;
622
-                }
623
-            }
624
-        } else {
625
-        /* don't use upper limit */
626
-
627
-            /* coarse steps */
628
-            while ($sat->el >= 1.0) {
629
-                $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
630
-                $this->predict_calc($sat, $qth, $t);
631
-            }
632
-
633
-            /* fine steps */
634
-            while ($lostime == 0.0) {
635
-
636
-                $t += $sat->el * sqrt($sat->alt) / 502500.0;
637
-                $this->predict_calc($sat, $qth, $t);
638
-
639
-                if (abs($sat->el) < 0.005)
640
-                    $lostime = $t;
641
-            }
642
-        }
643
-
644
-        return $lostime;
645
-    }
646
-
647
-    /** Find AOS time of current pass.
648
-     *  @param Predict_Sat $sat   The satellite to find AOS for.
649
-     *  @param Predict_QTH $qth   The ground station.
650
-     *  @param float       $start Start time, prefereably now.
651
-     *  @return The time of the previous AOS or 0.0 if the satellite has no AOS.
652
-     *
653
-     * This function can be used to find the AOS time in the past of the
654
-     * current pass.
655
-     */
656
-    public function find_prev_aos(Predict_Sat $sat, Predict_QTH $qth, $start)
657
-    {
658
-        $aostime = $start;
659
-
660
-        /* make sure current sat values are
428
+		$this->predict_calc($sat, $qth, $start);
429
+
430
+		/* check whether satellite has aos */
431
+		if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
432
+			($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
433
+			!$this->has_aos($sat, $qth)) {
434
+
435
+			return 0.0;
436
+		}
437
+
438
+		if ($sat->el > 0.0) {
439
+			$t = $this->find_los($sat, $qth, $start, $maxdt) + 0.014; // +20 min
440
+		}
441
+
442
+		/* invalid time (potentially returned by find_los) */
443
+		if ($t < 0.1) {
444
+			return 0.0;
445
+		}
446
+
447
+		/* update satellite data */
448
+		$this->predict_calc($sat, $qth, $t);
449
+
450
+		/* use upper time limit */
451
+		if ($maxdt > 0.0) {
452
+
453
+			/* coarse time steps */
454
+			while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) {
455
+				$t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
456
+				$this->predict_calc($sat, $qth, $t);
457
+			}
458
+
459
+			/* fine steps */
460
+			while (($aostime == 0.0) && ($t <= ($start + $maxdt))) {
461
+
462
+				if (abs($sat->el) < 0.005) {
463
+					$aostime = $t;
464
+				} else {
465
+					$t -= $sat->el * sqrt($sat->alt) / 530000.0;
466
+					$this->predict_calc($sat, $qth, $t);
467
+				}
468
+			}
469
+		} else {
470
+			/* don't use upper time limit */
471
+
472
+			/* coarse time steps */
473
+			while ($sat->el < -1.0) {
474
+
475
+				$t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
476
+				$this->predict_calc($sat, $qth, $t);
477
+			}
478
+
479
+			/* fine steps */
480
+			while ($aostime == 0.0) {
481
+
482
+				if (abs($sat->el) < 0.005) {
483
+					$aostime = $t;
484
+				} else {
485
+					$t -= $sat->el * sqrt($sat->alt) / 530000.0;
486
+					$this->predict_calc($sat, $qth, $t);
487
+				}
488
+
489
+			}
490
+		}
491
+
492
+		return $aostime;
493
+	}
494
+
495
+	/** SGP4SDP4 driver for doing AOS/LOS calculations.
496
+	 *  @param Predict_Sat $sat The satellite data.
497
+	 *  @param Predict_QTH $qth The QTH observer location data.
498
+	 *  @param float       $t   The time for calculation (Julian Date)
499
+	 *
500
+	 */
501
+	public function predict_calc(Predict_Sat $sat, Predict_QTH $qth, $t)
502
+	{
503
+		$obs_set      = new Predict_ObsSet();
504
+		$sat_geodetic = new Predict_Geodetic();
505
+		$obs_geodetic = new Predict_Geodetic();
506
+
507
+		$obs_geodetic->lon   = $qth->lon * self::de2ra;
508
+		$obs_geodetic->lat   = $qth->lat * self::de2ra;
509
+		$obs_geodetic->alt   = $qth->alt / 1000.0;
510
+		$obs_geodetic->theta = 0;
511
+
512
+		$sat->jul_utc = $t;
513
+		$sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda;
514
+
515
+		/* call the norad routines according to the deep-space flag */
516
+		$sgpsdp = Predict_SGPSDP::getInstance($sat);
517
+		if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
518
+			$sgpsdp->SDP4($sat, $sat->tsince);
519
+		} else {
520
+			$sgpsdp->SGP4($sat, $sat->tsince);
521
+		}
522
+
523
+		Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
524
+
525
+		/* get the velocity of the satellite */
526
+		$sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
527
+		$sat->velo = $sat->vel->w;
528
+		Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
529
+		Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic);
530
+
531
+		while ($sat_geodetic->lon < -self::pi) {
532
+			$sat_geodetic->lon += self::twopi;
533
+		}
534
+
535
+		while ($sat_geodetic->lon > (self::pi)) {
536
+			$sat_geodetic->lon -= self::twopi;
537
+		}
538
+
539
+		$sat->az = Predict_Math::Degrees($obs_set->az);
540
+		$sat->el = Predict_Math::Degrees($obs_set->el);
541
+		$sat->range = $obs_set->range;
542
+		$sat->range_rate = $obs_set->range_rate;
543
+		$sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat);
544
+		$sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
545
+		$sat->alt = $sat_geodetic->alt;
546
+		$sat->ma = Predict_Math::Degrees($sat->phase);
547
+		$sat->ma *= 256.0 / 360.0;
548
+		$sat->phase = Predict_Math::Degrees($sat->phase);
549
+
550
+		/* same formulas, but the one from predict is nicer */
551
+		//sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w);
552
+		$sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt));
553
+		$age = $sat->jul_utc - $sat->jul_epoch;
554
+		$sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi +
555
+						$age * $sat->tle->bstar * self::ae) * $age +
556
+						$sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1;
557
+	}
558
+
559
+	/** Find the LOS time of the next pass.
560
+	 *  @author Alexandru Csete, OZ9AEC
561
+	 *  @author John A. Magliacane, KD2BD
562
+	 *  @param Predict_Sat $sat The satellite data.
563
+	 *  @param Predict_QTH $qth The QTH observer location data.
564
+	 *  @param float       $start The time where calculation should start. (Julian Date)
565
+	 *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
566
+	 *  @return The time (julian date) of the next LOS or 0.0 if the satellite has no LOS.
567
+	 *
568
+	 * This function finds the time of LOS for the first coming pass taking place
569
+	 * no earlier that start.
570
+	 * If the satellite is currently out of range, the function first calls
571
+	 * find_aos to get the next AOS time. Then the calculations are done using
572
+	 * the new start time.
573
+	 * The function has a built-in watchdog to ensure that we don't end up in
574
+	 * lengthy loops.
575
+	 *
576
+	 */
577
+	public function find_los(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt)
578
+	{
579
+		$t = $start;
580
+		$lostime = 0.0;
581
+
582
+
583
+		$this->predict_calc($sat, $qth, $start);
584
+
585
+		/* check whether satellite has aos */
586
+		if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
587
+			($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
588
+			!$this->has_aos ($sat, $qth)) {
589
+
590
+			return 0.0;
591
+		}
592
+
593
+		if ($sat->el < 0.0) {
594
+			$t = $this->find_aos($sat, $qth, $start, $maxdt) + 0.001; // +1.5 min
595
+		}
596
+
597
+		/* invalid time (potentially returned by find_aos) */
598
+		if ($t < 0.01) {
599
+			return 0.0;
600
+		}
601
+
602
+		/* update satellite data */
603
+		$this->predict_calc($sat, $qth, $t);
604
+
605
+		/* use upper time limit */
606
+		if ($maxdt > 0.0) {
607
+
608
+			/* coarse steps */
609
+			while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) {
610
+				$t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
611
+				$this->predict_calc($sat, $qth, $t);
612
+			}
613
+
614
+			/* fine steps */
615
+			while (($lostime == 0.0) && ($t <= ($start + $maxdt)))  {
616
+
617
+				$t += $sat->el * sqrt($sat->alt) / 502500.0;
618
+				$this->predict_calc($sat, $qth, $t);
619
+
620
+				if (abs($sat->el) < 0.005) {
621
+					$lostime = $t;
622
+				}
623
+			}
624
+		} else {
625
+		/* don't use upper limit */
626
+
627
+			/* coarse steps */
628
+			while ($sat->el >= 1.0) {
629
+				$t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
630
+				$this->predict_calc($sat, $qth, $t);
631
+			}
632
+
633
+			/* fine steps */
634
+			while ($lostime == 0.0) {
635
+
636
+				$t += $sat->el * sqrt($sat->alt) / 502500.0;
637
+				$this->predict_calc($sat, $qth, $t);
638
+
639
+				if (abs($sat->el) < 0.005)
640
+					$lostime = $t;
641
+			}
642
+		}
643
+
644
+		return $lostime;
645
+	}
646
+
647
+	/** Find AOS time of current pass.
648
+	 *  @param Predict_Sat $sat   The satellite to find AOS for.
649
+	 *  @param Predict_QTH $qth   The ground station.
650
+	 *  @param float       $start Start time, prefereably now.
651
+	 *  @return The time of the previous AOS or 0.0 if the satellite has no AOS.
652
+	 *
653
+	 * This function can be used to find the AOS time in the past of the
654
+	 * current pass.
655
+	 */
656
+	public function find_prev_aos(Predict_Sat $sat, Predict_QTH $qth, $start)
657
+	{
658
+		$aostime = $start;
659
+
660
+		/* make sure current sat values are
661 661
             in sync with the time
662 662
         */
663
-        $this->predict_calc($sat, $qth, $start);
664
-
665
-        /* check whether satellite has aos */
666
-        if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
667
-            ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
668
-            !$this->has_aos($sat, $qth)) {
669
-
670
-            return 0.0;
671
-        }
672
-
673
-        while ($sat->el >= 0.0) {
674
-            $aostime -= 0.0005; // 0.75 min
675
-            $this->predict_calc($sat, $qth, $aostime);
676
-        }
677
-
678
-        return $aostime;
679
-    }
680
-
681
-    /** Determine whether satellite ever reaches AOS.
682
-     *  @author John A. Magliacane, KD2BD
683
-     *  @author Alexandru Csete, OZ9AEC
684
-     *  @param Predict_Sat $sat The satellite data.
685
-     *  @param Predict_QTH $qth The observer's location data
686
-     *  @return bool true if the satellite will reach AOS, false otherwise.
687
-     *
688
-     */
689
-    public function has_aos(Predict_Sat $sat, Predict_QTH $qth)
690
-    {
691
-         $retcode = false;
692
-
693
-         /* FIXME */
694
-         if ($sat->meanmo == 0.0) {
695
-              $retcode = false;
696
-         } else {
697
-
698
-            /* xincl is already in RAD by select_ephemeris */
699
-            $lin = $sat->tle->xincl;
700
-            if ($lin >= self::pio2) {
701
-                $lin = self::pi - $lin;
702
-            }
703
-
704
-            $sma = 331.25 * exp(log(1440.0 / $sat->meanmo) * (2.0 / 3.0));
705
-            $apogee = $sma * (1.0 + $sat->tle->eo) - self::xkmper;
706
-
707
-            if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) {
708
-                $retcode = true;
709
-            } else {
710
-                $retcode = false;
711
-            }
712
-        }
713
-
714
-        return $retcode;
715
-    }
716
-
717
-    /** Predict passes after a certain time.
718
-     *
719
-     *
720
-     * This function calculates num upcoming passes with AOS no earlier
721
-     * than t = start and not later that t = (start+maxdt). The function will
722
-     *  repeatedly call get_pass until
723
-     * the number of predicted passes is equal to num, the time has reached
724
-     * limit or the get_pass function returns NULL.
725
-     *
726
-     * note For no time limit use maxdt = 0.0
727
-     *
728
-     * note the data in sat will be corrupt (future) and must be refreshed
729
-     *      by the caller, if the caller will need it later on (eg. if the caller
730
-     *      is GtkSatList).
731
-     *
732
-     * note Prepending to a singly linked list is much faster than appending.
733
-     *      Therefore, the elements are prepended whereafter the GSList is
734
-     *      reversed
735
-     *
736
-     *
737
-     * @param Predict_Sat  $sat The satellite data
738
-     * @param Predict_QTH  $qth The observer's location data
739
-     * @param float $start The start julian date
740
-     * @param int   $maxdt The max # of days to look
741
-     * @param int   $num   The max # of passes to get
742
-     * @return array of Predict_Pass instances if found, empty array otherwise
743
-     */
744
-    public function get_passes(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt, $num = 0)
745
-    {
746
-        $passes = array();
747
-
748
-        /* if no number has been specified
663
+		$this->predict_calc($sat, $qth, $start);
664
+
665
+		/* check whether satellite has aos */
666
+		if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
667
+			($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
668
+			!$this->has_aos($sat, $qth)) {
669
+
670
+			return 0.0;
671
+		}
672
+
673
+		while ($sat->el >= 0.0) {
674
+			$aostime -= 0.0005; // 0.75 min
675
+			$this->predict_calc($sat, $qth, $aostime);
676
+		}
677
+
678
+		return $aostime;
679
+	}
680
+
681
+	/** Determine whether satellite ever reaches AOS.
682
+	 *  @author John A. Magliacane, KD2BD
683
+	 *  @author Alexandru Csete, OZ9AEC
684
+	 *  @param Predict_Sat $sat The satellite data.
685
+	 *  @param Predict_QTH $qth The observer's location data
686
+	 *  @return bool true if the satellite will reach AOS, false otherwise.
687
+	 *
688
+	 */
689
+	public function has_aos(Predict_Sat $sat, Predict_QTH $qth)
690
+	{
691
+		 $retcode = false;
692
+
693
+		 /* FIXME */
694
+		 if ($sat->meanmo == 0.0) {
695
+			  $retcode = false;
696
+		 } else {
697
+
698
+			/* xincl is already in RAD by select_ephemeris */
699
+			$lin = $sat->tle->xincl;
700
+			if ($lin >= self::pio2) {
701
+				$lin = self::pi - $lin;
702
+			}
703
+
704
+			$sma = 331.25 * exp(log(1440.0 / $sat->meanmo) * (2.0 / 3.0));
705
+			$apogee = $sma * (1.0 + $sat->tle->eo) - self::xkmper;
706
+
707
+			if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) {
708
+				$retcode = true;
709
+			} else {
710
+				$retcode = false;
711
+			}
712
+		}
713
+
714
+		return $retcode;
715
+	}
716
+
717
+	/** Predict passes after a certain time.
718
+	 *
719
+	 *
720
+	 * This function calculates num upcoming passes with AOS no earlier
721
+	 * than t = start and not later that t = (start+maxdt). The function will
722
+	 *  repeatedly call get_pass until
723
+	 * the number of predicted passes is equal to num, the time has reached
724
+	 * limit or the get_pass function returns NULL.
725
+	 *
726
+	 * note For no time limit use maxdt = 0.0
727
+	 *
728
+	 * note the data in sat will be corrupt (future) and must be refreshed
729
+	 *      by the caller, if the caller will need it later on (eg. if the caller
730
+	 *      is GtkSatList).
731
+	 *
732
+	 * note Prepending to a singly linked list is much faster than appending.
733
+	 *      Therefore, the elements are prepended whereafter the GSList is
734
+	 *      reversed
735
+	 *
736
+	 *
737
+	 * @param Predict_Sat  $sat The satellite data
738
+	 * @param Predict_QTH  $qth The observer's location data
739
+	 * @param float $start The start julian date
740
+	 * @param int   $maxdt The max # of days to look
741
+	 * @param int   $num   The max # of passes to get
742
+	 * @return array of Predict_Pass instances if found, empty array otherwise
743
+	 */
744
+	public function get_passes(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt, $num = 0)
745
+	{
746
+		$passes = array();
747
+
748
+		/* if no number has been specified
749 749
             set it to something big */
750
-        if ($num == 0) {
751
-            $num = 100;
752
-        }
750
+		if ($num == 0) {
751
+			$num = 100;
752
+		}
753 753
 
754
-        $t = $start;
754
+		$t = $start;
755 755
 
756
-        for ($i = 0; $i < $num; $i++) {
757
-            $pass = $this->get_pass($sat, $qth, $t, $maxdt);
756
+		for ($i = 0; $i < $num; $i++) {
757
+			$pass = $this->get_pass($sat, $qth, $t, $maxdt);
758 758
 
759
-            if ($pass != null) {
760
-                $passes[] = $pass;
761
-                $t = $pass->los + 0.014; // +20 min
759
+			if ($pass != null) {
760
+				$passes[] = $pass;
761
+				$t = $pass->los + 0.014; // +20 min
762 762
 
763
-                /* if maxdt > 0.0 check whether we have reached t = start+maxdt
763
+				/* if maxdt > 0.0 check whether we have reached t = start+maxdt
764 764
                     if yes finish predictions
765 765
                 */
766
-                if (($maxdt > 0.0) && ($t >= ($start + $maxdt))) {
767
-                    $i = $num;
768
-                }
769
-            } else {
770
-                /* we can't get any more passes */
771
-                $i = $num;
772
-            }
773
-        }
774
-
775
-        return $passes;
776
-    }
777
-
778
-    /**
779
-     * Filters out visible passes and adds the visible aos, tca, los, and
780
-     * corresponding az and ele for each.
781
-     *
782
-     * @param array $passes The passes returned from get_passes()
783
-     *
784
-     * @author Bill Shupp
785
-     * @return array
786
-     */
787
-    public function filterVisiblePasses(array $passes)
788
-    {
789
-        $filtered = array();
790
-
791
-        foreach ($passes as $result) {
792
-            // Dummy check
793
-            if ($result->vis[0] != 'V') {
794
-                continue;
795
-            }
796
-
797
-            $aos    = false;
798
-            $aos_az = false;
799
-            $aos    = false;
800
-            $tca    = false;
801
-            $los_az = false;
802
-            $max_el = 0;
803
-
804
-            foreach ($result->details as $detail) {
805
-                if ($detail->vis != Predict::SAT_VIS_VISIBLE) {
806
-                    continue;
807
-                }
808
-                if ($detail->el < $this->minEle) {
809
-                    continue;
810
-                }
811
-
812
-                if ($aos == false) {
813
-                    $aos       = $detail->time;
814
-                    $aos_az    = $detail->az;
815
-                    $aos_el    = $detail->el;
816
-                    $tca       = $detail->time;
817
-                    $los       = $detail->time;
818
-                    $los_az    = $detail->az;
819
-                    $los_el    = $detail->el;
820
-                    $max_el    = $detail->el;
821
-                    $max_el_az = $detail->el;
822
-                    continue;
823
-                }
824
-                $los    = $detail->time;
825
-                $los_az = $detail->az;
826
-                $los_el = $detail->el;
827
-
828
-                if ($detail->el > $max_el) {
829
-                    $tca       = $detail->time;
830
-                    $max_el    = $detail->el;
831
-                    $max_el_az = $detail->az;
832
-                }
833
-            }
834
-
835
-            if ($aos === false) {
836
-                // Does not reach minimum elevation, skip
837
-                continue;
838
-            }
839
-
840
-            $result->visible_aos       = $aos;
841
-            $result->visible_aos_az    = $aos_az;
842
-            $result->visible_aos_el    = $aos_el;
843
-            $result->visible_tca       = $tca;
844
-            $result->visible_max_el    = $max_el;
845
-            $result->visible_max_el_az = $max_el_az;
846
-            $result->visible_los       = $los;
847
-            $result->visible_los_az    = $los_az;
848
-            $result->visible_los_el    = $los_el;
849
-
850
-            $filtered[] = $result;
851
-        }
852
-
853
-        return $filtered;
854
-    }
855
-
856
-    /**
857
-     * Translates aziumuth degrees to compass direction:
858
-     *
859
-     * N (0°), NNE (22.5°), NE (45°), ENE (67.5°), E (90°), ESE (112.5°),
860
-     * SE (135°), SSE (157.5°), S (180°), SSW (202.5°), SW (225°),
861
-     * WSW (247.5°), W (270°), WNW (292.5°), NW (315°), NNW (337.5°)
862
-     *
863
-     * @param int $az The azimuth in degrees, defaults to 0
864
-     *
865
-     * @return string
866
-     */
867
-    public function azDegreesToDirection($az = 0)
868
-    {
869
-        $i = floor($az / 22.5);
870
-        $m = (22.5 * (2 * $i + 1)) / 2;
871
-        $i = ($az >= $m) ? $i + 1 : $i;
872
-
873
-        return trim(substr('N  NNENE ENEE  ESESE SSES  SSWSW WSWW  WNWNW NNWN  ', $i * 3, 3));
874
-    }
766
+				if (($maxdt > 0.0) && ($t >= ($start + $maxdt))) {
767
+					$i = $num;
768
+				}
769
+			} else {
770
+				/* we can't get any more passes */
771
+				$i = $num;
772
+			}
773
+		}
774
+
775
+		return $passes;
776
+	}
777
+
778
+	/**
779
+	 * Filters out visible passes and adds the visible aos, tca, los, and
780
+	 * corresponding az and ele for each.
781
+	 *
782
+	 * @param array $passes The passes returned from get_passes()
783
+	 *
784
+	 * @author Bill Shupp
785
+	 * @return array
786
+	 */
787
+	public function filterVisiblePasses(array $passes)
788
+	{
789
+		$filtered = array();
790
+
791
+		foreach ($passes as $result) {
792
+			// Dummy check
793
+			if ($result->vis[0] != 'V') {
794
+				continue;
795
+			}
796
+
797
+			$aos    = false;
798
+			$aos_az = false;
799
+			$aos    = false;
800
+			$tca    = false;
801
+			$los_az = false;
802
+			$max_el = 0;
803
+
804
+			foreach ($result->details as $detail) {
805
+				if ($detail->vis != Predict::SAT_VIS_VISIBLE) {
806
+					continue;
807
+				}
808
+				if ($detail->el < $this->minEle) {
809
+					continue;
810
+				}
811
+
812
+				if ($aos == false) {
813
+					$aos       = $detail->time;
814
+					$aos_az    = $detail->az;
815
+					$aos_el    = $detail->el;
816
+					$tca       = $detail->time;
817
+					$los       = $detail->time;
818
+					$los_az    = $detail->az;
819
+					$los_el    = $detail->el;
820
+					$max_el    = $detail->el;
821
+					$max_el_az = $detail->el;
822
+					continue;
823
+				}
824
+				$los    = $detail->time;
825
+				$los_az = $detail->az;
826
+				$los_el = $detail->el;
827
+
828
+				if ($detail->el > $max_el) {
829
+					$tca       = $detail->time;
830
+					$max_el    = $detail->el;
831
+					$max_el_az = $detail->az;
832
+				}
833
+			}
834
+
835
+			if ($aos === false) {
836
+				// Does not reach minimum elevation, skip
837
+				continue;
838
+			}
839
+
840
+			$result->visible_aos       = $aos;
841
+			$result->visible_aos_az    = $aos_az;
842
+			$result->visible_aos_el    = $aos_el;
843
+			$result->visible_tca       = $tca;
844
+			$result->visible_max_el    = $max_el;
845
+			$result->visible_max_el_az = $max_el_az;
846
+			$result->visible_los       = $los;
847
+			$result->visible_los_az    = $los_az;
848
+			$result->visible_los_el    = $los_el;
849
+
850
+			$filtered[] = $result;
851
+		}
852
+
853
+		return $filtered;
854
+	}
855
+
856
+	/**
857
+	 * Translates aziumuth degrees to compass direction:
858
+	 *
859
+	 * N (0°), NNE (22.5°), NE (45°), ENE (67.5°), E (90°), ESE (112.5°),
860
+	 * SE (135°), SSE (157.5°), S (180°), SSW (202.5°), SW (225°),
861
+	 * WSW (247.5°), W (270°), WNW (292.5°), NW (315°), NNW (337.5°)
862
+	 *
863
+	 * @param int $az The azimuth in degrees, defaults to 0
864
+	 *
865
+	 * @return string
866
+	 */
867
+	public function azDegreesToDirection($az = 0)
868
+	{
869
+		$i = floor($az / 22.5);
870
+		$m = (22.5 * (2 * $i + 1)) / 2;
871
+		$i = ($az >= $m) ? $i + 1 : $i;
872
+
873
+		return trim(substr('N  NNENE ENEE  ESESE SSES  SSWSW WSWW  WNWNW NNWN  ', $i * 3, 3));
874
+	}
875 875
 }
Please login to merge, or discard this patch.
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -52,60 +52,60 @@  discard block
 block discarded – undo
52 52
  */
53 53
 class Predict
54 54
 {
55
-    const de2ra    =  1.74532925E-2;   /* Degrees to Radians */
56
-    const pi       =  3.1415926535898; /* Pi */
57
-    const pio2     =  1.5707963267949; /* Pi/2 */
58
-    const x3pio2   =  4.71238898;      /* 3*Pi/2 */
59
-    const twopi    =  6.2831853071796; /* 2*Pi  */
60
-    const e6a      =  1.0E-6;
61
-    const tothrd   =  6.6666667E-1;    /* 2/3 */
62
-    const xj2      =  1.0826158E-3;    /* J2 Harmonic */
63
-    const xj3      = -2.53881E-6;      /* J3 Harmonic */
64
-    const xj4      = -1.65597E-6;      /* J4 Harmonic */
65
-    const xke      =  7.43669161E-2;
66
-    const xkmper   =  6.378135E3;      /* Earth radius km */
67
-    const xmnpda   =  1.44E3;          /* Minutes per day */
68
-    const km2mi    =  0.621371;        /* Kilometers per Mile */
69
-    const ae       =  1.0;
70
-    const ck2      =  5.413079E-4;
71
-    const ck4      =  6.209887E-7;
72
-    const __f      =  3.352779E-3;
73
-    const ge       =  3.986008E5;
74
-    const __s__    =  1.012229;
75
-    const qoms2t   =  1.880279E-09;
76
-    const secday   =  8.6400E4;        /* Seconds per day */
77
-    const omega_E  =  1.0027379;
78
-    const omega_ER =  6.3003879;
79
-    const zns      =  1.19459E-5;
80
-    const c1ss     =  2.9864797E-6;
81
-    const zes      =  1.675E-2;
82
-    const znl      =  1.5835218E-4;
83
-    const c1l      =  4.7968065E-7;
84
-    const zel      =  5.490E-2;
85
-    const zcosis   =  9.1744867E-1;
86
-    const zsinis   =  3.9785416E-1;
55
+    const de2ra    = 1.74532925E-2; /* Degrees to Radians */
56
+    const pi       = 3.1415926535898; /* Pi */
57
+    const pio2     = 1.5707963267949; /* Pi/2 */
58
+    const x3pio2   = 4.71238898; /* 3*Pi/2 */
59
+    const twopi    = 6.2831853071796; /* 2*Pi  */
60
+    const e6a      = 1.0E-6;
61
+    const tothrd   = 6.6666667E-1; /* 2/3 */
62
+    const xj2      = 1.0826158E-3; /* J2 Harmonic */
63
+    const xj3      = -2.53881E-6; /* J3 Harmonic */
64
+    const xj4      = -1.65597E-6; /* J4 Harmonic */
65
+    const xke      = 7.43669161E-2;
66
+    const xkmper   = 6.378135E3; /* Earth radius km */
67
+    const xmnpda   = 1.44E3; /* Minutes per day */
68
+    const km2mi    = 0.621371; /* Kilometers per Mile */
69
+    const ae       = 1.0;
70
+    const ck2      = 5.413079E-4;
71
+    const ck4      = 6.209887E-7;
72
+    const __f      = 3.352779E-3;
73
+    const ge       = 3.986008E5;
74
+    const __s__    = 1.012229;
75
+    const qoms2t   = 1.880279E-09;
76
+    const secday   = 8.6400E4; /* Seconds per day */
77
+    const omega_E  = 1.0027379;
78
+    const omega_ER = 6.3003879;
79
+    const zns      = 1.19459E-5;
80
+    const c1ss     = 2.9864797E-6;
81
+    const zes      = 1.675E-2;
82
+    const znl      = 1.5835218E-4;
83
+    const c1l      = 4.7968065E-7;
84
+    const zel      = 5.490E-2;
85
+    const zcosis   = 9.1744867E-1;
86
+    const zsinis   = 3.9785416E-1;
87 87
     const zsings   = -9.8088458E-1;
88
-    const zcosgs   =  1.945905E-1;
89
-    const zcoshs   =  1;
90
-    const zsinhs   =  0;
91
-    const q22      =  1.7891679E-6;
92
-    const q31      =  2.1460748E-6;
93
-    const q33      =  2.2123015E-7;
94
-    const g22      =  5.7686396;
95
-    const g32      =  9.5240898E-1;
96
-    const g44      =  1.8014998;
97
-    const g52      =  1.0508330;
98
-    const g54      =  4.4108898;
99
-    const root22   =  1.7891679E-6;
100
-    const root32   =  3.7393792E-7;
101
-    const root44   =  7.3636953E-9;
102
-    const root52   =  1.1428639E-7;
103
-    const root54   =  2.1765803E-9;
104
-    const thdt     =  4.3752691E-3;
105
-    const rho      =  1.5696615E-1;
106
-    const mfactor  =  7.292115E-5;
107
-    const __sr__   =  6.96000E5;      /*Solar radius - kilometers (IAU 76)*/
108
-    const AU       =  1.49597870E8;   /*Astronomical unit - kilometers (IAU 76)*/
88
+    const zcosgs   = 1.945905E-1;
89
+    const zcoshs   = 1;
90
+    const zsinhs   = 0;
91
+    const q22      = 1.7891679E-6;
92
+    const q31      = 2.1460748E-6;
93
+    const q33      = 2.2123015E-7;
94
+    const g22      = 5.7686396;
95
+    const g32      = 9.5240898E-1;
96
+    const g44      = 1.8014998;
97
+    const g52      = 1.0508330;
98
+    const g54      = 4.4108898;
99
+    const root22   = 1.7891679E-6;
100
+    const root32   = 3.7393792E-7;
101
+    const root44   = 7.3636953E-9;
102
+    const root52   = 1.1428639E-7;
103
+    const root54   = 2.1765803E-9;
104
+    const thdt     = 4.3752691E-3;
105
+    const rho      = 1.5696615E-1;
106
+    const mfactor  = 7.292115E-5;
107
+    const __sr__   = 6.96000E5; /*Solar radius - kilometers (IAU 76)*/
108
+    const AU       = 1.49597870E8; /*Astronomical unit - kilometers (IAU 76)*/
109 109
 
110 110
     /* visibility constants */
111 111
     const SAT_VIS_NONE     = 0;
@@ -163,18 +163,18 @@  discard block
 block discarded – undo
163 163
      */
164 164
     public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt)
165 165
     {
166
-        $aos = 0.0;    /* time of AOS */
167
-        $tca = 0.0;    /* time of TCA */
168
-        $los = 0.0;    /* time of LOS */
169
-        $dt = 0.0;     /* time diff */
170
-        $step = 0.0;   /* time step */
166
+        $aos = 0.0; /* time of AOS */
167
+        $tca = 0.0; /* time of TCA */
168
+        $los = 0.0; /* time of LOS */
169
+        $dt = 0.0; /* time diff */
170
+        $step = 0.0; /* time step */
171 171
         $t0 = $start;
172
-        $tres = 0.0;   /* required time resolution */
172
+        $tres = 0.0; /* required time resolution */
173 173
         $max_el = 0.0; /* maximum elevation */
174 174
         $pass = null;
175 175
         $detail = null;
176 176
         $done = false;
177
-        $iter = 0;      /* number of iterations */
177
+        $iter = 0; /* number of iterations */
178 178
         /* FIXME: watchdog */
179 179
 
180 180
         /*copy sat_in to a working structure*/
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $sat_working = clone $sat_in;
183 183
 
184 184
         /* get time resolution; sat-cfg stores it in seconds */
185
-        $tres = $this->timeRes / 86400.0;
185
+        $tres = $this->timeRes/86400.0;
186 186
 
187 187
         /* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL
188 188
             or we run out of time
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             /* aos = 0.0 means no aos */
208 208
             if ($aos == 0.0) {
209 209
                 $done = true;
210
-            } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) {
210
+            } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt))) {
211 211
                 /* check whether we are within time limits;
212 212
                     maxdt = 0 mean no time limit.
213 213
                 */
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                 $dt = $los - $aos;
218 218
 
219 219
                 /* get time step, which will give us the max number of entries */
220
-                $step = $dt / $this->numEntries;
220
+                $step = $dt/$this->numEntries;
221 221
 
222 222
                 /* but if this is smaller than the required resolution
223 223
                     we go with the resolution
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
         $solar_set = new Predict_ObsSet();
370 370
 
371 371
         /* FIXME: could be passed as parameter */
372
-        $obs_geodetic->lon   = $qth->lon * self::de2ra;
373
-        $obs_geodetic->lat   = $qth->lat * self::de2ra;
374
-        $obs_geodetic->alt   = $qth->alt / 1000.0;
372
+        $obs_geodetic->lon   = $qth->lon*self::de2ra;
373
+        $obs_geodetic->lat   = $qth->lat*self::de2ra;
374
+        $obs_geodetic->alt   = $qth->alt/1000.0;
375 375
         $obs_geodetic->theta = 0;
376 376
 
377 377
         Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector);
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 
453 453
             /* coarse time steps */
454 454
             while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) {
455
-                $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
455
+                $t -= 0.00035*($sat->el*(($sat->alt/8400.0) + 0.46) - 2.0);
456 456
                 $this->predict_calc($sat, $qth, $t);
457 457
             }
458 458
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
                 if (abs($sat->el) < 0.005) {
463 463
                     $aostime = $t;
464 464
                 } else {
465
-                    $t -= $sat->el * sqrt($sat->alt) / 530000.0;
465
+                    $t -= $sat->el*sqrt($sat->alt)/530000.0;
466 466
                     $this->predict_calc($sat, $qth, $t);
467 467
                 }
468 468
             }
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
             /* coarse time steps */
473 473
             while ($sat->el < -1.0) {
474 474
 
475
-                $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
475
+                $t -= 0.00035*($sat->el*(($sat->alt/8400.0) + 0.46) - 2.0);
476 476
                 $this->predict_calc($sat, $qth, $t);
477 477
             }
478 478
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
                 if (abs($sat->el) < 0.005) {
483 483
                     $aostime = $t;
484 484
                 } else {
485
-                    $t -= $sat->el * sqrt($sat->alt) / 530000.0;
485
+                    $t -= $sat->el*sqrt($sat->alt)/530000.0;
486 486
                     $this->predict_calc($sat, $qth, $t);
487 487
                 }
488 488
 
@@ -504,17 +504,17 @@  discard block
 block discarded – undo
504 504
         $sat_geodetic = new Predict_Geodetic();
505 505
         $obs_geodetic = new Predict_Geodetic();
506 506
 
507
-        $obs_geodetic->lon   = $qth->lon * self::de2ra;
508
-        $obs_geodetic->lat   = $qth->lat * self::de2ra;
509
-        $obs_geodetic->alt   = $qth->alt / 1000.0;
507
+        $obs_geodetic->lon   = $qth->lon*self::de2ra;
508
+        $obs_geodetic->lat   = $qth->lat*self::de2ra;
509
+        $obs_geodetic->alt   = $qth->alt/1000.0;
510 510
         $obs_geodetic->theta = 0;
511 511
 
512 512
         $sat->jul_utc = $t;
513
-        $sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda;
513
+        $sat->tsince = ($sat->jul_utc - $sat->jul_epoch)*self::xmnpda;
514 514
 
515 515
         /* call the norad routines according to the deep-space flag */
516 516
         $sgpsdp = Predict_SGPSDP::getInstance($sat);
517
-        if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
517
+        if ($sat->flags&Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
518 518
             $sgpsdp->SDP4($sat, $sat->tsince);
519 519
         } else {
520 520
             $sgpsdp->SGP4($sat, $sat->tsince);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
         Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
524 524
 
525 525
         /* get the velocity of the satellite */
526
-        $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
526
+        $sat->vel->w = sqrt($sat->vel->x*$sat->vel->x + $sat->vel->y*$sat->vel->y + $sat->vel->z*$sat->vel->z);
527 527
         $sat->velo = $sat->vel->w;
528 528
         Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
529 529
         Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic);
@@ -544,16 +544,16 @@  discard block
 block discarded – undo
544 544
         $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
545 545
         $sat->alt = $sat_geodetic->alt;
546 546
         $sat->ma = Predict_Math::Degrees($sat->phase);
547
-        $sat->ma *= 256.0 / 360.0;
547
+        $sat->ma *= 256.0/360.0;
548 548
         $sat->phase = Predict_Math::Degrees($sat->phase);
549 549
 
550 550
         /* same formulas, but the one from predict is nicer */
551 551
         //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w);
552
-        $sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt));
552
+        $sat->footprint = 12756.33*acos(self::xkmper/(self::xkmper + $sat->alt));
553 553
         $age = $sat->jul_utc - $sat->jul_epoch;
554
-        $sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi +
555
-                        $age * $sat->tle->bstar * self::ae) * $age +
556
-                        $sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1;
554
+        $sat->orbit = floor(($sat->tle->xno*self::xmnpda/self::twopi +
555
+                        $age*$sat->tle->bstar*self::ae)*$age +
556
+                        $sat->tle->xmo/self::twopi) + $sat->tle->revnum - 1;
557 557
     }
558 558
 
559 559
     /** Find the LOS time of the next pass.
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
         /* check whether satellite has aos */
586 586
         if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
587 587
             ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
588
-            !$this->has_aos ($sat, $qth)) {
588
+            !$this->has_aos($sat, $qth)) {
589 589
 
590 590
             return 0.0;
591 591
         }
@@ -607,14 +607,14 @@  discard block
 block discarded – undo
607 607
 
608 608
             /* coarse steps */
609 609
             while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) {
610
-                $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
610
+                $t += cos(($sat->el - 1.0)*self::de2ra)*sqrt($sat->alt)/25000.0;
611 611
                 $this->predict_calc($sat, $qth, $t);
612 612
             }
613 613
 
614 614
             /* fine steps */
615
-            while (($lostime == 0.0) && ($t <= ($start + $maxdt)))  {
615
+            while (($lostime == 0.0) && ($t <= ($start + $maxdt))) {
616 616
 
617
-                $t += $sat->el * sqrt($sat->alt) / 502500.0;
617
+                $t += $sat->el*sqrt($sat->alt)/502500.0;
618 618
                 $this->predict_calc($sat, $qth, $t);
619 619
 
620 620
                 if (abs($sat->el) < 0.005) {
@@ -626,14 +626,14 @@  discard block
 block discarded – undo
626 626
 
627 627
             /* coarse steps */
628 628
             while ($sat->el >= 1.0) {
629
-                $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
629
+                $t += cos(($sat->el - 1.0)*self::de2ra)*sqrt($sat->alt)/25000.0;
630 630
                 $this->predict_calc($sat, $qth, $t);
631 631
             }
632 632
 
633 633
             /* fine steps */
634 634
             while ($lostime == 0.0) {
635 635
 
636
-                $t += $sat->el * sqrt($sat->alt) / 502500.0;
636
+                $t += $sat->el*sqrt($sat->alt)/502500.0;
637 637
                 $this->predict_calc($sat, $qth, $t);
638 638
 
639 639
                 if (abs($sat->el) < 0.005)
@@ -701,10 +701,10 @@  discard block
 block discarded – undo
701 701
                 $lin = self::pi - $lin;
702 702
             }
703 703
 
704
-            $sma = 331.25 * exp(log(1440.0 / $sat->meanmo) * (2.0 / 3.0));
705
-            $apogee = $sma * (1.0 + $sat->tle->eo) - self::xkmper;
704
+            $sma = 331.25*exp(log(1440.0/$sat->meanmo)*(2.0/3.0));
705
+            $apogee = $sma*(1.0 + $sat->tle->eo) - self::xkmper;
706 706
 
707
-            if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) {
707
+            if ((acos(self::xkmper/($apogee + self::xkmper)) + ($lin)) > abs($qth->lat*self::de2ra)) {
708 708
                 $retcode = true;
709 709
             } else {
710 710
                 $retcode = false;
@@ -866,10 +866,10 @@  discard block
 block discarded – undo
866 866
      */
867 867
     public function azDegreesToDirection($az = 0)
868 868
     {
869
-        $i = floor($az / 22.5);
870
-        $m = (22.5 * (2 * $i + 1)) / 2;
869
+        $i = floor($az/22.5);
870
+        $m = (22.5*(2*$i + 1))/2;
871 871
         $i = ($az >= $m) ? $i + 1 : $i;
872 872
 
873
-        return trim(substr('N  NNENE ENEE  ESESE SSES  SSWSW WSWW  WNWNW NNWN  ', $i * 3, 3));
873
+        return trim(substr('N  NNENE ENEE  ESESE SSES  SSWSW WSWW  WNWNW NNWN  ', $i*3, 3));
874 874
     }
875 875
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -636,8 +636,9 @@
 block discarded – undo
636 636
                 $t += $sat->el * sqrt($sat->alt) / 502500.0;
637 637
                 $this->predict_calc($sat, $qth, $t);
638 638
 
639
-                if (abs($sat->el) < 0.005)
640
-                    $lostime = $t;
639
+                if (abs($sat->el) < 0.005) {
640
+                                    $lostime = $t;
641
+                }
641 642
             }
642 643
         }
643 644
 
Please login to merge, or discard this patch.