Completed
Push — master ( 7fab65...347b49 )
by Yannick
05:33
created
install/index.php 3 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	}
93 93
 	print '</ul>You <strong>must</strong> add these modules/fix errors.</div>';
94 94
 	require('../footer.php');
95
-        exit;
95
+		exit;
96 96
 }
97 97
 
98 98
 if (!isset($_SESSION['install']) && !isset($_POST['dbtype']) && (count($error) == 0)) {
@@ -301,17 +301,17 @@  discard block
 block discarded – undo
301 301
 				</tr>
302 302
 				<!--
303 303
 		<?php
304
-		    require_once(dirname(__FILE__).'/../require/class.Connection.php');
305
-		    $Connection = new Connection();
304
+			require_once(dirname(__FILE__).'/../require/class.Connection.php');
305
+			$Connection = new Connection();
306 306
 		?>
307 307
 				-->
308 308
 		<?php
309
-		    if ($Connection->db != NULL) {
309
+			if ($Connection->db != NULL) {
310 310
 			if ($Connection->tableExists('source_location')) {
311
-			    require_once(dirname(__FILE__).'/../require/class.Source.php');
312
-			    $Source = new Source();
313
-			    $alllocations = $Source->getAllLocationInfo();
314
-			    foreach ($alllocations as $location) {
311
+				require_once(dirname(__FILE__).'/../require/class.Source.php');
312
+				$Source = new Source();
313
+				$alllocations = $Source->getAllLocationInfo();
314
+				foreach ($alllocations as $location) {
315 315
 		?>
316 316
 				<tr>
317 317
 	    				<input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" />
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
 				</tr>
326 326
 		
327 327
 		<?php
328
-			    }
328
+				}
329
+			}
329 330
 			}
330
-		    }
331 331
 		?>
332 332
 
333 333
 				<tr>
@@ -418,12 +418,12 @@  discard block
 block discarded – undo
418 418
 ?>
419 419
 							<tr>
420 420
 								<?php
421
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
421
+									if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
422 422
 								?>
423 423
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
424 424
 								<td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td>
425 425
 								<?php
426
-								    } else {
426
+									} else {
427 427
 									$hostport = explode(':',$source['host']);
428 428
 									if (isset($hostport[1])) {
429 429
 										$host = $hostport[0];
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 								<td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td>
437 437
 								<td><input type="number" name="port[]" id="port" value="<?php print $port; ?>" /></td>
438 438
 								<?php
439
-								    }
439
+									}
440 440
 								?>
441 441
 								<td>
442 442
 									<select name="format[]" id="format">
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 			<br />
728 728
 			<p>
729 729
 			<?php 
730
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
730
+				if (extension_loaded('gd') && function_exists('gd_info')) {
731 731
 			?>
732 732
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
733 733
 				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
@@ -737,11 +737,11 @@  discard block
 block discarded – undo
737 737
 				<b>The directory cache is not writable, aircraft icon will not be cached</b>
738 738
 			<?php
739 739
 				}
740
-			    } else {
740
+				} else {
741 741
 			?>
742 742
 				<b>PHP GD is not installed, you can t change color of aircraft icon on map</b>
743 743
 			<?php
744
-			    }
744
+				}
745 745
 			?>
746 746
 			</p>
747 747
 			<br />
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 	</p>
761 761
 <?php
762 762
 	require('../footer.php');
763
-        exit;
763
+		exit;
764 764
 }
765 765
 	
766 766
 $settings = array();
@@ -850,8 +850,8 @@  discard block
 block discarded – undo
850 850
 	
851 851
 	$sources = array();
852 852
 	foreach ($source_name as $keys => $name) {
853
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
854
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
853
+		if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
854
+		else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
855 855
 	}
856 856
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
857 857
 
@@ -1116,14 +1116,14 @@  discard block
 block discarded – undo
1116 1116
 
1117 1117
 	// Set some defaults values...
1118 1118
 	if (!isset($globalAircraftImageSources)) {
1119
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1120
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1119
+		$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1120
+		$settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1121 1121
 	}
1122 1122
 
1123 1123
 	if (!isset($globalSchedulesSources)) {
1124
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1125
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1126
-    	}
1124
+		$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1125
+			$settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1126
+		}
1127 1127
 
1128 1128
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1129 1129
 
@@ -1175,21 +1175,21 @@  discard block
 block discarded – undo
1175 1175
 	$popi = false;
1176 1176
 	$popw = false;
1177 1177
 	foreach ($_SESSION['done'] as $done) {
1178
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1179
-	    if ($done == 'Create database') $pop = true;
1180
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1181
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1182
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1178
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1179
+		if ($done == 'Create database') $pop = true;
1180
+		if ($_SESSION['install'] == 'database_create') $pop = true;
1181
+		if ($_SESSION['install'] == 'database_import') $popi = true;
1182
+		if ($_SESSION['install'] == 'waypoints') $popw = true;
1183 1183
 	}
1184 1184
 	if ($pop) {
1185
-	    sleep(5);
1186
-	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1185
+		sleep(5);
1186
+		print '<li>Create database....<img src="../images/loading.gif" /></li>';
1187 1187
 	} else if ($popi) {
1188
-	    sleep(5);
1189
-	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1188
+		sleep(5);
1189
+		print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1190 1190
 	} else if ($popw) {
1191
-	    sleep(5);
1192
-	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1191
+		sleep(5);
1192
+		print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1193 1193
 	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1194 1194
 	print '</div></ul>';
1195 1195
 	print '<div id="error"></div>';
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
 	unset($_COOKIE['install']);
1253 1253
 	print '<div class="info column"><ul>';
1254 1254
 	foreach ($_SESSION['done'] as $done) {
1255
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1255
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1256 1256
 	}
1257 1257
 	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1258 1258
 	print '</ul></div>';
Please login to merge, or discard this patch.
Braces   +394 added lines, -102 removed lines patch added patch discarded remove patch
@@ -124,45 +124,72 @@  discard block
 block discarded – undo
124 124
 			</div>
125 125
 			<p>
126 126
 				<label for="dbhost">Database hostname</label>
127
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
127
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
128
+	print $globalDBhost;
129
+}
130
+?>" />
128 131
 			</p>
129 132
 			<p>
130 133
 				<label for="dbport">Database port</label>
131
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
134
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
135
+	print $globalDBport;
136
+}
137
+?>" />
132 138
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
133 139
 			</p>
134 140
 			<p>
135 141
 				<label for="dbname">Database name</label>
136
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
142
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
143
+	print $globalDBname;
144
+}
145
+?>" />
137 146
 			</p>
138 147
 			<p>
139 148
 				<label for="dbuser">Database user</label>
140
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
149
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
150
+	print $globalDBuser;
151
+}
152
+?>" />
141 153
 			</p>
142 154
 			<p>
143 155
 				<label for="dbuserpass">Database user password</label>
144
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
156
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
157
+	print $globalDBpass;
158
+}
159
+?>" />
145 160
 			</p>
146 161
 		</fieldset>
147 162
 		<fieldset id="site">
148 163
 			<legend>Site configuration</legend>
149 164
 			<p>
150 165
 				<label for="sitename">Site name</label>
151
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
166
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
167
+	print $globalName;
168
+}
169
+?>" />
152 170
 			</p>
153 171
 			<p>
154 172
 				<label for="siteurl">Site directory</label>
155
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
173
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
174
+	print $globalURL;
175
+}
176
+?>" />
156 177
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
157 178
 			</p>
158 179
 			<p>
159 180
 				<label for="timezone">Timezone</label>
160
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
181
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
182
+	print $globalTimezone;
183
+}
184
+?>" />
161 185
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
162 186
 			</p>
163 187
 			<p>
164 188
 				<label for="language">Language</label>
165
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
189
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
190
+	print $globalLanguage;
191
+}
192
+?>" />
166 193
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
167 194
 			</p>
168 195
 		</fieldset>
@@ -183,11 +210,17 @@  discard block
 block discarded – undo
183 210
 			<div id="mapbox_data">
184 211
 				<p>
185 212
 					<label for="mapboxid">Mapbox id</label>
186
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
213
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
214
+	print $globalMapboxId;
215
+}
216
+?>" />
187 217
 				</p>
188 218
 				<p>
189 219
 					<label for="mapboxtoken">Mapbox token</label>
190
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
220
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
221
+	print $globalMapboxToken;
222
+}
223
+?>" />
191 224
 				</p>
192 225
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
193 226
 			</div>
@@ -195,7 +228,10 @@  discard block
 block discarded – undo
195 228
 			<div id="google_data">
196 229
 				<p>
197 230
 					<label for="googlekey">Google API key</label>
198
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
231
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
232
+	print $globalGoogleAPIKey;
233
+}
234
+?>" />
199 235
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
200 236
 				</p>
201 237
 			</div>
@@ -203,7 +239,10 @@  discard block
 block discarded – undo
203 239
 			<div id="bing_data">
204 240
 				<p>
205 241
 					<label for="bingkey">Bing Map key</label>
206
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
242
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
243
+	print $globalBingMapKey;
244
+}
245
+?>" />
207 246
 					<p class="help-block">Get a key <a href="https://msdn.microsoft.com/en-us/library/ff428642.aspx">here</a></p>
208 247
 				</p>
209 248
 			</div>
@@ -211,7 +250,10 @@  discard block
 block discarded – undo
211 250
 			<div id="mapquest_data">
212 251
 				<p>
213 252
 					<label for="mapquestkey">MapQuest key</label>
214
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
253
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
254
+	print $globalMapQuestKey;
255
+}
256
+?>" />
215 257
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
216 258
 				</p>
217 259
 			</div>
@@ -219,11 +261,17 @@  discard block
 block discarded – undo
219 261
 			<div id="here_data">
220 262
 				<p>
221 263
 					<label for="hereappid">Here App_Id</label>
222
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
264
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
265
+	print $globalHereappId;
266
+}
267
+?>" />
223 268
 				</p>
224 269
 				<p>
225 270
 					<label for="hereappcode">Here App_Code</label>
226
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
271
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
272
+	print $globalHereappCode;
273
+}
274
+?>" />
227 275
 				</p>
228 276
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
229 277
 			</div>
@@ -232,42 +280,86 @@  discard block
 block discarded – undo
232 280
 			<legend>Coverage area</legend>
233 281
 			<p>
234 282
 				<label for="latitudemax">The maximum latitude (north)</label>
235
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
283
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
284
+	print $globalLatitudeMax;
285
+}
286
+?>" />
236 287
 			</p>
237 288
 			<p>
238 289
 				<label for="latitudemin">The minimum latitude (south)</label>
239
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
290
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
291
+	print $globalLatitudeMin;
292
+}
293
+?>" />
240 294
 			</p>
241 295
 			<p>
242 296
 				<label for="longitudemax">The maximum longitude (west)</label>
243
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
297
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
298
+	print $globalLongitudeMax;
299
+}
300
+?>" />
244 301
 			</p>
245 302
 			<p>
246 303
 				<label for="longitudemin">The minimum longitude (east)</label>
247
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
304
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
305
+	print $globalLongitudeMin;
306
+}
307
+?>" />
248 308
 			</p>
249 309
 			<p>
250 310
 				<label for="latitudecenter">The latitude center</label>
251
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
311
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
312
+	print $globalCenterLatitude;
313
+}
314
+?>" />
252 315
 			</p>
253 316
 			<p>
254 317
 				<label for="longitudecenter">The longitude center</label>
255
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
318
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
319
+	print $globalCenterLongitude;
320
+}
321
+?>" />
256 322
 			</p>
257 323
 			<p>
258 324
 				<label for="livezoom">Default Zoom on live map</label>
259
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
325
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
326
+	print $globalLiveZoom;
327
+} else {
328
+	print '9';
329
+}
330
+?>" />
260 331
 			</p>
261 332
 			<p>
262 333
 				<label for="squawk_country">Country for squawk usage</label>
263 334
 				<select name="squawk_country" id="squawk_country">
264
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
265
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
266
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
267
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
268
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
269
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
270
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
335
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
336
+	print ' selected ';
337
+}
338
+?>>UK</option>
339
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
340
+	print ' selected ';
341
+}
342
+?>>NZ</option>
343
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
344
+	print ' selected ';
345
+}
346
+?>>US</option>
347
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
348
+	print ' selected ';
349
+}
350
+?>>AU</option>
351
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
352
+	print ' selected ';
353
+}
354
+?>>NL</option>
355
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
356
+	print ' selected ';
357
+}
358
+?>>FR</option>
359
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
360
+	print ' selected ';
361
+}
362
+?>>TR</option>
271 363
 				</select>
272 364
 			</p>
273 365
 		</fieldset>
@@ -276,15 +368,24 @@  discard block
 block discarded – undo
276 368
 			<p><i>Only put in DB flights that are inside a circle</i></p>
277 369
 			<p>
278 370
 				<label for="latitude">Center latitude</label>
279
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
371
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
372
+	echo $globalDistanceIgnore['latitude'];
373
+}
374
+?>" />
280 375
 			</p>
281 376
 			<p>
282 377
 				<label for="longitude">Center longitude</label>
283
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
378
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
379
+	echo $globalDistanceIgnore['longitude'];
380
+}
381
+?>" />
284 382
 			</p>
285 383
 			<p>
286 384
 				<label for="Distance">Distance (in km)</label>
287
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
385
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
386
+	echo $globalDistanceIgnore['distance'];
387
+}
388
+?>" />
288 389
 			</p>
289 390
 		</fieldset>
290 391
 		<fieldset id="sourceloc">
@@ -377,11 +478,17 @@  discard block
 block discarded – undo
377 478
 			<div id="flightaware_data">
378 479
 				<p>
379 480
 					<label for="flightawareusername">FlightAware username</label>
380
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
481
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
482
+	print $globalFlightAwareUsername;
483
+}
484
+?>" />
381 485
 				</p>
382 486
 				<p>
383 487
 					<label for="flightawarepassword">FlightAware password/API key</label>
384
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
488
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
489
+	print $globalFlightAwarePassword;
490
+}
491
+?>" />
385 492
 				</p>
386 493
 			</div>
387 494
 -->
@@ -440,22 +547,64 @@  discard block
 block discarded – undo
440 547
 								?>
441 548
 								<td>
442 549
 									<select name="format[]" id="format">
443
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
444
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
445
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
446
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
447
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
448
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
449
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
450
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server</option>
451
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
452
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
453
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
454
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
550
+										<option value="auto" <?php if (!isset($source['format'])) {
551
+	print 'selected';
552
+}
553
+?>>Auto</option>
554
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
555
+	print 'selected';
556
+}
557
+?>>SBS</option>
558
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
559
+	print 'selected';
560
+}
561
+?>>TSV</option>
562
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
563
+	print 'selected';
564
+}
565
+?>>Raw</option>
566
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
567
+	print 'selected';
568
+}
569
+?>>APRS</option>
570
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
571
+	print 'selected';
572
+}
573
+?>>Radarcape deltadb.txt</option>
574
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
575
+	print 'selected';
576
+}
577
+?>>Vatsim</option>
578
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
579
+	print 'selected';
580
+}
581
+?>>Virtual Radar Server</option>
582
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
583
+	print 'selected';
584
+}
585
+?>>phpVMS</option>
586
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
587
+	print 'selected';
588
+}
589
+?>>IVAO</option>
590
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
591
+	print 'selected';
592
+}
593
+?>>FlightGear Multiplayer</option>
594
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
595
+	print 'selected';
596
+}
597
+?>>FlightGear Singleplayer</option>
455 598
 									</select>
456 599
 								</td>
457
-								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td>
458
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
600
+								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
601
+	print $source['name'];
602
+}
603
+?>" /></td>
604
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
605
+	print 'checked';
606
+}
607
+?> /></td>
459 608
 								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
460 609
 							</tr>
461 610
 <?php
@@ -497,11 +646,17 @@  discard block
 block discarded – undo
497 646
 					<p>Listen UDP server for acarsdec/acarsdeco2/...</p>
498 647
 					<p>
499 648
 						<label for="acarshost">ACARS UDP host</label>
500
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
649
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
650
+	print $globalACARSHost;
651
+}
652
+?>" />
501 653
 					</p>
502 654
 					<p>
503 655
 						<label for="acarsport">ACARS UDP port</label>
504
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
656
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
657
+	print $globalACARSPort;
658
+}
659
+?>" />
505 660
 					</p>
506 661
 				</fieldset>
507 662
 			</div>
@@ -564,13 +719,19 @@  discard block
 block discarded – undo
564 719
 			<div id="schedules_options">
565 720
 				<p>
566 721
 					<label for="britishairways">British Airways API Key</label>
567
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
722
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
723
+	print $globalBritishAirwaysKey;
724
+}
725
+?>" />
568 726
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
569 727
 				</p>
570 728
 				<!--
571 729
 				<p>
572 730
 					<label for="transavia">Transavia Test API Consumer Key</label>
573
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
731
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
732
+	print $globalTransaviaKey;
733
+}
734
+?>" />
574 735
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
575 736
 				</p>
576 737
 				-->
@@ -579,10 +740,16 @@  discard block
 block discarded – undo
579 740
 						<b>Lufthansa API Key</b>
580 741
 						<p>
581 742
 							<label for="lufthansakey">Key</label>
582
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
743
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
744
+	print $globalLufthansaKey['key'];
745
+}
746
+?>" />
583 747
 						</p><p>
584 748
 							<label for="lufthansasecret">Secret</label>
585
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
749
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
750
+	print $globalLufthansaKey['secret'];
751
+}
752
+?>" />
586 753
 						</p>
587 754
 					</div>
588 755
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -602,7 +769,10 @@  discard block
 block discarded – undo
602 769
 			</p>
603 770
 			<p>
604 771
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
605
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
772
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
773
+	print $globalNOTAMSource;
774
+}
775
+?>" />
606 776
 			</p>
607 777
 			<br />
608 778
 			<p>
@@ -617,14 +787,20 @@  discard block
 block discarded – undo
617 787
 			<div id="metarsrc">
618 788
 				<p>
619 789
 					<label for="metarsource">URL of your METAR source</label>
620
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
790
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
791
+	print $globalMETARurl;
792
+}
793
+?>" />
621 794
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
622 795
 				</p>
623 796
 			</div>
624 797
 			<br />
625 798
 			<p>
626 799
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
627
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
800
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
801
+	print $globalBitlyAccessToken;
802
+}
803
+?>" />
628 804
 			</p>
629 805
 			<br />
630 806
 			<p>
@@ -638,7 +814,12 @@  discard block
 block discarded – undo
638 814
 			</p>
639 815
 			<p>
640 816
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
641
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
817
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
818
+	print $globalArchiveMonths;
819
+} else {
820
+	echo '0';
821
+}
822
+?>" />
642 823
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
643 824
 			</p>
644 825
 			<p>
@@ -648,12 +829,22 @@  discard block
 block discarded – undo
648 829
 			</p>
649 830
 			<p>
650 831
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
651
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
832
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
833
+	print $globalArchiveKeepMonths;
834
+} else {
835
+	echo '0';
836
+}
837
+?>" />
652 838
 				<p class="help-block">0 to disable</p>
653 839
 			</p>
654 840
 			<p>
655 841
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
656
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
842
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
843
+	print $globalArchiveKeepTrackMonths;
844
+} else {
845
+	echo '0';
846
+}
847
+?>" />
657 848
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
658 849
 			</p>
659 850
 			<br />
@@ -662,7 +853,12 @@  discard block
 block discarded – undo
662 853
 				<input type="checkbox" name="daemon" id="daemon" value="daemon"<?php if ((isset($globalDaemon) && $globalDaemon) || !isset($globalDaemon)) { ?> checked="checked"<?php } ?> onClick="daemon_js()" />
663 854
 				<div id="cronends"> 
664 855
 					<label for="cronend">Run script for xx seconds</label>
665
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
856
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
857
+	print $globalCronEnd;
858
+} else {
859
+	print '0';
860
+}
861
+?>" />
666 862
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
667 863
 				</div>
668 864
 				<p class="help-block">Uncheck if the script is running as cron job</p>
@@ -703,26 +899,49 @@  discard block
 block discarded – undo
703 899
 			<br />
704 900
 			<p>
705 901
 				<label for="refresh">Show flights detected since xxx seconds</label>
706
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
902
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
903
+	echo $globalLiveInterval;
904
+} else {
905
+	echo '200';
906
+}
907
+?>" />
707 908
 			</p>
708 909
 			<p>
709 910
 				<label for="maprefresh">Live map refresh (in seconds)</label>
710
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
911
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
912
+	echo $globalMapRefresh;
913
+} else {
914
+	echo '30';
915
+}
916
+?>" />
711 917
 			</p>
712 918
 			<p>
713 919
 				<label for="mapidle">Map idle timeout (in minutes)</label>
714
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
920
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
921
+	echo $globalMapIdleTimeout;
922
+} else {
923
+	echo '30';
924
+}
925
+?>" />
715 926
 				<p class="help-block">0 to disable</p>
716 927
 			</p>
717 928
 			<br />
718 929
 			<p>
719 930
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
720
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
931
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
932
+	echo $globalClosestMinDist;
933
+} else {
934
+	echo '50';
935
+}
936
+?>" />
721 937
 			</p>
722 938
 			<br />
723 939
 			<p>
724 940
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
725
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
941
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
942
+	echo $globalAircraftSize;
943
+}
944
+?>" />
726 945
 			</p>
727 946
 			<br />
728 947
 			<p>
@@ -730,7 +949,12 @@  discard block
 block discarded – undo
730 949
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
731 950
 			?>
732 951
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
733
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
952
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
953
+	echo $globalAircraftIconColor;
954
+} else {
955
+	echo '1a3151';
956
+}
957
+?>" />
734 958
 			<?php
735 959
 				if (!is_writable('../cache')) {
736 960
 			?>
@@ -748,8 +972,18 @@  discard block
 block discarded – undo
748 972
 			<p>
749 973
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
750 974
 				<div class="range">
751
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
752
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
975
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
976
+	echo $globalAirportZoom;
977
+} else {
978
+	echo '7';
979
+}
980
+?>" />
981
+					<output id="range"><?php if (isset($globalAirportZoom)) {
982
+	echo $globalAirportZoom;
983
+} else {
984
+	echo '7';
985
+}
986
+?></output>
753 987
 				</div>
754 988
 			</p>
755 989
 		</fieldset>
@@ -777,8 +1011,12 @@  discard block
 block discarded – undo
777 1011
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
778 1012
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
779 1013
 
780
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
781
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1014
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1015
+		$error .= 'Mysql driver for PDO must be loaded';
1016
+	}
1017
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1018
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1019
+	}
782 1020
 	
783 1021
 	$_SESSION['database_root'] = $dbroot;
784 1022
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -845,15 +1083,23 @@  discard block
 block discarded – undo
845 1083
 	$source_city = $_POST['source_city'];
846 1084
 	$source_country = $_POST['source_country'];
847 1085
 	$source_ref = $_POST['source_ref'];
848
-	if (isset($source_id)) $source_id = $_POST['source_id'];
849
-	else $source_id = array();
1086
+	if (isset($source_id)) {
1087
+		$source_id = $_POST['source_id'];
1088
+	} else {
1089
+		$source_id = array();
1090
+	}
850 1091
 	
851 1092
 	$sources = array();
852 1093
 	foreach ($source_name as $keys => $name) {
853
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
854
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1094
+	    if (isset($source_id[$keys])) {
1095
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1096
+	    } else {
1097
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1098
+	    }
1099
+	}
1100
+	if (count($sources) > 0) {
1101
+		$_SESSION['sources'] = $sources;
855 1102
 	}
856
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
857 1103
 
858 1104
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
859 1105
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -890,13 +1136,21 @@  discard block
 block discarded – undo
890 1136
 	$port = $_POST['port'];
891 1137
 	$name = $_POST['name'];
892 1138
 	$format = $_POST['format'];
893
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
894
-	else $sourcestats = array();
1139
+	if (isset($_POST['sourcestats'])) {
1140
+		$sourcestats = $_POST['sourcestats'];
1141
+	} else {
1142
+		$sourcestats = array();
1143
+	}
895 1144
 	$gSources = array();
896 1145
 	foreach ($host as $key => $h) {
897
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
898
-		else $cov = 'FALSE';
899
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1146
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1147
+			$cov = 'TRUE';
1148
+		} else {
1149
+			$cov = 'FALSE';
1150
+		}
1151
+		if ($h != '') {
1152
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1153
+		}
900 1154
 	}
901 1155
 	$settings = array_merge($settings,array('globalSources' => $gSources));
902 1156
 
@@ -920,7 +1174,9 @@  discard block
 block discarded – undo
920 1174
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
921 1175
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
922 1176
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
923
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1177
+	} else {
1178
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1179
+	}
924 1180
 
925 1181
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
926 1182
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -959,7 +1215,9 @@  discard block
 block discarded – undo
959 1215
 
960 1216
 	// Create in settings.php keys not yet configurable if not already here
961 1217
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
962
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1218
+	if (!isset($globalDebug)) {
1219
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1220
+	}
963 1221
 
964 1222
 	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
965 1223
 	if ($archive == 'archive') {
@@ -989,24 +1247,38 @@  discard block
 block discarded – undo
989 1247
 	}
990 1248
 */
991 1249
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
992
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
993
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
994
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
995
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1250
+	if ($globalsbs == 'sbs') {
1251
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1252
+	} else {
1253
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1254
+	}
1255
+	if ($globalaprs == 'aprs') {
1256
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1257
+	} else {
1258
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1259
+	}
996 1260
 	if ($globalivao == 'ivao') {
997 1261
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
998 1262
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
999
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1263
+	} else {
1264
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1265
+	}
1000 1266
 	if ($globalvatsim == 'vatsim') {
1001 1267
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1002 1268
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1003
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1269
+	} else {
1270
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1271
+	}
1004 1272
 	if ($globalphpvms == 'phpvms') {
1005 1273
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1006
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1274
+	} else {
1275
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1276
+	}
1007 1277
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1008 1278
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1009
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1279
+	} else {
1280
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1281
+	}
1010 1282
 	
1011 1283
 
1012 1284
 
@@ -1112,7 +1384,9 @@  discard block
 block discarded – undo
1112 1384
 		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1113 1385
 	}
1114 1386
 
1115
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1387
+	if (!isset($globalTransaction)) {
1388
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1389
+	}
1116 1390
 
1117 1391
 	// Set some defaults values...
1118 1392
 	if (!isset($globalAircraftImageSources)) {
@@ -1127,15 +1401,23 @@  discard block
 block discarded – undo
1127 1401
 
1128 1402
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1129 1403
 
1130
-	if ($error == '') settings::modify_settings($settings);
1131
-	if ($error == '') settings::comment_settings($settings_comment);
1404
+	if ($error == '') {
1405
+		settings::modify_settings($settings);
1406
+	}
1407
+	if ($error == '') {
1408
+		settings::comment_settings($settings_comment);
1409
+	}
1132 1410
 	if ($error != '') {
1133 1411
 		print '<div class="info column">'.$error.'</div>';
1134 1412
 		require('../footer.php');
1135 1413
 		exit;
1136 1414
 	} else {
1137
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1138
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1415
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1416
+			$_SESSION['waypoints'] = 1;
1417
+		}
1418
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1419
+			$_SESSION['owner'] = 1;
1420
+		}
1139 1421
 		if (isset($_POST['createdb'])) {
1140 1422
 			$_SESSION['install'] = 'database_create';
1141 1423
 		} else {
@@ -1176,10 +1458,18 @@  discard block
 block discarded – undo
1176 1458
 	$popw = false;
1177 1459
 	foreach ($_SESSION['done'] as $done) {
1178 1460
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1179
-	    if ($done == 'Create database') $pop = true;
1180
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1181
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1182
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1461
+	    if ($done == 'Create database') {
1462
+	    	$pop = true;
1463
+	    }
1464
+	    if ($_SESSION['install'] == 'database_create') {
1465
+	    	$pop = true;
1466
+	    }
1467
+	    if ($_SESSION['install'] == 'database_import') {
1468
+	    	$popi = true;
1469
+	    }
1470
+	    if ($_SESSION['install'] == 'waypoints') {
1471
+	    	$popw = true;
1472
+	    }
1183 1473
 	}
1184 1474
 	if ($pop) {
1185 1475
 	    sleep(5);
@@ -1190,7 +1480,9 @@  discard block
 block discarded – undo
1190 1480
 	} else if ($popw) {
1191 1481
 	    sleep(5);
1192 1482
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1193
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1483
+	} else {
1484
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1485
+	}
1194 1486
 	print '</div></ul>';
1195 1487
 	print '<div id="error"></div>';
1196 1488
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.create_db.php');
10 10
 require_once(dirname(__FILE__).'/class.update_schema.php');
11 11
 require_once(dirname(__FILE__).'/class.settings.php');
12
-$title="Install";
12
+$title = "Install";
13 13
 require(dirname(__FILE__).'/../require/settings.php');
14 14
 require(dirname(__FILE__).'/header.php');
15 15
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 if (!extension_loaded('curl')) {
64 64
 	$error[] = "Curl is not loaded.";
65 65
 }
66
-if(function_exists('apache_get_modules') ){
67
-	if(!in_array('mod_rewrite',apache_get_modules())) {
66
+if (function_exists('apache_get_modules')) {
67
+	if (!in_array('mod_rewrite', apache_get_modules())) {
68 68
 		$error[] = "mod_rewrite is not available.";
69 69
 	}
70 70
 /*
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 }
80 80
 if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
81 81
 	if (function_exists('get_headers')) {
82
-		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
83
-		if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
82
+		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
83
+		if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
84 84
 			print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
85 85
 		}
86 86
 	}
@@ -418,13 +418,13 @@  discard block
 block discarded – undo
418 418
 ?>
419 419
 							<tr>
420 420
 								<?php
421
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
421
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
422 422
 								?>
423 423
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
424 424
 								<td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td>
425 425
 								<?php
426 426
 								    } else {
427
-									$hostport = explode(':',$source['host']);
427
+									$hostport = explode(':', $source['host']);
428 428
 									if (isset($hostport[1])) {
429 429
 										$host = $hostport[0];
430 430
 										$port = $hostport[1];
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 			<br />
729 729
 			<p>
730 730
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
731
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
731
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
732 732
 			</p>
733 733
 			<br />
734 734
 			<p>
@@ -774,14 +774,14 @@  discard block
 block discarded – undo
774 774
 $error = '';
775 775
 
776 776
 if (isset($_POST['dbtype'])) {
777
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
778
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
779
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
780
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
781
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
782
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
783
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
784
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
777
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
778
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
779
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
780
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
781
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
782
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
783
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
784
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
785 785
 
786 786
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
787 787
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -801,48 +801,48 @@  discard block
 block discarded – undo
801 801
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
802 802
 	*/
803 803
 	
804
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
804
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
805 805
 
806
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
807
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
808
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
809
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
810
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
806
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
807
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
808
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
809
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
810
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
811 811
 
812
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
813
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
814
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
815
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
816
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
817
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
818
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
819
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
820
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey));
812
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
813
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
814
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
815
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
816
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
817
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
818
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
819
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
820
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey));
821 821
 	
822
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
823
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
824
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
825
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
826
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
827
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
822
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
823
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
824
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
825
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
826
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
827
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
828 828
 
829
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
830
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
829
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
830
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
831 831
 
832
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
833
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
834
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
832
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
833
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
834
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
835 835
 
836
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
836
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
837 837
 	if ($acars == 'acars') {
838
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
838
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
839 839
 	} else {
840
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
840
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
841 841
 	}
842 842
 
843
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
844
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
845
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
843
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
844
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
845
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
846 846
 	
847 847
 	$source_name = $_POST['source_name'];
848 848
 	$source_latitude = $_POST['source_latitude'];
@@ -856,8 +856,8 @@  discard block
 block discarded – undo
856 856
 	
857 857
 	$sources = array();
858 858
 	foreach ($source_name as $keys => $name) {
859
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
860
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
859
+	    if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]);
860
+	    else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]);
861 861
 	}
862 862
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
863 863
 
@@ -870,12 +870,12 @@  discard block
 block discarded – undo
870 870
 	$sbsurl = $_POST['sbsurl'];
871 871
 	*/
872 872
 
873
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
874
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
875
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
876
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
877
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
878
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
873
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
874
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
875
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
876
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
877
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
878
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
879 879
 
880 880
 /*	
881 881
 	$globalSBS1Hosts = array();
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 	}
892 892
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
893 893
 */
894
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
894
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
895 895
 	$host = $_POST['host'];
896 896
 	$port = $_POST['port'];
897 897
 	$name = $_POST['name'];
@@ -902,88 +902,88 @@  discard block
 block discarded – undo
902 902
 	foreach ($host as $key => $h) {
903 903
 		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
904 904
 		else $cov = 'FALSE';
905
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
905
+		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov);
906 906
 	}
907
-	$settings = array_merge($settings,array('globalSources' => $gSources));
907
+	$settings = array_merge($settings, array('globalSources' => $gSources));
908 908
 
909
-	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
910
-	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
909
+	$sbstimeout = filter_input(INPUT_POST, 'sbstimeout', FILTER_SANITIZE_NUMBER_INT);
910
+	$settings = array_merge($settings, array('globalSourcesTimeOut' => $sbstimeout));
911 911
 
912
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
913
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
914
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
912
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
913
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
914
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
915 915
 
916
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
917
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
916
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
917
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
918 918
 
919
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
920
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
921
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
922
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
919
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
920
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
921
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
922
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
923 923
 
924
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
925
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
926
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
924
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
925
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
926
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
927 927
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
928
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
929
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
928
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
929
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
930 930
 
931
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
932
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
933
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
934
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
935
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
936
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
937
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
938
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
931
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
932
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
933
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
934
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
935
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
936
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
937
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
938
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
939 939
 
940
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
941
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
940
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
941
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
942 942
 
943
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
944
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
943
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
944
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
945 945
 	
946
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
946
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
947 947
 	if ($archiveyear == "archiveyear") {
948
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
948
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
949 949
 	} else {
950
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
950
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
951 951
 	}
952
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
953
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
954
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
955
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
952
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
953
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
954
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
955
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
956 956
 
957
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
958
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
959
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
960
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
957
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
958
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
959
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
960
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
961 961
 
962
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
963
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
964
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
962
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
963
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
964
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
965 965
 
966 966
 	// Create in settings.php keys not yet configurable if not already here
967 967
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
968
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
968
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
969 969
 
970
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
970
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
971 971
 	if ($archive == 'archive') {
972
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
972
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
973 973
 	} else {
974
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
974
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
975 975
 	}
976
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
976
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
977 977
 	if ($daemon == 'daemon') {
978
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
978
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
979 979
 	} else {
980
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
980
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
981 981
 	}
982
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
982
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
983 983
 	if ($schedules == 'schedules') {
984
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
984
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
985 985
 	} else {
986
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
986
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
987 987
 	}
988 988
 
989 989
 /*
@@ -994,150 +994,150 @@  discard block
 block discarded – undo
994 994
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
995 995
 	}
996 996
 */
997
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
998
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
999
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1000
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1001
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
997
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
998
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
999
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1000
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1001
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1002 1002
 	if ($globalivao == 'ivao') {
1003 1003
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1004
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1005
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1004
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1005
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1006 1006
 	if ($globalvatsim == 'vatsim') {
1007 1007
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1008
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1009
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1008
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1009
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1010 1010
 	if ($globalphpvms == 'phpvms') {
1011
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1012
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1011
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1012
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1013 1013
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1014
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1015
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1014
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1015
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1016 1016
 	
1017 1017
 
1018 1018
 
1019
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1019
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1020 1020
 	if ($notam == 'notam') {
1021
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1021
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1022 1022
 	} else {
1023
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1023
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1024 1024
 	}
1025
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1025
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1026 1026
 	if ($owner == 'owner') {
1027
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1027
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1028 1028
 	} else {
1029
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1029
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1030 1030
 	}
1031
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1031
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1032 1032
 	if ($map3d == 'map3d') {
1033
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1033
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1034 1034
 	} else {
1035
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1035
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1036 1036
 	}
1037
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1037
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1038 1038
 	if ($mapsatellites == 'mapsatellites') {
1039
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1039
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1040 1040
 	} else {
1041
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1041
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1042 1042
 	}
1043
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1043
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1044 1044
 	if ($map3ddefault == 'map3ddefault') {
1045
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1045
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1046 1046
 	} else {
1047
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1047
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1048 1048
 	}
1049
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1049
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1050 1050
 	if ($translate == 'translate') {
1051
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1051
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1052 1052
 	} else {
1053
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1053
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1054 1054
 	}
1055
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1055
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1056 1056
 	if ($estimation == 'estimation') {
1057
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1057
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1058 1058
 	} else {
1059
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1059
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1060 1060
 	}
1061
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1061
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1062 1062
 	if ($metar == 'metar') {
1063
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1063
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1064 1064
 	} else {
1065
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1065
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1066 1066
 	}
1067
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1067
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1068 1068
 	if ($metarcycle == 'metarcycle') {
1069
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1069
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1070 1070
 	} else {
1071
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1071
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1072 1072
 	}
1073
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1073
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1074 1074
 	if ($fork == 'fork') {
1075
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1075
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1076 1076
 	} else {
1077
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1077
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1078 1078
 	}
1079 1079
 
1080
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1080
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1081 1081
 	if ($colormap == 'colormap') {
1082
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1082
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1083 1083
 	} else {
1084
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1084
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1085 1085
 	}
1086 1086
 	
1087 1087
 	if (isset($_POST['aircrafticoncolor'])) {
1088
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1089
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1088
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1089
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1090 1090
 	}
1091 1091
 
1092
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1093
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1092
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1093
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1094 1094
 
1095
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1096
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1097
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1098
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1099
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1100
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1095
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1096
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1097
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1098
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1099
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1100
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1101 1101
 
1102
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1102
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1103 1103
 	if ($mappopup == 'mappopup') {
1104
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1104
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1105 1105
 	} else {
1106
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1106
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1107 1107
 	}
1108
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1108
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1109 1109
 	if ($airportpopup == 'airportpopup') {
1110
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1110
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1111 1111
 	} else {
1112
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1112
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1113 1113
 	}
1114
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1114
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1115 1115
 	if ($maphistory == 'maphistory') {
1116
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1116
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1117 1117
 	} else {
1118
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1118
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1119 1119
 	}
1120
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1120
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1121 1121
 	if ($flightroute == 'flightroute') {
1122
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1122
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1123 1123
 	} else {
1124
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1124
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1125 1125
 	}
1126 1126
 
1127
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1127
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1128 1128
 
1129 1129
 	// Set some defaults values...
1130 1130
 	if (!isset($globalAircraftImageSources)) {
1131
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1132
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1131
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1132
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1133 1133
 	}
1134 1134
 
1135 1135
 	if (!isset($globalSchedulesSources)) {
1136
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1137
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1136
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1137
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1138 1138
     	}
1139 1139
 
1140
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1140
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1141 1141
 
1142 1142
 	if ($error == '') settings::modify_settings($settings);
1143 1143
 	if ($error == '') settings::comment_settings($settings_comment);
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.
Braces   +403 added lines, -259 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,12 +108,18 @@  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);
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
+		}
107 114
 		if ($n != 0) {
108 115
 			$registration = str_replace('.','',$registration);
109 116
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
110
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
111
-		} else $message = $data;
117
+			if ($globalDebug) {
118
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
119
+			}
120
+		} else {
121
+			$message = $data;
122
+		}
112 123
 		$icao = '';
113 124
 		$airicao = '';
114 125
 		$decode = array();
@@ -122,12 +133,21 @@  discard block
 block discarded – undo
122 133
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
123 134
 					$latitude = $la / 10000.0;
124 135
 					$longitude = $ln / 10000.0;
125
-					if ($lac == 'S') $latitude = '-'.$latitude;
126
-					if ($lnc == 'W') $longitude = '-'.$longitude;
136
+					if ($lac == 'S') {
137
+						$latitude = '-'.$latitude;
138
+					}
139
+					if ($lnc == 'W') {
140
+						$longitude = '-'.$longitude;
141
+					}
127 142
 					// Temp not always available
128
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
129
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
130
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
143
+					if ($globalDebug) {
144
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
145
+					}
146
+					if ($temp == '') {
147
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
148
+					} else {
149
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
150
+					}
131 151
 
132 152
 					//$icao = $Translation->checkTranslation($ident);
133 153
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -137,25 +157,35 @@  discard block
 block discarded – undo
137 157
 			if (!$found && ($label == '10')) {
138 158
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
139 159
 				if ($n == 4 && strlen($darr) == 4) {
140
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
141
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
142
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
160
+					if ($dhour != '') {
161
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
162
+					}
163
+					if ($ahour != '') {
164
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
165
+					}
166
+					if ($globalDebug) {
167
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
168
+					}
143 169
 					//$icao = ACARS->ident2icao($ident);
144 170
 					//$icao = $Translation->checkTranslation($ident);
145 171
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
146 172
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
147 173
 					$found = true;
148
-				}
149
-				elseif ($n == 2 || $n  == 4) {
150
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
151
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
174
+				} elseif ($n == 2 || $n  == 4) {
175
+					if ($dhour != '') {
176
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
177
+					}
178
+					if ($globalDebug) {
179
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
180
+					}
152 181
 					//$icao = ACARS->ident2icao($ident);
153 182
 					//$icao = $Translation->checkTranslation($ident);
154 183
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
155 184
 					$found = true;
156
-				}
157
-				elseif ($n == 1) {
158
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
185
+				} elseif ($n == 1) {
186
+					if ($globalDebug) {
187
+						echo 'airport arrival : '.$darr."\n";
188
+					}
159 189
 					//$icao = ACARS->ident2icao($ident);
160 190
 					//$icao = $Translation->checkTranslation($ident);
161 191
 					$decode = array('Arrival airport' => $darr);
@@ -172,7 +202,9 @@  discard block
 block discarded – undo
172 202
 
173 203
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
174 204
 				if ($n == 4) {
175
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
205
+					if ($globalDebug) {
206
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
207
+					}
176 208
 					//$icao = ACARS->ident2icao($ident);
177 209
 					//$icao = $Translation->checkTranslation($ident);
178 210
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -197,14 +229,23 @@  discard block
 block discarded – undo
197 229
 				//$n = sscanf($message, "%*[0-9A-Z]/%*3d/%4s/%*c\nSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d\n%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
198 230
 				$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);
199 231
 				if ($n > 8) {
200
-					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";
201
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
202
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
232
+					if ($globalDebug) {
233
+						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";
234
+					}
235
+					if ($dhour != '') {
236
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
237
+					}
238
+					if ($ahour != '') {
239
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
240
+					}
203 241
 					$icao = trim($aident);
204 242
 
205 243
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
206
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
207
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
244
+					if ($ahour == '') {
245
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
246
+					} else {
247
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
248
+					}
208 249
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
209 250
 					$decode['icao'] = $icao;
210 251
 					$found = true;
@@ -221,9 +262,15 @@  discard block
 block discarded – undo
221 262
 					$lns = $lns.'.'.$lns;
222 263
 					$latitude = $las / 1000.0;
223 264
 					$longitude = $lns / 1000.0;
224
-					if ($lac == 'S') $latitude = '-'.$latitude;
225
-					if ($lnc == 'W') $longitude = '-'.$longitude;
226
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
265
+					if ($lac == 'S') {
266
+						$latitude = '-'.$latitude;
267
+					}
268
+					if ($lnc == 'W') {
269
+						$longitude = '-'.$longitude;
270
+					}
271
+					if ($globalDebug) {
272
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
273
+					}
227 274
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
228 275
 					$found = true;
229 276
 				}
@@ -239,7 +286,9 @@  discard block
 block discarded – undo
239 286
 				*/
240 287
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
241 288
 				if ($n == 4) {
242
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
289
+					if ($globalDebug) {
290
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
291
+					}
243 292
 					//$icao = $Translation->checkTranslation($ident);
244 293
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
245 294
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -250,7 +299,9 @@  discard block
 block discarded – undo
250 299
 				// example message : "Reg. : TS-ION - Ident : TU0634 - Label : 1L - Message : 000442152001337,DTTJ,LFPO,1609"
251 300
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
252 301
 				if ($n == 4) {
253
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
302
+					if ($globalDebug) {
303
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
304
+					}
254 305
 					//$icao = $Translation->checkTranslation($ident);
255 306
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
256 307
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -261,7 +312,9 @@  discard block
 block discarded – undo
261 312
 				// example message : "Reg. : OO-TAH - Ident : 3V042J - Label : 5U - Message : 002AF   EBLG EBBR                     N4621.5E  524.2195"
262 313
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
263 314
 				if ($n == 2) {
264
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
315
+					if ($globalDebug) {
316
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
317
+					}
265 318
 					//$icao = $Translation->checkTranslation($ident);
266 319
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
267 320
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -273,7 +326,9 @@  discard block
 block discarded – undo
273 326
 				// example message : 'Reg. : F-GHQJ - Ident : AF6241 - Label : H1 - Message : #DFBA01/CCF-GHQJ,FEB27,205556,LFMN,LFPO,0241/C106,17404,5000,42,0010,0,0100,42,X/CEN270,36012,257,778,6106,299,B5B7G8/EC731134,42387,01439,41194,12/EE731212,44932,11870,43555,12/N10875,0875,0910,6330,1205,-----'
274 327
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
275 328
 				if ($n == 6) {
276
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
329
+					if ($globalDebug) {
330
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
331
+					}
277 332
 					//$icao = $Translation->checkTranslation($ident);
278 333
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
279 334
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -284,7 +339,9 @@  discard block
 block discarded – undo
284 339
 				// example message : 'Reg. : F-GUGP - Ident : AF1842 - Label : H1 - Message : #DFBA01/A31801,1,1/CCF-GUGP,MAR11,093856,LFPG,LSGG,1842/C106,55832,5000,37,0010,0,0100,37,X/CEN282,31018,277,750,5515,255,C11036/EC577870,02282,07070,01987,73,14/EE577871,02282,06947,01987,73/N10790,0790,0903,5'
285 340
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
286 341
 				if ($n == 7) {
287
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
342
+					if ($globalDebug) {
343
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
344
+					}
288 345
 					//$icao = $Translation->checkTranslation($ident);
289 346
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
290 347
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -304,8 +361,12 @@  discard block
 block discarded – undo
304 361
 					$decode['icao'] = $icao;
305 362
 					$latitude = $las / 100.0;
306 363
 					$longitude = $lns / 100.0;
307
-					if ($lac == 'S') $latitude = '-'.$latitude;
308
-					if ($lnc == 'W') $longitude = '-'.$longitude;
364
+					if ($lac == 'S') {
365
+						$latitude = '-'.$latitude;
366
+					}
367
+					if ($lnc == 'W') {
368
+						$longitude = '-'.$longitude;
369
+					}
309 370
 
310 371
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
311 372
 					$found = true;
@@ -319,8 +380,12 @@  discard block
 block discarded – undo
319 380
 				if ($n == 4) {
320 381
 					$latitude = $las;
321 382
 					$longitude = $lns;
322
-					if ($lac == 'S') $latitude = '-'.$latitude;
323
-					if ($lnc == 'W') $longitude = '-'.$longitude;
383
+					if ($lac == 'S') {
384
+						$latitude = '-'.$latitude;
385
+					}
386
+					if ($lnc == 'W') {
387
+						$longitude = '-'.$longitude;
388
+					}
324 389
 
325 390
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
326 391
 					$found = true;
@@ -334,7 +399,9 @@  discard block
 block discarded – undo
334 399
 				*/
335 400
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
336 401
 				if ($n == 5) {
337
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
402
+					if ($globalDebug) {
403
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
404
+					}
338 405
 					//$icao = $Translation->checkTranslation($ident);
339 406
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
340 407
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -352,7 +419,9 @@  discard block
 block discarded – undo
352 419
 //    	    $n = sscanf($message, "%*[0-9A-Z],,\n%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,\n%*4[A-Z],\n%[0-9A-Z],", $dair, $darr, $aident);
353 420
 				$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);
354 421
 				if ($n == 8) {
355
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
422
+					if ($globalDebug) {
423
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
424
+					}
356 425
 					$icao = trim($aident);
357 426
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
358 427
 					$decode['icao'] = $icao;
@@ -367,7 +436,9 @@  discard block
 block discarded – undo
367 436
 				*/
368 437
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
369 438
 				if ($n == 5) {
370
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
439
+					if ($globalDebug) {
440
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
441
+					}
371 442
 					//$icao = $Translation->checkTranslation($ident);
372 443
 
373 444
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -381,7 +452,9 @@  discard block
 block discarded – undo
381 452
 				*/
382 453
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
383 454
 				if ($n == 3) {
384
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
455
+					if ($globalDebug) {
456
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
457
+					}
385 458
 					//$icao = $Translation->checkTranslation($ident);
386 459
 
387 460
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -395,7 +468,9 @@  discard block
 block discarded – undo
395 468
 				*/
396 469
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
397 470
 				if ($n == 3) {
398
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
471
+					if ($globalDebug) {
472
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
473
+					}
399 474
 					//$icao = $Translation->checkTranslation($ident);
400 475
 
401 476
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -406,7 +481,9 @@  discard block
 block discarded – undo
406 481
 			if (!$found) {
407 482
 				$n = sscanf($message,'MET01%4c',$airport);
408 483
 				if ($n == 1) {
409
-					if ($globalDebug) echo 'airport name : '.$airport;
484
+					if ($globalDebug) {
485
+						echo 'airport name : '.$airport;
486
+					}
410 487
 					$decode = array('Airport/Waypoint name' => $airport);
411 488
 					$found = true;
412 489
 				}
@@ -415,184 +492,126 @@  discard block
 block discarded – undo
415 492
 			if ($label == 'H1') {
416 493
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
417 494
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
418
-				}
419
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
495
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
420 496
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
421
-				}
422
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
497
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
423 498
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
424
-				}
425
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
499
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
426 500
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
427
-				}
428
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
501
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
429 502
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
430
-				}
431
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
503
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
432 504
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
433
-				}
434
-				elseif (preg_match(':^#M1AAEP:',$message)) {
505
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
435 506
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
436
-				}
437
-				elseif (preg_match(':^#M2APWD:',$message)) {
507
+				} elseif (preg_match(':^#M2APWD:',$message)) {
438 508
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
439
-				}
440
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
509
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
441 510
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
442
-				}
443
-				elseif (preg_match(':^#CF:',$message)) {
511
+				} elseif (preg_match(':^#CF:',$message)) {
444 512
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
445
-				}
446
-				elseif (preg_match(':^#DF:',$message)) {
513
+				} elseif (preg_match(':^#DF:',$message)) {
447 514
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
448
-				}
449
-				elseif (preg_match(':^#EC:',$message)) {
515
+				} elseif (preg_match(':^#EC:',$message)) {
450 516
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
451
-				}
452
-				elseif (preg_match(':^#EI:',$message)) {
517
+				} elseif (preg_match(':^#EI:',$message)) {
453 518
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
454
-				}
455
-				elseif (preg_match(':^#H1:',$message)) {
519
+				} elseif (preg_match(':^#H1:',$message)) {
456 520
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
457
-				}
458
-				elseif (preg_match(':^#H2:',$message)) {
521
+				} elseif (preg_match(':^#H2:',$message)) {
459 522
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
460
-				}
461
-				elseif (preg_match(':^#HD:',$message)) {
523
+				} elseif (preg_match(':^#HD:',$message)) {
462 524
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
463
-				}
464
-				elseif (preg_match(':^#M1:',$message)) {
525
+				} elseif (preg_match(':^#M1:',$message)) {
465 526
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
466
-				}
467
-				elseif (preg_match(':^#M2:',$message)) {
527
+				} elseif (preg_match(':^#M2:',$message)) {
468 528
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
469
-				}
470
-				elseif (preg_match(':^#M3:',$message)) {
529
+				} elseif (preg_match(':^#M3:',$message)) {
471 530
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
472
-				}
473
-				elseif (preg_match(':^#MD:',$message)) {
531
+				} elseif (preg_match(':^#MD:',$message)) {
474 532
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
475
-				}
476
-				elseif (preg_match(':^#PS:',$message)) {
533
+				} elseif (preg_match(':^#PS:',$message)) {
477 534
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
478
-				}
479
-				elseif (preg_match(':^#S1:',$message)) {
535
+				} elseif (preg_match(':^#S1:',$message)) {
480 536
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
481
-				}
482
-				elseif (preg_match(':^#S2:',$message)) {
537
+				} elseif (preg_match(':^#S2:',$message)) {
483 538
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
484
-				}
485
-				elseif (preg_match(':^#SD:',$message)) {
539
+				} elseif (preg_match(':^#SD:',$message)) {
486 540
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
487
-				}
488
-				elseif (preg_match(':^#T[0-8]:',$message)) {
541
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
489 542
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
490
-				}
491
-				elseif (preg_match(':^#WO:',$message)) {
543
+				} elseif (preg_match(':^#WO:',$message)) {
492 544
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
493
-				}
494
-				elseif (preg_match(':^#A1:',$message)) {
545
+				} elseif (preg_match(':^#A1:',$message)) {
495 546
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
496
-				}
497
-				elseif (preg_match(':^#A3:',$message)) {
547
+				} elseif (preg_match(':^#A3:',$message)) {
498 548
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
499
-				}
500
-				elseif (preg_match(':^#A4:',$message)) {
549
+				} elseif (preg_match(':^#A4:',$message)) {
501 550
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
502
-				}
503
-				elseif (preg_match(':^#A6:',$message)) {
551
+				} elseif (preg_match(':^#A6:',$message)) {
504 552
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
505
-				}
506
-				elseif (preg_match(':^#A8:',$message)) {
553
+				} elseif (preg_match(':^#A8:',$message)) {
507 554
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
508
-				}
509
-				elseif (preg_match(':^#A9:',$message)) {
555
+				} elseif (preg_match(':^#A9:',$message)) {
510 556
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
511
-				}
512
-				elseif (preg_match(':^#A0:',$message)) {
557
+				} elseif (preg_match(':^#A0:',$message)) {
513 558
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
514
-				}
515
-				elseif (preg_match(':^#AA:',$message)) {
559
+				} elseif (preg_match(':^#AA:',$message)) {
516 560
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
517
-				}
518
-				elseif (preg_match(':^#AB:',$message)) {
561
+				} elseif (preg_match(':^#AB:',$message)) {
519 562
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
520
-				}
521
-				elseif (preg_match(':^#AC:',$message)) {
563
+				} elseif (preg_match(':^#AC:',$message)) {
522 564
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
523
-				}
524
-				elseif (preg_match(':^#AD:',$message)) {
565
+				} elseif (preg_match(':^#AD:',$message)) {
525 566
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
526
-				}
527
-				elseif (preg_match(':^#AF:',$message)) {
567
+				} elseif (preg_match(':^#AF:',$message)) {
528 568
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
529
-				}
530
-				elseif (preg_match(':^#B1:',$message)) {
569
+				} elseif (preg_match(':^#B1:',$message)) {
531 570
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
532
-				}
533
-				elseif (preg_match(':^#B2:',$message)) {
571
+				} elseif (preg_match(':^#B2:',$message)) {
534 572
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
535
-				}
536
-				elseif (preg_match(':^#B3:',$message)) {
573
+				} elseif (preg_match(':^#B3:',$message)) {
537 574
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
538
-				}
539
-				elseif (preg_match(':^#B4:',$message)) {
575
+				} elseif (preg_match(':^#B4:',$message)) {
540 576
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
541
-				}
542
-				elseif (preg_match(':^#B6:',$message)) {
577
+				} elseif (preg_match(':^#B6:',$message)) {
543 578
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
544
-				}
545
-				elseif (preg_match(':^#B8:',$message)) {
579
+				} elseif (preg_match(':^#B8:',$message)) {
546 580
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
547
-				}
548
-				elseif (preg_match(':^#B9:',$message)) {
581
+				} elseif (preg_match(':^#B9:',$message)) {
549 582
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
550
-				}
551
-				elseif (preg_match(':^#B0:',$message)) {
583
+				} elseif (preg_match(':^#B0:',$message)) {
552 584
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
553
-				}
554
-				elseif (preg_match(':^#BA:',$message)) {
585
+				} elseif (preg_match(':^#BA:',$message)) {
555 586
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
556
-				}
557
-				elseif (preg_match(':^#BB:',$message)) {
587
+				} elseif (preg_match(':^#BB:',$message)) {
558 588
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
559
-				}
560
-				elseif (preg_match(':^#BC:',$message)) {
589
+				} elseif (preg_match(':^#BC:',$message)) {
561 590
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
562
-				}
563
-				elseif (preg_match(':^#BD:',$message)) {
591
+				} elseif (preg_match(':^#BD:',$message)) {
564 592
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
565
-				}
566
-				elseif (preg_match(':^#BE:',$message)) {
593
+				} elseif (preg_match(':^#BE:',$message)) {
567 594
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
568
-				}
569
-				elseif (preg_match(':^#BF:',$message)) {
595
+				} elseif (preg_match(':^#BF:',$message)) {
570 596
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
571
-				}
572
-				elseif (preg_match(':^#H3:',$message)) {
597
+				} elseif (preg_match(':^#H3:',$message)) {
573 598
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
574 599
 				}
575 600
 			}
576 601
 			if ($label == '10') {
577 602
 				if (preg_match(':^DTO01:',$message)) {
578 603
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
579
-				}
580
-				elseif (preg_match(':^AIS01:',$message)) {
604
+				} elseif (preg_match(':^AIS01:',$message)) {
581 605
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
582
-				}
583
-				elseif (preg_match(':^FTX01:',$message)) {
606
+				} elseif (preg_match(':^FTX01:',$message)) {
584 607
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
585
-				}
586
-				elseif (preg_match(':^FPL01:',$message)) {
608
+				} elseif (preg_match(':^FPL01:',$message)) {
587 609
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
588
-				}
589
-				elseif (preg_match(':^WAB01:',$message)) {
610
+				} elseif (preg_match(':^WAB01:',$message)) {
590 611
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
591
-				}
592
-				elseif (preg_match(':^MET01:',$message)) {
612
+				} elseif (preg_match(':^MET01:',$message)) {
593 613
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
594
-				}
595
-				elseif (preg_match(':^WAB02:',$message)) {
614
+				} elseif (preg_match(':^WAB02:',$message)) {
596 615
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
597 616
 				}
598 617
 			}
@@ -607,38 +626,28 @@  discard block
 block discarded – undo
607 626
 					$vsta = array('Version' => $version);
608 627
 					if ($state == 'E') {
609 628
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
610
-					}
611
-					elseif ($state == 'L') {
629
+					} elseif ($state == 'L') {
612 630
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
613
-					}
614
-					else {
631
+					} else {
615 632
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
616 633
 					}
617 634
 					if ($type == 'V') {
618 635
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
619
-					}
620
-					elseif ($type == 'S') {
636
+					} elseif ($type == 'S') {
621 637
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
622
-					}
623
-					elseif ($type == 'H') {
638
+					} elseif ($type == 'H') {
624 639
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
625
-					}
626
-					elseif ($type == 'G') {
640
+					} elseif ($type == 'G') {
627 641
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
628
-					}
629
-					elseif ($type == 'C') {
642
+					} elseif ($type == 'C') {
630 643
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
631
-					}
632
-					elseif ($type == '2') {
644
+					} elseif ($type == '2') {
633 645
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
634
-					}
635
-					elseif ($type == 'X') {
646
+					} elseif ($type == 'X') {
636 647
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
637
-					}
638
-					elseif ($type == 'I') {
648
+					} elseif ($type == 'I') {
639 649
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
640
-					}
641
-					else {
650
+					} else {
642 651
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
643 652
 					}
644 653
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -647,7 +656,9 @@  discard block
 block discarded – undo
647 656
 			}
648 657
 
649 658
 			$title = $this->getTitlefromLabel($label);
650
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
659
+			if ($title != '') {
660
+				$decode = array_merge(array('Message title' => $title),$decode);
661
+			}
651 662
 
652 663
 			/*
653 664
 			// Business jets always use GS0001
@@ -688,14 +699,26 @@  discard block
 block discarded – undo
688 699
 			$decode = $message['decode'];
689 700
 			$registration = $message['registration'];
690 701
 		
691
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
692
-			else $latitude = '';
693
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
694
-			else $longitude = '';
695
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
696
-			else $airicao = '';
697
-			if (isset($decode['icao'])) $icao = $decode['icao'];
698
-			else $icao = $Translation->checkTranslation($ident);
702
+			if (isset($decode['latitude'])) {
703
+				$latitude = $decode['latitude'];
704
+			} else {
705
+				$latitude = '';
706
+			}
707
+			if (isset($decode['longitude'])) {
708
+				$longitude = $decode['longitude'];
709
+			} else {
710
+				$longitude = '';
711
+			}
712
+			if (isset($decode['airicao'])) {
713
+				$airicao = $decode['airicao'];
714
+			} else {
715
+				$airicao = '';
716
+			}
717
+			if (isset($decode['icao'])) {
718
+				$icao = $decode['icao'];
719
+			} else {
720
+				$icao = $Translation->checkTranslation($ident);
721
+			}
699 722
 		
700 723
 			$image_array = $Image->getSpotterImage($registration);
701 724
 			if (!isset($image_array[0]['registration'])) {
@@ -703,11 +726,18 @@  discard block
 block discarded – undo
703 726
 			}
704 727
 		
705 728
 			// Business jets always use GS0001
706
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
707
-			if ($globalDebug && isset($info) && $info != '') echo $info;
729
+			if ($ident != 'GS0001') {
730
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
731
+			}
732
+			if ($globalDebug && isset($info) && $info != '') {
733
+				echo $info;
734
+			}
708 735
 
709
-			if (count($decode) > 0) $decode_json = json_encode($decode);
710
-			else $decode_json = '';
736
+			if (count($decode) > 0) {
737
+				$decode_json = json_encode($decode);
738
+			} else {
739
+				$decode_json = '';
740
+			}
711 741
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
712 742
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
713 743
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
@@ -715,8 +745,12 @@  discard block
 block discarded – undo
715 745
 			}
716 746
 
717 747
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
718
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
719
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
748
+			if (!isset($globalACARSArchive)) {
749
+				$globalACARSArchive = array('10','80','81','82','3F');
750
+			}
751
+			if ($result && in_array($label,$globalACARSArchive)) {
752
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
753
+			}
720 754
 
721 755
 			if ($globalDebug && count($decode) > 0) {
722 756
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
@@ -741,7 +775,9 @@  discard block
 block discarded – undo
741 775
 			$Connection = new Connection($this->db);
742 776
 			$this->db = $Connection->db;
743 777
 
744
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
778
+			if ($globalDebug) {
779
+				echo "Test if not already in Live ACARS table...";
780
+			}
745 781
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
746 782
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
747 783
 			try {
@@ -751,7 +787,9 @@  discard block
 block discarded – undo
751 787
 				return "error : ".$e->getMessage();
752 788
 			}
753 789
 			if ($stht->fetchColumn() == 0) {
754
-				if ($globalDebug) echo "Add Live ACARS data...";
790
+				if ($globalDebug) {
791
+					echo "Add Live ACARS data...";
792
+				}
755 793
 				$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)";
756 794
 				$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"));
757 795
 				try {
@@ -762,10 +800,14 @@  discard block
 block discarded – undo
762 800
 					return "error : ".$e->getMessage();
763 801
 				}
764 802
 			} else {
765
-				if ($globalDebug) echo "Data already in DB...\n";
803
+				if ($globalDebug) {
804
+					echo "Data already in DB...\n";
805
+				}
766 806
 				return false;
767 807
 			}
768
-			if ($globalDebug) echo "Done\n";
808
+			if ($globalDebug) {
809
+				echo "Done\n";
810
+			}
769 811
 			return true;
770 812
 		}
771 813
 	}
@@ -797,7 +839,9 @@  discard block
 block discarded – undo
797 839
 			    	    }
798 840
 				    if ($stht->fetchColumn() == 0) {
799 841
 			*/
800
-			if ($globalDebug) echo "Add Live ACARS data...";
842
+			if ($globalDebug) {
843
+				echo "Add Live ACARS data...";
844
+			}
801 845
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
802 846
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
803 847
 			try {
@@ -808,7 +852,9 @@  discard block
 block discarded – undo
808 852
 				return "error : ".$e->getMessage();
809 853
 			}
810 854
 //    	    }
811
-			if ($globalDebug) echo "Done\n";
855
+			if ($globalDebug) {
856
+				echo "Done\n";
857
+			}
812 858
 		}
813 859
 	}
814 860
 
@@ -832,8 +878,11 @@  discard block
 block discarded – undo
832 878
 			die;
833 879
 		}
834 880
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
835
-		if (count($row) > 0) return $row[0]['title'];
836
-		else return '';
881
+		if (count($row) > 0) {
882
+			return $row[0]['title'];
883
+		} else {
884
+			return '';
885
+		}
837 886
 	}
838 887
 
839 888
 	/**
@@ -853,8 +902,11 @@  discard block
 block discarded – undo
853 902
 			die;
854 903
 		}
855 904
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
856
-		if (count($row) > 0) return $row;
857
-		else return array();
905
+		if (count($row) > 0) {
906
+			return $row;
907
+		} else {
908
+			return array();
909
+		}
858 910
 	}
859 911
 
860 912
 	/**
@@ -875,8 +927,11 @@  discard block
 block discarded – undo
875 927
 			die;
876 928
 		}
877 929
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
878
-		if (count($row) > 0) return $row[0];
879
-		else return array();
930
+		if (count($row) > 0) {
931
+			return $row[0];
932
+		} else {
933
+			return array();
934
+		}
880 935
 	}
881 936
 
882 937
 	/**
@@ -928,20 +983,36 @@  discard block
 block discarded – undo
928 983
 			if ($row['registration'] != '') {
929 984
 				$row['registration'] = str_replace('.','',$row['registration']);
930 985
 				$image_array = $Image->getSpotterImage($row['registration']);
931
-				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']));
932
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
933
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
934
-			if ($row['registration'] == '') $row['registration'] = 'NA';
935
-			if ($row['ident'] == '') $row['ident'] = 'NA';
986
+				if (count($image_array) > 0) {
987
+					$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']));
988
+				} else {
989
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
990
+				}
991
+			} else {
992
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
+			}
994
+			if ($row['registration'] == '') {
995
+				$row['registration'] = 'NA';
996
+			}
997
+			if ($row['ident'] == '') {
998
+				$row['ident'] = 'NA';
999
+			}
936 1000
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
937 1001
 			if (isset($identicao[0])) {
938 1002
 				if (substr($row['ident'],0,2) == 'AF') {
939
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
940
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
941
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1003
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1004
+						$icao = $row['ident'];
1005
+					} else {
1006
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1007
+					}
1008
+				} else {
1009
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1010
+				}
942 1011
 
943 1012
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
944
-			} else $icao = $row['ident'];
1013
+			} else {
1014
+				$icao = $row['ident'];
1015
+			}
945 1016
 			$icao = $Translation->checkTranslation($icao,false);
946 1017
 
947 1018
 			$decode = json_decode($row['decode'],true);
@@ -967,7 +1038,9 @@  discard block
 block discarded – undo
967 1038
 					$found = true;
968 1039
 				}
969 1040
 			}
970
-			if ($found) $row['decode'] = json_encode($decode);
1041
+			if ($found) {
1042
+				$row['decode'] = json_encode($decode);
1043
+			}
971 1044
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
972 1045
 			$result[] = $data;
973 1046
 			$i++;
@@ -975,8 +1048,9 @@  discard block
 block discarded – undo
975 1048
 		if (isset($result)) {
976 1049
 			$result[0]['query_number_rows'] = $i;
977 1050
 			return $result;
1051
+		} else {
1052
+			return array();
978 1053
 		}
979
-		else return array();
980 1054
 	}
981 1055
 
982 1056
 	/**
@@ -1036,20 +1110,36 @@  discard block
 block discarded – undo
1036 1110
 			if ($row['registration'] != '') {
1037 1111
 				$row['registration'] = str_replace('.','',$row['registration']);
1038 1112
 				$image_array = $Image->getSpotterImage($row['registration']);
1039
-				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']));
1040
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1041
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1113
+				if (count($image_array) > 0) {
1114
+					$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']));
1115
+				} else {
1116
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1117
+				}
1118
+			} else {
1119
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1120
+			}
1042 1121
 			$icao = '';
1043
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1044
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1122
+			if ($row['registration'] == '') {
1123
+				$row['registration'] = 'NA';
1124
+			}
1125
+			if ($row['ident'] == '') {
1126
+				$row['ident'] = 'NA';
1127
+			}
1045 1128
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1046 1129
 			if (isset($identicao[0])) {
1047 1130
 				if (substr($row['ident'],0,2) == 'AF') {
1048
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1049
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1050
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1131
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1132
+						$icao = $row['ident'];
1133
+					} else {
1134
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1135
+					}
1136
+				} else {
1137
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1138
+				}
1051 1139
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1052
-			} else $icao = $row['ident'];
1140
+			} else {
1141
+				$icao = $row['ident'];
1142
+			}
1053 1143
 			$icao = $Translation->checkTranslation($icao);
1054 1144
 
1055 1145
 
@@ -1057,12 +1147,16 @@  discard block
 block discarded – undo
1057 1147
 			$found = false;
1058 1148
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1059 1149
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1060
-				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>';
1150
+				if (isset($airport_info[0]['icao'])) {
1151
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1152
+				}
1061 1153
 				$found = true;
1062 1154
 			}
1063 1155
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1064 1156
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1065
-				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>';
1157
+				if (isset($airport_info[0]['icao'])) {
1158
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1159
+				}
1066 1160
 				$found = true;
1067 1161
 			}
1068 1162
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1072,7 +1166,9 @@  discard block
 block discarded – undo
1072 1166
 					$found = true;
1073 1167
 				}
1074 1168
 			}
1075
-			if ($found) $row['decode'] = json_encode($decode);
1169
+			if ($found) {
1170
+				$row['decode'] = json_encode($decode);
1171
+			}
1076 1172
 
1077 1173
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1078 1174
 			$result[] = $data;
@@ -1081,7 +1177,9 @@  discard block
 block discarded – undo
1081 1177
 		if (isset($result)) {
1082 1178
 			$result[0]['query_number_rows'] = $i;
1083 1179
 			return $result;
1084
-		} else return array();
1180
+		} else {
1181
+			return array();
1182
+		}
1085 1183
 	}
1086 1184
 
1087 1185
 	/**
@@ -1097,19 +1195,29 @@  discard block
 block discarded – undo
1097 1195
 		$ident = trim($ident);
1098 1196
 		$Translation = new Translation($this->db);
1099 1197
 		$Spotter = new Spotter($this->db);
1100
-		if ($globalDebug) echo "Test if we add ModeS data...";
1198
+		if ($globalDebug) {
1199
+			echo "Test if we add ModeS data...";
1200
+		}
1101 1201
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1102
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1103
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1202
+		if ($icao == '') {
1203
+			$icao = $Translation->checkTranslation($ident);
1204
+		}
1205
+		if ($globalDebug) {
1206
+			echo '- Ident : '.$icao.' - ';
1207
+		}
1104 1208
 		if ($ident == '' || $registration == '') {
1105
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1209
+			if ($globalDebug) {
1210
+				echo "Ident or registration null, exit\n";
1211
+			}
1106 1212
 			return '';
1107 1213
 		}
1108 1214
 
1109 1215
 		$registration = str_replace('.','',$registration);
1110 1216
 		$ident = $Translation->ident2icao($ident);
1111 1217
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1112
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1218
+		if ($globalDebug) {
1219
+			echo "Check if needed to add translation ".$ident.'... ';
1220
+		}
1113 1221
 		$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";
1114 1222
 		$querysi_values = array(':registration' => $registration);
1115 1223
 		try {
@@ -1117,7 +1225,9 @@  discard block
 block discarded – undo
1117 1225
 			$sthsi = $this->db->prepare($querysi);
1118 1226
 			$sthsi->execute($querysi_values);
1119 1227
 		} catch(PDOException $e) {
1120
-			if ($globalDebug) echo $e->getMessage();
1228
+			if ($globalDebug) {
1229
+				echo $e->getMessage();
1230
+			}
1121 1231
 			return "error : ".$e->getMessage();
1122 1232
 		}
1123 1233
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1125,9 +1235,14 @@  discard block
 block discarded – undo
1125 1235
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1126 1236
 			$Translation = new Translation($this->db);
1127 1237
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1128
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1129
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1130
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1238
+			if ($globalDebug) {
1239
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1240
+			}
1241
+			if ($ident != $trans_ident) {
1242
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1243
+			} elseif ($trans_ident == $ident) {
1244
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1245
+			}
1131 1246
 		} else {
1132 1247
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1133 1248
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1136,17 +1251,24 @@  discard block
 block discarded – undo
1136 1251
 					$sth = $this->db->prepare($query);
1137 1252
 					$sth->execute($query_values);
1138 1253
 				} catch(PDOException $e) {
1139
-					if ($globalDebug) echo $e->getMessage();
1254
+					if ($globalDebug) {
1255
+						echo $e->getMessage();
1256
+					}
1140 1257
 					return "error : ".$e->getMessage();
1141 1258
 				}
1142 1259
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1143
-				if (isset($result['modes'])) $hex = $result['modes'];
1144
-				else $hex = '';
1260
+				if (isset($result['modes'])) {
1261
+					$hex = $result['modes'];
1262
+				} else {
1263
+					$hex = '';
1264
+				}
1145 1265
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1146 1266
 				$this->SI->add($SI_data);
1147 1267
 			}
1148 1268
 		}
1149
-		if ($globalDebug) echo 'Done'."\n";
1269
+		if ($globalDebug) {
1270
+			echo 'Done'."\n";
1271
+		}
1150 1272
 
1151 1273
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1152 1274
 		$query_values = array(':ident' => $icao);
@@ -1155,14 +1277,19 @@  discard block
 block discarded – undo
1155 1277
 			$sth = $this->db->prepare($query);
1156 1278
 			$sth->execute($query_values);
1157 1279
 		} catch(PDOException $e) {
1158
-			if ($globalDebug) echo $e->getMessage();
1280
+			if ($globalDebug) {
1281
+				echo $e->getMessage();
1282
+			}
1159 1283
 			return "error : ".$e->getMessage();
1160 1284
 		}
1161 1285
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1162 1286
 		//print_r($result);
1163 1287
 		if (isset($result['flightaware_id'])) {
1164
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1165
-			else $ModeS = '';
1288
+			if (isset($result['ModeS'])) {
1289
+				$ModeS = $result['ModeS'];
1290
+			} else {
1291
+				$ModeS = '';
1292
+			}
1166 1293
 			if ($ModeS == '') {
1167 1294
 				$id = explode('-',$result['flightaware_id']);
1168 1295
 				$ModeS = $id[0];
@@ -1176,13 +1303,17 @@  discard block
 block discarded – undo
1176 1303
 					$sthc = $this->db->prepare($queryc);
1177 1304
 					$sthc->execute($queryc_values);
1178 1305
 				} catch(PDOException $e) {
1179
-					if ($globalDebug) echo $e->getMessage();
1306
+					if ($globalDebug) {
1307
+						echo $e->getMessage();
1308
+					}
1180 1309
 					return "error : ".$e->getMessage();
1181 1310
 				}
1182 1311
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1183 1312
 
1184 1313
 				if (count($row) ==  0) {
1185
-					if ($globalDebug) echo " Add to ModeS table - ";
1314
+					if ($globalDebug) {
1315
+						echo " Add to ModeS table - ";
1316
+					}
1186 1317
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1187 1318
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1188 1319
 					try {
@@ -1190,11 +1321,15 @@  discard block
 block discarded – undo
1190 1321
 						$sthi = $this->db->prepare($queryi);
1191 1322
 						$sthi->execute($queryi_values);
1192 1323
 					} catch(PDOException $e) {
1193
-						if ($globalDebug) echo $e->getMessage();
1324
+						if ($globalDebug) {
1325
+							echo $e->getMessage();
1326
+						}
1194 1327
 						return "error : ".$e->getMessage();
1195 1328
 					}
1196 1329
 				} else {
1197
-					if ($globalDebug) echo " Update ModeS table - ";
1330
+					if ($globalDebug) {
1331
+						echo " Update ModeS table - ";
1332
+					}
1198 1333
 					if ($ICAOTypeCode != '') {
1199 1334
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1200 1335
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1207,7 +1342,9 @@  discard block
 block discarded – undo
1207 1342
 						$sthi = $this->db->prepare($queryi);
1208 1343
 						$sthi->execute($queryi_values);
1209 1344
 					} catch(PDOException $e) {
1210
-						if ($globalDebug) echo $e->getMessage();
1345
+						if ($globalDebug) {
1346
+							echo $e->getMessage();
1347
+						}
1211 1348
 						return "error : ".$e->getMessage();
1212 1349
 					}
1213 1350
 				}
@@ -1229,7 +1366,9 @@  discard block
 block discarded – undo
1229 1366
 					    return "error : ".$e->getMessage();
1230 1367
 				}
1231 1368
 				*/
1232
-				if ($globalDebug) echo " Update Spotter_output table - ";
1369
+				if ($globalDebug) {
1370
+					echo " Update Spotter_output table - ";
1371
+				}
1233 1372
 				if ($ICAOTypeCode != '') {
1234 1373
 					if ($globalDBdriver == 'mysql') {
1235 1374
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1240,8 +1379,7 @@  discard block
 block discarded – undo
1240 1379
 				} else {
1241 1380
 					if ($globalDBdriver == 'mysql') {
1242 1381
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1243
-					}
1244
-					elseif ($globalDBdriver == 'pgsql') {
1382
+					} elseif ($globalDBdriver == 'pgsql') {
1245 1383
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1246 1384
 					}
1247 1385
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1251,15 +1389,21 @@  discard block
 block discarded – undo
1251 1389
 					$sthi = $this->db->prepare($queryi);
1252 1390
 					$sthi->execute($queryi_values);
1253 1391
 				} catch(PDOException $e) {
1254
-					if ($globalDebug) echo $e->getMessage();
1392
+					if ($globalDebug) {
1393
+						echo $e->getMessage();
1394
+					}
1255 1395
 					return "error : ".$e->getMessage();
1256 1396
 				}
1257 1397
 
1258 1398
 			}
1259 1399
 		} else {
1260
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1400
+			if ($globalDebug) {
1401
+				echo " Can't find ModeS in spotter_output - ";
1402
+			}
1403
+		}
1404
+		if ($globalDebug) {
1405
+			echo "Done\n";
1261 1406
 		}
1262
-		if ($globalDebug) echo "Done\n";
1263 1407
 	}
1264 1408
 }
1265 1409
 ?>
Please login to merge, or discard this patch.
Spacing   +253 added lines, -253 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,11 +102,11 @@  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);
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 107
 		if ($n != 0) {
108
-			$registration = str_replace('.','',$registration);
109
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
108
+			$registration = str_replace('.', '', $registration);
109
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
110 110
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
111 111
 		} else $message = $data;
112 112
 		$airicao = '';
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 				$temp = '';
128 128
 				$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);
129 129
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
130
-					$latitude = $la / 10000.0;
131
-					$longitude = $ln / 10000.0;
130
+					$latitude = $la/10000.0;
131
+					$longitude = $ln/10000.0;
132 132
 					if ($lac == 'S') $latitude = '-'.$latitude;
133 133
 					if ($lnc == 'W') $longitude = '-'.$longitude;
134 134
 					// Temp not always available
135 135
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
136
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
137
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
136
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
137
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
138 138
 
139 139
 					//$icao = $Translation->checkTranslation($ident);
140 140
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -146,19 +146,19 @@  discard block
 block discarded – undo
146 146
 				$dhour = '';
147 147
 				$darr = '';
148 148
 				$ahour = '';
149
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
149
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
150 150
 				if ($n == 4 && strlen($darr) == 4) {
151
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
152
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
153
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
151
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
152
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
153
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
154 154
 					//$icao = ACARS->ident2icao($ident);
155 155
 					//$icao = $Translation->checkTranslation($ident);
156 156
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
157 157
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
158 158
 					$found = true;
159 159
 				}
160
-				elseif ($n == 2 || $n  == 4) {
161
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
160
+				elseif ($n == 2 || $n == 4) {
161
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
162 162
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
163 163
 					//$icao = ACARS->ident2icao($ident);
164 164
 					//$icao = $Translation->checkTranslation($ident);
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
 				$ahour = '';
217 217
 				$aair = '';
218 218
 				$apiste = '';
219
-				$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);
219
+				$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 220
 				if ($n > 8) {
221
-					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";
222
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
223
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
221
+					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";
222
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
223
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
224 224
 					$icao = trim($aident);
225 225
 
226 226
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -245,8 +245,8 @@  discard block
 block discarded – undo
245 245
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
246 246
 					$las = $las.'.'.$lass;
247 247
 					$lns = $lns.'.'.$lns;
248
-					$latitude = $las / 1000.0;
249
-					$longitude = $lns / 1000.0;
248
+					$latitude = $las/1000.0;
249
+					$longitude = $lns/1000.0;
250 250
 					if ($lac == 'S') $latitude = '-'.$latitude;
251 251
 					if ($lnc == 'W') $longitude = '-'.$longitude;
252 252
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -341,17 +341,17 @@  discard block
 block discarded – undo
341 341
 				$alt = '';
342 342
 				$fuel = '';
343 343
 				$speed = '';
344
-				$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);
344
+				$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 345
 				if ($n == 9) {
346 346
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
347 347
 					$icao = trim($aident);
348 348
 					$decode['icao'] = $icao;
349
-					$latitude = $las / 100.0;
350
-					$longitude = $lns / 100.0;
349
+					$latitude = $las/100.0;
350
+					$longitude = $lns/100.0;
351 351
 					if ($lac == 'S') $latitude = '-'.$latitude;
352 352
 					if ($lnc == 'W') $longitude = '-'.$longitude;
353 353
 
354
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
354
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
355 355
 					$found = true;
356 356
 				}
357 357
 			}
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 					if ($lac == 'S') $latitude = '-'.$latitude;
371 371
 					if ($lnc == 'W') $longitude = '-'.$longitude;
372 372
 
373
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
373
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
374 374
 					$found = true;
375 375
 				}
376 376
 			}
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 				$dair = '';
404 404
 				$darr = '';
405 405
 				$aident = '';
406
-				$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);
406
+				$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 407
 				if ($n == 8) {
408 408
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
409 409
 					$icao = trim($aident);
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 				*/
437 437
 				$dair = '';
438 438
 				$darr = '';
439
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
439
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
440 440
 				if ($n == 3) {
441 441
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
442 442
 					//$icao = $Translation->checkTranslation($ident);
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 				*/
453 453
 				$dair = '';
454 454
 				$darr = '';
455
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
455
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
456 456
 				if ($n == 3) {
457 457
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
458 458
 					//$icao = $Translation->checkTranslation($ident);
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 				}
464 464
 			}
465 465
 			if (!$found) {
466
-				$n = sscanf($message,'MET01%4c',$airport);
466
+				$n = sscanf($message, 'MET01%4c', $airport);
467 467
 				if ($n == 1) {
468 468
 					if ($globalDebug) echo 'airport name : '.$airport;
469 469
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -472,241 +472,241 @@  discard block
 block discarded – undo
472 472
 			}
473 473
 
474 474
 			if ($label == 'H1') {
475
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
476
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
475
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
476
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
477 477
 				}
478
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
479
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
478
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
479
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
480 480
 				}
481
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
482
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
481
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
482
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
483 483
 				}
484
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
485
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
484
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
485
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
486 486
 				}
487
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
488
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
487
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
488
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
489 489
 				}
490
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
491
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
490
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
491
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
492 492
 				}
493
-				elseif (preg_match(':^#M1AAEP:',$message)) {
494
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
493
+				elseif (preg_match(':^#M1AAEP:', $message)) {
494
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
495 495
 				}
496
-				elseif (preg_match(':^#M2APWD:',$message)) {
497
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
496
+				elseif (preg_match(':^#M2APWD:', $message)) {
497
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
498 498
 				}
499
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
500
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
499
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
500
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
501 501
 				}
502
-				elseif (preg_match(':^#CF:',$message)) {
503
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
502
+				elseif (preg_match(':^#CF:', $message)) {
503
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
504 504
 				}
505
-				elseif (preg_match(':^#DF:',$message)) {
506
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
505
+				elseif (preg_match(':^#DF:', $message)) {
506
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
507 507
 				}
508
-				elseif (preg_match(':^#EC:',$message)) {
509
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
508
+				elseif (preg_match(':^#EC:', $message)) {
509
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
510 510
 				}
511
-				elseif (preg_match(':^#EI:',$message)) {
512
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
511
+				elseif (preg_match(':^#EI:', $message)) {
512
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
513 513
 				}
514
-				elseif (preg_match(':^#H1:',$message)) {
515
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
514
+				elseif (preg_match(':^#H1:', $message)) {
515
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
516 516
 				}
517
-				elseif (preg_match(':^#H2:',$message)) {
518
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
517
+				elseif (preg_match(':^#H2:', $message)) {
518
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
519 519
 				}
520
-				elseif (preg_match(':^#HD:',$message)) {
521
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
520
+				elseif (preg_match(':^#HD:', $message)) {
521
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
522 522
 				}
523
-				elseif (preg_match(':^#M1:',$message)) {
524
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
523
+				elseif (preg_match(':^#M1:', $message)) {
524
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
525 525
 				}
526
-				elseif (preg_match(':^#M2:',$message)) {
527
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
526
+				elseif (preg_match(':^#M2:', $message)) {
527
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
528 528
 				}
529
-				elseif (preg_match(':^#M3:',$message)) {
530
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
529
+				elseif (preg_match(':^#M3:', $message)) {
530
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
531 531
 				}
532
-				elseif (preg_match(':^#MD:',$message)) {
533
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
532
+				elseif (preg_match(':^#MD:', $message)) {
533
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
534 534
 				}
535
-				elseif (preg_match(':^#PS:',$message)) {
536
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
535
+				elseif (preg_match(':^#PS:', $message)) {
536
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
537 537
 				}
538
-				elseif (preg_match(':^#S1:',$message)) {
539
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
538
+				elseif (preg_match(':^#S1:', $message)) {
539
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
540 540
 				}
541
-				elseif (preg_match(':^#S2:',$message)) {
542
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
541
+				elseif (preg_match(':^#S2:', $message)) {
542
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
543 543
 				}
544
-				elseif (preg_match(':^#SD:',$message)) {
545
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
544
+				elseif (preg_match(':^#SD:', $message)) {
545
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
546 546
 				}
547
-				elseif (preg_match(':^#T[0-8]:',$message)) {
548
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
547
+				elseif (preg_match(':^#T[0-8]:', $message)) {
548
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
549 549
 				}
550
-				elseif (preg_match(':^#WO:',$message)) {
551
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
550
+				elseif (preg_match(':^#WO:', $message)) {
551
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
552 552
 				}
553
-				elseif (preg_match(':^#A1:',$message)) {
554
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
553
+				elseif (preg_match(':^#A1:', $message)) {
554
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
555 555
 				}
556
-				elseif (preg_match(':^#A3:',$message)) {
557
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
556
+				elseif (preg_match(':^#A3:', $message)) {
557
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
558 558
 				}
559
-				elseif (preg_match(':^#A4:',$message)) {
560
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
559
+				elseif (preg_match(':^#A4:', $message)) {
560
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
561 561
 				}
562
-				elseif (preg_match(':^#A6:',$message)) {
563
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
562
+				elseif (preg_match(':^#A6:', $message)) {
563
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
564 564
 				}
565
-				elseif (preg_match(':^#A8:',$message)) {
566
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
565
+				elseif (preg_match(':^#A8:', $message)) {
566
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
567 567
 				}
568
-				elseif (preg_match(':^#A9:',$message)) {
569
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
568
+				elseif (preg_match(':^#A9:', $message)) {
569
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
570 570
 				}
571
-				elseif (preg_match(':^#A0:',$message)) {
572
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
571
+				elseif (preg_match(':^#A0:', $message)) {
572
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
573 573
 				}
574
-				elseif (preg_match(':^#AA:',$message)) {
575
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
574
+				elseif (preg_match(':^#AA:', $message)) {
575
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
576 576
 				}
577
-				elseif (preg_match(':^#AB:',$message)) {
578
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
577
+				elseif (preg_match(':^#AB:', $message)) {
578
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
579 579
 				}
580
-				elseif (preg_match(':^#AC:',$message)) {
581
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
580
+				elseif (preg_match(':^#AC:', $message)) {
581
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
582 582
 				}
583
-				elseif (preg_match(':^#AD:',$message)) {
584
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
583
+				elseif (preg_match(':^#AD:', $message)) {
584
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
585 585
 				}
586
-				elseif (preg_match(':^#AF:',$message)) {
587
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
586
+				elseif (preg_match(':^#AF:', $message)) {
587
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
588 588
 				}
589
-				elseif (preg_match(':^#B1:',$message)) {
590
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
589
+				elseif (preg_match(':^#B1:', $message)) {
590
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
591 591
 				}
592
-				elseif (preg_match(':^#B2:',$message)) {
593
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
592
+				elseif (preg_match(':^#B2:', $message)) {
593
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
594 594
 				}
595
-				elseif (preg_match(':^#B3:',$message)) {
596
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
595
+				elseif (preg_match(':^#B3:', $message)) {
596
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
597 597
 				}
598
-				elseif (preg_match(':^#B4:',$message)) {
599
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
598
+				elseif (preg_match(':^#B4:', $message)) {
599
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
600 600
 				}
601
-				elseif (preg_match(':^#B6:',$message)) {
602
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
601
+				elseif (preg_match(':^#B6:', $message)) {
602
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
603 603
 				}
604
-				elseif (preg_match(':^#B8:',$message)) {
605
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
604
+				elseif (preg_match(':^#B8:', $message)) {
605
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
606 606
 				}
607
-				elseif (preg_match(':^#B9:',$message)) {
608
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
607
+				elseif (preg_match(':^#B9:', $message)) {
608
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
609 609
 				}
610
-				elseif (preg_match(':^#B0:',$message)) {
611
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
610
+				elseif (preg_match(':^#B0:', $message)) {
611
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
612 612
 				}
613
-				elseif (preg_match(':^#BA:',$message)) {
614
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
613
+				elseif (preg_match(':^#BA:', $message)) {
614
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
615 615
 				}
616
-				elseif (preg_match(':^#BB:',$message)) {
617
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
616
+				elseif (preg_match(':^#BB:', $message)) {
617
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
618 618
 				}
619
-				elseif (preg_match(':^#BC:',$message)) {
620
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
619
+				elseif (preg_match(':^#BC:', $message)) {
620
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
621 621
 				}
622
-				elseif (preg_match(':^#BD:',$message)) {
623
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
622
+				elseif (preg_match(':^#BD:', $message)) {
623
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
624 624
 				}
625
-				elseif (preg_match(':^#BE:',$message)) {
626
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
625
+				elseif (preg_match(':^#BE:', $message)) {
626
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
627 627
 				}
628
-				elseif (preg_match(':^#BF:',$message)) {
629
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
628
+				elseif (preg_match(':^#BF:', $message)) {
629
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
630 630
 				}
631
-				elseif (preg_match(':^#H3:',$message)) {
632
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
631
+				elseif (preg_match(':^#H3:', $message)) {
632
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
633 633
 				}
634 634
 			}
635 635
 			if ($label == '10') {
636
-				if (preg_match(':^DTO01:',$message)) {
637
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
636
+				if (preg_match(':^DTO01:', $message)) {
637
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
638 638
 				}
639
-				elseif (preg_match(':^AIS01:',$message)) {
640
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
639
+				elseif (preg_match(':^AIS01:', $message)) {
640
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
641 641
 				}
642
-				elseif (preg_match(':^FTX01:',$message)) {
643
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
642
+				elseif (preg_match(':^FTX01:', $message)) {
643
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
644 644
 				}
645
-				elseif (preg_match(':^FPL01:',$message)) {
646
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
645
+				elseif (preg_match(':^FPL01:', $message)) {
646
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
647 647
 				}
648
-				elseif (preg_match(':^WAB01:',$message)) {
649
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
648
+				elseif (preg_match(':^WAB01:', $message)) {
649
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
650 650
 				}
651
-				elseif (preg_match(':^MET01:',$message)) {
652
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
651
+				elseif (preg_match(':^MET01:', $message)) {
652
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
653 653
 				}
654
-				elseif (preg_match(':^WAB02:',$message)) {
655
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
654
+				elseif (preg_match(':^WAB02:', $message)) {
655
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
656 656
 				}
657 657
 			}
658 658
 			if ($label == '15') {
659
-				if (preg_match(':^FST01:',$message)) {
660
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
659
+				if (preg_match(':^FST01:', $message)) {
660
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
661 661
 				}
662 662
 			}
663 663
 			if (!$found && $label == 'SA') {
664
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
664
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
665 665
 				if ($n == 4) {
666 666
 					$vsta = array('Version' => $version);
667 667
 					if ($state == 'E') {
668
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
668
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
669 669
 					}
670 670
 					elseif ($state == 'L') {
671
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
671
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
672 672
 					}
673 673
 					else {
674
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
674
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
675 675
 					}
676 676
 					if ($type == 'V') {
677
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
677
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
678 678
 					}
679 679
 					elseif ($type == 'S') {
680
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
680
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
681 681
 					}
682 682
 					elseif ($type == 'H') {
683
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
683
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
684 684
 					}
685 685
 					elseif ($type == 'G') {
686
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
686
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
687 687
 					}
688 688
 					elseif ($type == 'C') {
689
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
689
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
690 690
 					}
691 691
 					elseif ($type == '2') {
692
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
692
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
693 693
 					}
694 694
 					elseif ($type == 'X') {
695
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
695
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
696 696
 					}
697 697
 					elseif ($type == 'I') {
698
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
698
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
699 699
 					}
700 700
 					else {
701
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
701
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
702 702
 					}
703
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
704
-					$decode = array_merge($vsta,$decode);
703
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
704
+					$decode = array_merge($vsta, $decode);
705 705
 				}
706 706
 			}
707 707
 
708 708
 			$title = $this->getTitlefromLabel($label);
709
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
709
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
710 710
 
711 711
 			/*
712 712
 			// Business jets always use GS0001
@@ -739,13 +739,13 @@  discard block
 block discarded – undo
739 739
 		$message = $this->parse($data);
740 740
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
741 741
 		
742
-			$ident = (string)$message['ident'];
742
+			$ident = (string) $message['ident'];
743 743
 			$label = $message['label'];
744 744
 			$block_id = $message['block_id'];
745 745
 			$msg_no = $message['msg_no'];
746 746
 			$msg = $message['message'];
747 747
 			$decode = $message['decode'];
748
-			$registration = (string)$message['registration'];
748
+			$registration = (string) $message['registration'];
749 749
 		
750 750
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
751 751
 			else $latitude = '';
@@ -762,23 +762,23 @@  discard block
 block discarded – undo
762 762
 			}
763 763
 		
764 764
 			// Business jets always use GS0001
765
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
765
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
766 766
 			if ($globalDebug && isset($info) && $info != '') echo $info;
767 767
 
768 768
 			if (count($decode) > 0) $decode_json = json_encode($decode);
769 769
 			else $decode_json = '';
770 770
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
771
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
771
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
772 772
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
773
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
773
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
774 774
 			}
775 775
 
776
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
777
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
778
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
776
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
777
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
778
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
779 779
 
780 780
 			if ($globalDebug && count($decode) > 0) {
781
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
781
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
782 782
 			}
783 783
 		}
784 784
 	}
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 	* @param String $msg_no Number of the ACARS message
794 794
 	* @param String $message ACARS message
795 795
 	*/
796
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
796
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
797 797
 		global $globalDebug;
798 798
 		date_default_timezone_set('UTC');
799 799
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -802,22 +802,22 @@  discard block
 block discarded – undo
802 802
 
803 803
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
804 804
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
805
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
805
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
806 806
 			try {
807 807
 				$stht = $this->db->prepare($query_test);
808 808
 				$stht->execute($query_test_values);
809
-			} catch(PDOException $e) {
809
+			} catch (PDOException $e) {
810 810
 				return "error : ".$e->getMessage();
811 811
 			}
812 812
 			if ($stht->fetchColumn() == 0) {
813 813
 				if ($globalDebug) echo "Add Live ACARS data...";
814 814
 				$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)";
815
-				$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"));
815
+				$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 816
 				try {
817 817
 
818 818
 					$sth = $this->db->prepare($query);
819 819
 					$sth->execute($query_values);
820
-				} catch(PDOException $e) {
820
+				} catch (PDOException $e) {
821 821
 					return "error : ".$e->getMessage();
822 822
 				}
823 823
 			} else {
@@ -839,10 +839,10 @@  discard block
 block discarded – undo
839 839
 	* @param String $msg_no Number of the ACARS message
840 840
 	* @param String $message ACARS message
841 841
 	*/
842
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
842
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
843 843
 		global $globalDebug;
844 844
 		date_default_timezone_set('UTC');
845
-		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) {
845
+		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 846
 			/*
847 847
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
848 848
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -858,12 +858,12 @@  discard block
 block discarded – undo
858 858
 			*/
859 859
 			if ($globalDebug) echo "Add Live ACARS data...";
860 860
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
861
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
861
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
862 862
 			try {
863 863
 
864 864
 				$sth = $this->db->prepare($query);
865 865
 				$sth->execute($query_values);
866
-			} catch(PDOException $e) {
866
+			} catch (PDOException $e) {
867 867
 				return "error : ".$e->getMessage();
868 868
 			}
869 869
 //    	    }
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 
887 887
 			$sth = $this->db->prepare($query);
888 888
 			$sth->execute($query_values);
889
-		} catch(PDOException $e) {
889
+		} catch (PDOException $e) {
890 890
 			echo "error : ".$e->getMessage();
891 891
 			die;
892 892
 		}
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 
908 908
 			$sth = $this->db->prepare($query);
909 909
 			$sth->execute($query_values);
910
-		} catch(PDOException $e) {
910
+		} catch (PDOException $e) {
911 911
 			echo "error : ".$e->getMessage();
912 912
 			die;
913 913
 		}
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 
930 930
 			$sth = $this->db->prepare($query);
931 931
 			$sth->execute($query_values);
932
-		} catch(PDOException $e) {
932
+		} catch (PDOException $e) {
933 933
 			echo "error : ".$e->getMessage();
934 934
 			die;
935 935
 		}
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 	*
944 944
 	* @return Array Return ACARS data in array
945 945
 	*/
946
-	public function getLatestAcarsData($limit = '',$label = '') {
946
+	public function getLatestAcarsData($limit = '', $label = '') {
947 947
 		global $globalURL, $globalDBdriver;
948 948
 		$Image = new Image($this->db);
949 949
 		$Spotter = new Spotter($this->db);
@@ -955,8 +955,8 @@  discard block
 block discarded – undo
955 955
 		{
956 956
 			$limit_array = explode(",", $limit);
957 957
 
958
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
959
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
958
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
959
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
960 960
 
961 961
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
962 962
 			{
@@ -978,48 +978,48 @@  discard block
 block discarded – undo
978 978
 
979 979
 			$sth = $this->db->prepare($query);
980 980
 			$sth->execute($query_values);
981
-		} catch(PDOException $e) {
981
+		} catch (PDOException $e) {
982 982
 			return "error : ".$e->getMessage();
983 983
 		}
984 984
 		$i = 0;
985 985
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
986 986
 			$data = array();
987 987
 			if ($row['registration'] != '') {
988
-				$row['registration'] = str_replace('.','',$row['registration']);
988
+				$row['registration'] = str_replace('.', '', $row['registration']);
989 989
 				$image_array = $Image->getSpotterImage($row['registration']);
990
-				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']));
991
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
992
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
990
+				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']));
991
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
992
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
993 993
 			if ($row['registration'] == '') $row['registration'] = 'NA';
994 994
 			if ($row['ident'] == '') $row['ident'] = 'NA';
995
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
995
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
996 996
 			if (isset($identicao[0])) {
997
-				if (substr($row['ident'],0,2) == 'AF') {
998
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1000
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
997
+				if (substr($row['ident'], 0, 2) == 'AF') {
998
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1000
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1001 1001
 
1002
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1002
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1003 1003
 			} else $icao = $row['ident'];
1004
-			$icao = $Translation->checkTranslation($icao,false);
1004
+			$icao = $Translation->checkTranslation($icao, false);
1005 1005
 
1006
-			$decode = json_decode($row['decode'],true);
1006
+			$decode = json_decode($row['decode'], true);
1007 1007
 			$found = false;
1008
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1008
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1009 1009
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1010 1010
 				if (isset($airport_info[0]['icao'])) {
1011 1011
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1012 1012
 					$found = true;
1013 1013
 				}
1014 1014
 			}
1015
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1015
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1016 1016
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1017 1017
 				if (isset($airport_info[0]['icao'])) {
1018 1018
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1019 1019
 					$found = true;
1020 1020
 				}
1021 1021
 			}
1022
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1022
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1023 1023
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1024 1024
 				if (isset($airport_info[0]['icao'])) {
1025 1025
 					$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>';
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 				}
1028 1028
 			}
1029 1029
 			if ($found) $row['decode'] = json_encode($decode);
1030
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1030
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1031 1031
 			$result[] = $data;
1032 1032
 			$i++;
1033 1033
 		}
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 	*
1044 1044
 	* @return Array Return ACARS data in array
1045 1045
 	*/
1046
-	public function getArchiveAcarsData($limit = '',$label = '') {
1046
+	public function getArchiveAcarsData($limit = '', $label = '') {
1047 1047
 		global $globalURL, $globalDBdriver;
1048 1048
 		$Image = new Image($this->db);
1049 1049
 		$Spotter = new Spotter($this->db);
@@ -1055,8 +1055,8 @@  discard block
 block discarded – undo
1055 1055
 		{
1056 1056
 			$limit_array = explode(",", $limit);
1057 1057
 
1058
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1059
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1058
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1059
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1060 1060
 
1061 1061
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1062 1062
 			{
@@ -1086,45 +1086,45 @@  discard block
 block discarded – undo
1086 1086
 
1087 1087
 			$sth = $this->db->prepare($query);
1088 1088
 			$sth->execute($query_values);
1089
-		} catch(PDOException $e) {
1089
+		} catch (PDOException $e) {
1090 1090
 			return "error : ".$e->getMessage();
1091 1091
 		}
1092
-		$i=0;
1092
+		$i = 0;
1093 1093
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1094 1094
 			$data = array();
1095 1095
 			if ($row['registration'] != '') {
1096
-				$row['registration'] = str_replace('.','',$row['registration']);
1096
+				$row['registration'] = str_replace('.', '', $row['registration']);
1097 1097
 				$image_array = $Image->getSpotterImage($row['registration']);
1098
-				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']));
1099
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1100
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1098
+				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']));
1099
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1100
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1101 1101
 			$icao = '';
1102 1102
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1103 1103
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1104
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1104
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1105 1105
 			if (isset($identicao[0])) {
1106
-				if (substr($row['ident'],0,2) == 'AF') {
1107
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1108
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1109
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1110
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1106
+				if (substr($row['ident'], 0, 2) == 'AF') {
1107
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1108
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1109
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1110
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1111 1111
 			} else $icao = $row['ident'];
1112 1112
 			$icao = $Translation->checkTranslation($icao);
1113 1113
 
1114 1114
 
1115
-			$decode = json_decode($row['decode'],true);
1115
+			$decode = json_decode($row['decode'], true);
1116 1116
 			$found = false;
1117
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1117
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1118 1118
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1119 1119
 				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>';
1120 1120
 				$found = true;
1121 1121
 			}
1122
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1122
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1123 1123
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1124 1124
 				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>';
1125 1125
 				$found = true;
1126 1126
 			}
1127
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1127
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1128 1128
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1129 1129
 				if (isset($airport_info[0]['icao'])) {
1130 1130
 					$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>';
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 			}
1134 1134
 			if ($found) $row['decode'] = json_encode($decode);
1135 1135
 
1136
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1136
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1137 1137
 			$result[] = $data;
1138 1138
 			$i++;
1139 1139
 		}
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 	* @param String $icao
1152 1152
 	* @param String $ICAOTypeCode
1153 1153
 	*/
1154
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1154
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1155 1155
 		global $globalDebug, $globalDBdriver;
1156 1156
 		$ident = trim($ident);
1157 1157
 		$Translation = new Translation($this->db);
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 			return '';
1166 1166
 		}
1167 1167
 
1168
-		$registration = str_replace('.','',$registration);
1168
+		$registration = str_replace('.', '', $registration);
1169 1169
 		$ident = $Translation->ident2icao($ident);
1170 1170
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1171 1171
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 
1176 1176
 			$sthsi = $this->db->prepare($querysi);
1177 1177
 			$sthsi->execute($querysi_values);
1178
-		} catch(PDOException $e) {
1178
+		} catch (PDOException $e) {
1179 1179
 			if ($globalDebug) echo $e->getMessage();
1180 1180
 			return "error : ".$e->getMessage();
1181 1181
 		}
@@ -1185,8 +1185,8 @@  discard block
 block discarded – undo
1185 1185
 			$Translation = new Translation($this->db);
1186 1186
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1187 1187
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1188
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1189
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1188
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1189
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1190 1190
 		} else {
1191 1191
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1192 1192
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1194,14 +1194,14 @@  discard block
 block discarded – undo
1194 1194
 				try {
1195 1195
 					$sth = $this->db->prepare($query);
1196 1196
 					$sth->execute($query_values);
1197
-				} catch(PDOException $e) {
1197
+				} catch (PDOException $e) {
1198 1198
 					if ($globalDebug) echo $e->getMessage();
1199 1199
 					return "error : ".$e->getMessage();
1200 1200
 				}
1201 1201
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1202 1202
 				if (isset($result['modes'])) $hex = $result['modes'];
1203 1203
 				else $hex = '';
1204
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1204
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1205 1205
 				$this->SI->add($SI_data);
1206 1206
 			}
1207 1207
 		}
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
 
1214 1214
 			$sth = $this->db->prepare($query);
1215 1215
 			$sth->execute($query_values);
1216
-		} catch(PDOException $e) {
1216
+		} catch (PDOException $e) {
1217 1217
 			if ($globalDebug) echo $e->getMessage();
1218 1218
 			return "error : ".$e->getMessage();
1219 1219
 		}
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1224 1224
 			else $ModeS = '';
1225 1225
 			if ($ModeS == '') {
1226
-				$id = explode('-',$result['flightaware_id']);
1226
+				$id = explode('-', $result['flightaware_id']);
1227 1227
 				$ModeS = $id[0];
1228 1228
 			}
1229 1229
 			if ($ModeS != '') {
@@ -1234,21 +1234,21 @@  discard block
 block discarded – undo
1234 1234
 
1235 1235
 					$sthc = $this->db->prepare($queryc);
1236 1236
 					$sthc->execute($queryc_values);
1237
-				} catch(PDOException $e) {
1237
+				} catch (PDOException $e) {
1238 1238
 					if ($globalDebug) echo $e->getMessage();
1239 1239
 					return "error : ".$e->getMessage();
1240 1240
 				}
1241 1241
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1242 1242
 
1243
-				if (count($row) ==  0) {
1243
+				if (count($row) == 0) {
1244 1244
 					if ($globalDebug) echo " Add to ModeS table - ";
1245 1245
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1246
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1246
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1247 1247
 					try {
1248 1248
 
1249 1249
 						$sthi = $this->db->prepare($queryi);
1250 1250
 						$sthi->execute($queryi_values);
1251
-					} catch(PDOException $e) {
1251
+					} catch (PDOException $e) {
1252 1252
 						if ($globalDebug) echo $e->getMessage();
1253 1253
 						return "error : ".$e->getMessage();
1254 1254
 					}
@@ -1256,16 +1256,16 @@  discard block
 block discarded – undo
1256 1256
 					if ($globalDebug) echo " Update ModeS table - ";
1257 1257
 					if ($ICAOTypeCode != '') {
1258 1258
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1259
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1259
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1260 1260
 					} else {
1261 1261
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1262
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1262
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1263 1263
 					}
1264 1264
 					try {
1265 1265
 
1266 1266
 						$sthi = $this->db->prepare($queryi);
1267 1267
 						$sthi->execute($queryi_values);
1268
-					} catch(PDOException $e) {
1268
+					} catch (PDOException $e) {
1269 1269
 						if ($globalDebug) echo $e->getMessage();
1270 1270
 						return "error : ".$e->getMessage();
1271 1271
 					}
@@ -1303,13 +1303,13 @@  discard block
 block discarded – undo
1303 1303
 					elseif ($globalDBdriver == 'pgsql') {
1304 1304
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1305 1305
 					}
1306
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1306
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1307 1307
 				}
1308 1308
 				try {
1309 1309
 
1310 1310
 					$sthi = $this->db->prepare($queryi);
1311 1311
 					$sthi->execute($queryi_values);
1312
-				} catch(PDOException $e) {
1312
+				} catch (PDOException $e) {
1313 1313
 					if ($globalDebug) echo $e->getMessage();
1314 1314
 					return "error : ".$e->getMessage();
1315 1315
 				}
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.
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
27
+		$query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright
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 $globalAircraftCustomSources;
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.
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.
require/class.SpotterArchive.php 3 patches
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,10 +14,17 @@  discard block
 block discarded – undo
14 14
 		if ($over_country == '') {
15 15
 			$Spotter = new Spotter($this->db);
16 16
 			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
17
-			if (!empty($data_country)) $country = $data_country['iso2'];
18
-			else $country = '';
19
-		} else $country = $over_country;
20
-		if ($airline_type === NULL) $airline_type ='';
17
+			if (!empty($data_country)) {
18
+				$country = $data_country['iso2'];
19
+			} else {
20
+				$country = '';
21
+			}
22
+		} else {
23
+			$country = $over_country;
24
+		}
25
+		if ($airline_type === NULL) {
26
+			$airline_type ='';
27
+		}
21 28
 	
22 29
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
23 30
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
@@ -502,7 +509,9 @@  discard block
 block discarded – undo
502 509
 		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
503 510
 		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
504 511
 		    $translate = $Translation->ident2icao($q_item);
505
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
512
+		    if ($translate != $q_item) {
513
+		    	$additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
514
+		    }
506 515
 		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
507 516
 		    $additional_query .= ")";
508 517
 		}
@@ -720,7 +729,9 @@  discard block
 block discarded – undo
720 729
 		date_default_timezone_set($globalTimezone);
721 730
 		$datetime = new DateTime();
722 731
 		$offset = $datetime->format('P');
723
-	    } else $offset = '+00:00';
732
+	    } else {
733
+	    	$offset = '+00:00';
734
+	    }
724 735
 
725 736
 
726 737
 	    if ($date_array[1] != "")
@@ -883,9 +894,13 @@  discard block
 block discarded – undo
883 894
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
884 895
 			}
885 896
 		}
886
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
897
+                if ($sincedate != '') {
898
+                	$query .= "AND date > '".$sincedate."' ";
899
+                }
887 900
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
888
-	if ($limit) $query .= " LIMIT 0,10";
901
+	if ($limit) {
902
+		$query .= " LIMIT 0,10";
903
+	}
889 904
       
890 905
 	
891 906
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
Indentation   +502 added lines, -502 removed lines patch added patch discarded remove patch
@@ -57,44 +57,44 @@  discard block
 block discarded – undo
57 57
 	}
58 58
 
59 59
 
60
-        /**
61
-        * Gets all the spotter information based on a particular callsign
62
-        *
63
-        * @return Array the spotter information
64
-        *
65
-        */
66
-        public function getLastArchiveSpotterDataByIdent($ident)
67
-        {
60
+		/**
61
+		 * Gets all the spotter information based on a particular callsign
62
+		 *
63
+		 * @return Array the spotter information
64
+		 *
65
+		 */
66
+		public function getLastArchiveSpotterDataByIdent($ident)
67
+		{
68 68
 		$Spotter = new Spotter($this->db);
69
-                date_default_timezone_set('UTC');
69
+				date_default_timezone_set('UTC');
70 70
 
71
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
72
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
73
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
71
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
72
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
73
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
74 74
 
75
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
75
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
76 76
 
77
-                return $spotter_array;
78
-        }
77
+				return $spotter_array;
78
+		}
79 79
 
80 80
 
81
-        /**
82
-        * Gets last the spotter information based on a particular id
83
-        *
84
-        * @return Array the spotter information
85
-        *
86
-        */
87
-        public function getLastArchiveSpotterDataById($id)
88
-        {
89
-    		$Spotter = new Spotter($this->db);
90
-                date_default_timezone_set('UTC');
91
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
92
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
93
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
94
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
81
+		/**
82
+		 * Gets last the spotter information based on a particular id
83
+		 *
84
+		 * @return Array the spotter information
85
+		 *
86
+		 */
87
+		public function getLastArchiveSpotterDataById($id)
88
+		{
89
+			$Spotter = new Spotter($this->db);
90
+				date_default_timezone_set('UTC');
91
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
92
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
93
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
94
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
95 95
 
96 96
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
97
-                  /*
97
+				  /*
98 98
                 try {
99 99
                         $Connection = new Connection();
100 100
                         $sth = Connection->$db->prepare($query);
@@ -104,232 +104,232 @@  discard block
 block discarded – undo
104 104
                 }
105 105
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
106 106
                 */
107
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
108
-
109
-                return $spotter_array;
110
-        }
111
-
112
-        /**
113
-        * Gets all the spotter information based on a particular id
114
-        *
115
-        * @return Array the spotter information
116
-        *
117
-        */
118
-        public function getAllArchiveSpotterDataById($id)
119
-        {
120
-                date_default_timezone_set('UTC');
121
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
122
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
107
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
108
+
109
+				return $spotter_array;
110
+		}
111
+
112
+		/**
113
+		 * Gets all the spotter information based on a particular id
114
+		 *
115
+		 * @return Array the spotter information
116
+		 *
117
+		 */
118
+		public function getAllArchiveSpotterDataById($id)
119
+		{
120
+				date_default_timezone_set('UTC');
121
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
122
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
123 123
 
124 124
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
125 125
 
126
-                try {
127
-                        $sth = $this->db->prepare($query);
128
-                        $sth->execute(array(':id' => $id));
129
-                } catch(PDOException $e) {
130
-                        echo $e->getMessage();
131
-                        die;
132
-                }
133
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
134
-
135
-                return $spotter_array;
136
-        }
137
-
138
-        /**
139
-        * Gets coordinate & time spotter information based on a particular id
140
-        *
141
-        * @return Array the spotter information
142
-        *
143
-        */
144
-        public function getCoordArchiveSpotterDataById($id)
145
-        {
146
-                date_default_timezone_set('UTC');
147
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
148
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
126
+				try {
127
+						$sth = $this->db->prepare($query);
128
+						$sth->execute(array(':id' => $id));
129
+				} catch(PDOException $e) {
130
+						echo $e->getMessage();
131
+						die;
132
+				}
133
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
134
+
135
+				return $spotter_array;
136
+		}
137
+
138
+		/**
139
+		 * Gets coordinate & time spotter information based on a particular id
140
+		 *
141
+		 * @return Array the spotter information
142
+		 *
143
+		 */
144
+		public function getCoordArchiveSpotterDataById($id)
145
+		{
146
+				date_default_timezone_set('UTC');
147
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
148
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
149 149
 
150 150
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
151 151
 
152
-                try {
153
-                        $sth = $this->db->prepare($query);
154
-                        $sth->execute(array(':id' => $id));
155
-                } catch(PDOException $e) {
156
-                        echo $e->getMessage();
157
-                        die;
158
-                }
159
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
152
+				try {
153
+						$sth = $this->db->prepare($query);
154
+						$sth->execute(array(':id' => $id));
155
+				} catch(PDOException $e) {
156
+						echo $e->getMessage();
157
+						die;
158
+				}
159
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
160 160
 
161
-                return $spotter_array;
162
-        }
161
+				return $spotter_array;
162
+		}
163 163
 
164 164
 
165
-        /**
166
-        * Gets altitude information based on a particular callsign
167
-        *
168
-        * @return Array the spotter information
169
-        *
170
-        */
171
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
172
-        {
165
+		/**
166
+		 * Gets altitude information based on a particular callsign
167
+		 *
168
+		 * @return Array the spotter information
169
+		 *
170
+		 */
171
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
172
+		{
173 173
 
174
-                date_default_timezone_set('UTC');
174
+				date_default_timezone_set('UTC');
175 175
 
176
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
177
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
176
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
177
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
178 178
 
179
-                try {
180
-                        $sth = $this->db->prepare($query);
181
-                        $sth->execute(array(':ident' => $ident));
182
-                } catch(PDOException $e) {
183
-                        echo $e->getMessage();
184
-                        die;
185
-                }
186
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
179
+				try {
180
+						$sth = $this->db->prepare($query);
181
+						$sth->execute(array(':ident' => $ident));
182
+				} catch(PDOException $e) {
183
+						echo $e->getMessage();
184
+						die;
185
+				}
186
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
187 187
 
188
-                return $spotter_array;
189
-        }
188
+				return $spotter_array;
189
+		}
190 190
 
191
-        /**
192
-        * Gets altitude information based on a particular id
193
-        *
194
-        * @return Array the spotter information
195
-        *
196
-        */
197
-        public function getAltitudeArchiveSpotterDataById($id)
198
-        {
191
+		/**
192
+		 * Gets altitude information based on a particular id
193
+		 *
194
+		 * @return Array the spotter information
195
+		 *
196
+		 */
197
+		public function getAltitudeArchiveSpotterDataById($id)
198
+		{
199 199
 
200
-                date_default_timezone_set('UTC');
200
+				date_default_timezone_set('UTC');
201 201
 
202
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
203
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
202
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
203
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
204 204
 
205
-                try {
206
-                        $sth = $this->db->prepare($query);
207
-                        $sth->execute(array(':id' => $id));
208
-                } catch(PDOException $e) {
209
-                        echo $e->getMessage();
210
-                        die;
211
-                }
212
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
205
+				try {
206
+						$sth = $this->db->prepare($query);
207
+						$sth->execute(array(':id' => $id));
208
+				} catch(PDOException $e) {
209
+						echo $e->getMessage();
210
+						die;
211
+				}
212
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
213 213
 
214
-                return $spotter_array;
215
-        }
214
+				return $spotter_array;
215
+		}
216 216
 
217
-        /**
218
-        * Gets altitude & speed information based on a particular id
219
-        *
220
-        * @return Array the spotter information
221
-        *
222
-        */
223
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
224
-        {
217
+		/**
218
+		 * Gets altitude & speed information based on a particular id
219
+		 *
220
+		 * @return Array the spotter information
221
+		 *
222
+		 */
223
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
224
+		{
225 225
 
226
-                date_default_timezone_set('UTC');
226
+				date_default_timezone_set('UTC');
227 227
 
228
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
229
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
228
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
229
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
230 230
 
231
-                try {
232
-                        $sth = $this->db->prepare($query);
233
-                        $sth->execute(array(':id' => $id));
234
-                } catch(PDOException $e) {
235
-                        echo $e->getMessage();
236
-                        die;
237
-                }
238
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
231
+				try {
232
+						$sth = $this->db->prepare($query);
233
+						$sth->execute(array(':id' => $id));
234
+				} catch(PDOException $e) {
235
+						echo $e->getMessage();
236
+						die;
237
+				}
238
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
239 239
 
240
-                return $spotter_array;
241
-        }
240
+				return $spotter_array;
241
+		}
242 242
 
243 243
 
244
-        /**
245
-        * Gets altitude information based on a particular callsign
246
-        *
247
-        * @return Array the spotter information
248
-        *
249
-        */
250
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
251
-        {
244
+		/**
245
+		 * Gets altitude information based on a particular callsign
246
+		 *
247
+		 * @return Array the spotter information
248
+		 *
249
+		 */
250
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
251
+		{
252 252
 
253
-                date_default_timezone_set('UTC');
253
+				date_default_timezone_set('UTC');
254 254
 
255
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
256
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
255
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
256
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
257 257
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
258 258
 
259
-                try {
260
-                        $sth = $this->db->prepare($query);
261
-                        $sth->execute(array(':ident' => $ident));
262
-                } catch(PDOException $e) {
263
-                        echo $e->getMessage();
264
-                        die;
265
-                }
266
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
259
+				try {
260
+						$sth = $this->db->prepare($query);
261
+						$sth->execute(array(':ident' => $ident));
262
+				} catch(PDOException $e) {
263
+						echo $e->getMessage();
264
+						die;
265
+				}
266
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
267 267
 
268
-                return $spotter_array;
269
-        }
268
+				return $spotter_array;
269
+		}
270 270
 
271 271
 
272 272
 
273
-       /**
274
-        * Gets all the archive spotter information
275
-        *
276
-        * @return Array the spotter information
277
-        *
278
-        */
279
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
280
-        {
281
-    		$Spotter = new Spotter($this->db);
282
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
283
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
273
+	   /**
274
+	    * Gets all the archive spotter information
275
+	    *
276
+	    * @return Array the spotter information
277
+	    *
278
+	    */
279
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
280
+		{
281
+			$Spotter = new Spotter($this->db);
282
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
283
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
284 284
 
285
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
285
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
286 286
 
287
-                return $spotter_array;
288
-        }
287
+				return $spotter_array;
288
+		}
289 289
         
290
-        public function deleteSpotterArchiveTrackData()
291
-        {
290
+		public function deleteSpotterArchiveTrackData()
291
+		{
292 292
 		global $globalArchiveKeepTrackMonths;
293
-                date_default_timezone_set('UTC');
293
+				date_default_timezone_set('UTC');
294 294
 		$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
295
-                try {
296
-                        $sth = $this->db->prepare($query);
297
-                        $sth->execute();
298
-                } catch(PDOException $e) {
299
-                        echo $e->getMessage();
300
-                        die;
301
-                }
295
+				try {
296
+						$sth = $this->db->prepare($query);
297
+						$sth->execute();
298
+				} catch(PDOException $e) {
299
+						echo $e->getMessage();
300
+						die;
301
+				}
302 302
 	}
303 303
 
304 304
 	/**
305
-        * Gets Minimal Live Spotter data
306
-        *
307
-        * @return Array the spotter information
308
-        *
309
-        */
310
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
311
-        {
312
-                global $globalDBdriver, $globalLiveInterval;
313
-                date_default_timezone_set('UTC');
314
-
315
-                $filter_query = '';
316
-                if (isset($filter['source']) && !empty($filter['source'])) {
317
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
318
-                }
319
-                // Use spotter_output also ?
320
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
321
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
322
-                }
323
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
324
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
325
-                }
326
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
327
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
328
-                }
329
-
330
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
331
-                if ($globalDBdriver == 'mysql') {
332
-                        /*
305
+	 * Gets Minimal Live Spotter data
306
+	 *
307
+	 * @return Array the spotter information
308
+	 *
309
+	 */
310
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
311
+		{
312
+				global $globalDBdriver, $globalLiveInterval;
313
+				date_default_timezone_set('UTC');
314
+
315
+				$filter_query = '';
316
+				if (isset($filter['source']) && !empty($filter['source'])) {
317
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
318
+				}
319
+				// Use spotter_output also ?
320
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
321
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
322
+				}
323
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
324
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
325
+				}
326
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
327
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
328
+				}
329
+
330
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
331
+				if ($globalDBdriver == 'mysql') {
332
+						/*
333 333
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
334 334
                     		    FROM spotter_archive 
335 335
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -341,51 +341,51 @@  discard block
 block discarded – undo
341 341
 						WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".') 
342 342
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
343 343
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
344
-                } else {
345
-                        $query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
346
-                }
347
-                //echo $query;
348
-                try {
349
-                        $sth = $this->db->prepare($query);
350
-                        $sth->execute();
351
-                } catch(PDOException $e) {
352
-                        echo $e->getMessage();
353
-                        die;
354
-                }
355
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
356
-
357
-                return $spotter_array;
358
-        }
344
+				} else {
345
+						$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
346
+				}
347
+				//echo $query;
348
+				try {
349
+						$sth = $this->db->prepare($query);
350
+						$sth->execute();
351
+				} catch(PDOException $e) {
352
+						echo $e->getMessage();
353
+						die;
354
+				}
355
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
356
+
357
+				return $spotter_array;
358
+		}
359 359
 
360 360
 	/**
361
-        * Gets Minimal Live Spotter data
362
-        *
363
-        * @return Array the spotter information
364
-        *
365
-        */
366
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
367
-        {
368
-                global $globalDBdriver, $globalLiveInterval;
369
-                date_default_timezone_set('UTC');
370
-
371
-                $filter_query = '';
372
-                if (isset($filter['source']) && !empty($filter['source'])) {
373
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
374
-                }
375
-                // Should use spotter_output also ?
376
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
377
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
378
-                }
379
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
380
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
381
-                }
382
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
383
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
384
-                }
385
-
386
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
387
-                if ($globalDBdriver == 'mysql') {
388
-                        /*
361
+	 * Gets Minimal Live Spotter data
362
+	 *
363
+	 * @return Array the spotter information
364
+	 *
365
+	 */
366
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
367
+		{
368
+				global $globalDBdriver, $globalLiveInterval;
369
+				date_default_timezone_set('UTC');
370
+
371
+				$filter_query = '';
372
+				if (isset($filter['source']) && !empty($filter['source'])) {
373
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
374
+				}
375
+				// Should use spotter_output also ?
376
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
377
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
378
+				}
379
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
380
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
381
+				}
382
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
383
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
384
+				}
385
+
386
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
387
+				if ($globalDBdriver == 'mysql') {
388
+						/*
389 389
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
390 390
                     		    FROM spotter_archive 
391 391
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -396,94 +396,94 @@  discard block
 block discarded – undo
396 396
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
397 397
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
398 398
 
399
-                } else {
400
-                        //$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
401
-                       /*
399
+				} else {
400
+						//$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
401
+					   /*
402 402
                         $query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
403 403
                         	    FROM spotter_archive_output 
404 404
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
405 405
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
406 406
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
407 407
                         */
408
-                        $query  = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
408
+						$query  = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
409 409
                         	    FROM spotter_output 
410 410
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_output.aircraft_icao = a.icao
411 411
                         	    WHERE spotter_output.date >= '."'".$begindate."'".' AND spotter_output.date <= '."'".$enddate."'".'
412 412
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
413 413
 //                        	    .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
414 414
                         	    
415
-                }
416
-                //echo $query;
417
-                try {
418
-                        $sth = $this->db->prepare($query);
419
-                        $sth->execute();
420
-                } catch(PDOException $e) {
421
-                        echo $e->getMessage();
422
-                        die;
423
-                }
424
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
425
-
426
-                return $spotter_array;
427
-        }
415
+				}
416
+				//echo $query;
417
+				try {
418
+						$sth = $this->db->prepare($query);
419
+						$sth->execute();
420
+				} catch(PDOException $e) {
421
+						echo $e->getMessage();
422
+						die;
423
+				}
424
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
425
+
426
+				return $spotter_array;
427
+		}
428 428
 
429 429
 	 /**
430
-        * Gets count Live Spotter data
431
-        *
432
-        * @return Array the spotter information
433
-        *
434
-        */
435
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
436
-        {
437
-                global $globalDBdriver, $globalLiveInterval;
438
-                date_default_timezone_set('UTC');
439
-
440
-                $filter_query = '';
441
-                if (isset($filter['source']) && !empty($filter['source'])) {
442
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
443
-                }
444
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
445
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
446
-                }
447
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
448
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
449
-                }
450
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
451
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
452
-                }
453
-
454
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
455
-                if ($globalDBdriver == 'mysql') {
430
+	  * Gets count Live Spotter data
431
+	  *
432
+	  * @return Array the spotter information
433
+	  *
434
+	  */
435
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
436
+		{
437
+				global $globalDBdriver, $globalLiveInterval;
438
+				date_default_timezone_set('UTC');
439
+
440
+				$filter_query = '';
441
+				if (isset($filter['source']) && !empty($filter['source'])) {
442
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
443
+				}
444
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
445
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
446
+				}
447
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
448
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
449
+				}
450
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
451
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
452
+				}
453
+
454
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
455
+				if ($globalDBdriver == 'mysql') {
456 456
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
457 457
 			FROM spotter_archive l 
458 458
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
459
-                } else {
459
+				} else {
460 460
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
461
-                }
462
-                //echo $query;
463
-                try {
464
-                        $sth = $this->db->prepare($query);
465
-                        $sth->execute();
466
-                } catch(PDOException $e) {
467
-                        echo $e->getMessage();
468
-                        die;
469
-                }
461
+				}
462
+				//echo $query;
463
+				try {
464
+						$sth = $this->db->prepare($query);
465
+						$sth->execute();
466
+				} catch(PDOException $e) {
467
+						echo $e->getMessage();
468
+						die;
469
+				}
470 470
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
471
-                return $result['nb'];
471
+				return $result['nb'];
472 472
 
473
-        }
473
+		}
474 474
 
475 475
 
476 476
 
477 477
 	// Spotter_Archive_output
478 478
 	
479
-    /**
480
-    * Gets all the spotter information
481
-    *
482
-    * @return Array the spotter information
483
-    *
484
-    */
485
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filter=array())
486
-    {
479
+	/**
480
+	 * Gets all the spotter information
481
+	 *
482
+	 * @return Array the spotter information
483
+	 *
484
+	 */
485
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filter=array())
486
+	{
487 487
 	global $globalTimezone, $globalDBdriver;
488 488
 	require_once(dirname(__FILE__).'/class.Translation.php');
489 489
 	$Translation = new Translation();
@@ -497,159 +497,159 @@  discard block
 block discarded – undo
497 497
 	$filter_query = $this->getFilter($filter);
498 498
 	if ($q != "")
499 499
 	{
500
-	    if (!is_string($q))
501
-	    {
500
+		if (!is_string($q))
501
+		{
502 502
 		return false;
503
-	    } else {
503
+		} else {
504 504
 	        
505 505
 		$q_array = explode(" ", $q);
506 506
 		
507 507
 		foreach ($q_array as $q_item){
508
-		    $additional_query .= " AND (";
509
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
510
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
511
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
512
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
513
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
514
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
515
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
516
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
517
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
518
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
519
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
520
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
521
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
522
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
523
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
524
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
525
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
526
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
527
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
528
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
529
-		    $translate = $Translation->ident2icao($q_item);
530
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
531
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
532
-		    $additional_query .= ")";
533
-		}
534
-	    }
508
+			$additional_query .= " AND (";
509
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
510
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
511
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
512
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
513
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
514
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
515
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
516
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
517
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
518
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
519
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
520
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
521
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
522
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
523
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
524
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
525
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
526
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
527
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
528
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
529
+			$translate = $Translation->ident2icao($q_item);
530
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
531
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
532
+			$additional_query .= ")";
533
+		}
534
+		}
535 535
 	}
536 536
 	
537 537
 	if ($registration != "")
538 538
 	{
539
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
540
-	    if (!is_string($registration))
541
-	    {
539
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
540
+		if (!is_string($registration))
541
+		{
542 542
 		return false;
543
-	    } else {
543
+		} else {
544 544
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
545
-	    }
545
+		}
546 546
 	}
547 547
 	
548 548
 	if ($aircraft_icao != "")
549 549
 	{
550
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
551
-	    if (!is_string($aircraft_icao))
552
-	    {
550
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
551
+		if (!is_string($aircraft_icao))
552
+		{
553 553
 		return false;
554
-	    } else {
554
+		} else {
555 555
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
556
-	    }
556
+		}
557 557
 	}
558 558
 	
559 559
 	if ($aircraft_manufacturer != "")
560 560
 	{
561
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
562
-	    if (!is_string($aircraft_manufacturer))
563
-	    {
561
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
562
+		if (!is_string($aircraft_manufacturer))
563
+		{
564 564
 		return false;
565
-	    } else {
565
+		} else {
566 566
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
567
-	    }
567
+		}
568 568
 	}
569 569
 	
570 570
 	if ($highlights == "true")
571 571
 	{
572
-	    if (!is_string($highlights))
573
-	    {
572
+		if (!is_string($highlights))
573
+		{
574 574
 		return false;
575
-	    } else {
575
+		} else {
576 576
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
577
-	    }
577
+		}
578 578
 	}
579 579
 	
580 580
 	if ($airline_icao != "")
581 581
 	{
582
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
583
-	    if (!is_string($airline_icao))
584
-	    {
582
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
583
+		if (!is_string($airline_icao))
584
+		{
585 585
 		return false;
586
-	    } else {
586
+		} else {
587 587
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
588
-	    }
588
+		}
589 589
 	}
590 590
 	
591 591
 	if ($airline_country != "")
592 592
 	{
593
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
594
-	    if (!is_string($airline_country))
595
-	    {
593
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
594
+		if (!is_string($airline_country))
595
+		{
596 596
 		return false;
597
-	    } else {
597
+		} else {
598 598
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
599
-	    }
599
+		}
600 600
 	}
601 601
 	
602 602
 	if ($airline_type != "")
603 603
 	{
604
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
605
-	    if (!is_string($airline_type))
606
-	    {
604
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
605
+		if (!is_string($airline_type))
606
+		{
607 607
 		return false;
608
-	    } else {
608
+		} else {
609 609
 		if ($airline_type == "passenger")
610 610
 		{
611
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
611
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
612 612
 		}
613 613
 		if ($airline_type == "cargo")
614 614
 		{
615
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
615
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
616 616
 		}
617 617
 		if ($airline_type == "military")
618 618
 		{
619
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
619
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
620
+		}
620 621
 		}
621
-	    }
622 622
 	}
623 623
 	
624 624
 	if ($airport != "")
625 625
 	{
626
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
627
-	    if (!is_string($airport))
628
-	    {
626
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
627
+		if (!is_string($airport))
628
+		{
629 629
 		return false;
630
-	    } else {
630
+		} else {
631 631
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
632
-	    }
632
+		}
633 633
 	}
634 634
 	
635 635
 	if ($airport_country != "")
636 636
 	{
637
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
638
-	    if (!is_string($airport_country))
639
-	    {
637
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
638
+		if (!is_string($airport_country))
639
+		{
640 640
 		return false;
641
-	    } else {
641
+		} else {
642 642
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
643
-	    }
643
+		}
644 644
 	}
645 645
     
646 646
 	if ($callsign != "")
647 647
 	{
648
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
649
-	    if (!is_string($callsign))
650
-	    {
648
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
649
+		if (!is_string($callsign))
650
+		{
651 651
 		return false;
652
-	    } else {
652
+		} else {
653 653
 		$translate = $Translation->ident2icao($callsign);
654 654
 		if ($translate != $callsign) {
655 655
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -657,99 +657,99 @@  discard block
 block discarded – undo
657 657
 		} else {
658 658
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
659 659
 		}
660
-	    }
660
+		}
661 661
 	}
662 662
 
663 663
 	if ($owner != "")
664 664
 	{
665
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
666
-	    if (!is_string($owner))
667
-	    {
665
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
666
+		if (!is_string($owner))
667
+		{
668 668
 		return false;
669
-	    } else {
669
+		} else {
670 670
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
671
-	    }
671
+		}
672 672
 	}
673 673
 
674 674
 	if ($pilot_name != "")
675 675
 	{
676
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
677
-	    if (!is_string($pilot_name))
678
-	    {
676
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
677
+		if (!is_string($pilot_name))
678
+		{
679 679
 		return false;
680
-	    } else {
680
+		} else {
681 681
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
682
-	    }
682
+		}
683 683
 	}
684 684
 	
685 685
 	if ($pilot_id != "")
686 686
 	{
687
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
688
-	    if (!is_string($pilot_id))
689
-	    {
687
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
688
+		if (!is_string($pilot_id))
689
+		{
690 690
 		return false;
691
-	    } else {
691
+		} else {
692 692
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
693
-	    }
693
+		}
694 694
 	}
695 695
 	
696 696
 	if ($departure_airport_route != "")
697 697
 	{
698
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
699
-	    if (!is_string($departure_airport_route))
700
-	    {
698
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
699
+		if (!is_string($departure_airport_route))
700
+		{
701 701
 		return false;
702
-	    } else {
702
+		} else {
703 703
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
704
-	    }
704
+		}
705 705
 	}
706 706
 	
707 707
 	if ($arrival_airport_route != "")
708 708
 	{
709
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
710
-	    if (!is_string($arrival_airport_route))
711
-	    {
709
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
710
+		if (!is_string($arrival_airport_route))
711
+		{
712 712
 		return false;
713
-	    } else {
713
+		} else {
714 714
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
715
-	    }
715
+		}
716 716
 	}
717 717
 	
718 718
 	if ($altitude != "")
719 719
 	{
720
-	    $altitude_array = explode(",", $altitude);
720
+		$altitude_array = explode(",", $altitude);
721 721
 	    
722
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
723
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
722
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
723
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
724 724
 	    
725 725
 
726
-	    if ($altitude_array[1] != "")
727
-	    {                
726
+		if ($altitude_array[1] != "")
727
+		{                
728 728
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
729 729
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
730 730
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
731
-	    } else {
731
+		} else {
732 732
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
733 733
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
734
-	    }
734
+		}
735 735
 	}
736 736
 	
737 737
 	if ($date_posted != "")
738 738
 	{
739
-	    $date_array = explode(",", $date_posted);
739
+		$date_array = explode(",", $date_posted);
740 740
 	    
741
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
742
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
741
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
742
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
743 743
 	    
744
-	    if ($globalTimezone != '') {
744
+		if ($globalTimezone != '') {
745 745
 		date_default_timezone_set($globalTimezone);
746 746
 		$datetime = new DateTime();
747 747
 		$offset = $datetime->format('P');
748
-	    } else $offset = '+00:00';
748
+		} else $offset = '+00:00';
749 749
 
750 750
 
751
-	    if ($date_array[1] != "")
752
-	    {                
751
+		if ($date_array[1] != "")
752
+		{                
753 753
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
754 754
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
755 755
 		if ($globalDBdriver == 'mysql') {
@@ -757,28 +757,28 @@  discard block
 block discarded – undo
757 757
 		} else {
758 758
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
759 759
 		}
760
-	    } else {
760
+		} else {
761 761
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
762
-                if ($globalDBdriver == 'mysql') {
762
+				if ($globalDBdriver == 'mysql') {
763 763
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
764 764
 		} else {
765 765
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
766 766
 		}
767
-	    }
767
+		}
768 768
 	}
769 769
 	
770 770
 	if ($limit != "")
771 771
 	{
772
-	    $limit_array = explode(",", $limit);
772
+		$limit_array = explode(",", $limit);
773 773
 	    
774
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
775
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
774
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
775
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
776 776
 	    
777
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
778
-	    {
777
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
778
+		{
779 779
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
780 780
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
781
-	    }
781
+		}
782 782
 	}
783 783
 	
784 784
 
@@ -809,33 +809,33 @@  discard block
 block discarded – undo
809 809
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
810 810
 
811 811
 	return $spotter_array;
812
-    }
812
+	}
813 813
 
814
-    public function deleteSpotterArchiveData()
815
-    {
814
+	public function deleteSpotterArchiveData()
815
+	{
816 816
 		global $globalArchiveKeepMonths, $globalDBdriver;
817
-                date_default_timezone_set('UTC');
818
-                if ($globalDBdriver == 'mysql') {
817
+				date_default_timezone_set('UTC');
818
+				if ($globalDBdriver == 'mysql') {
819 819
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
820 820
 		} else {
821 821
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
822 822
 		}
823
-                try {
824
-                        $sth = $this->db->prepare($query);
825
-                        $sth->execute();
826
-                } catch(PDOException $e) {
827
-                        return "error";
828
-                }
823
+				try {
824
+						$sth = $this->db->prepare($query);
825
+						$sth->execute();
826
+				} catch(PDOException $e) {
827
+						return "error";
828
+				}
829 829
 	}
830 830
 
831
-    /**
832
-    * Gets all the spotter information based on the callsign
833
-    *
834
-    * @return Array the spotter information
835
-    *
836
-    */
837
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
838
-    {
831
+	/**
832
+	 * Gets all the spotter information based on the callsign
833
+	 *
834
+	 * @return Array the spotter information
835
+	 *
836
+	 */
837
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
838
+	{
839 839
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
840 840
 	
841 841
 	date_default_timezone_set('UTC');
@@ -847,35 +847,35 @@  discard block
 block discarded – undo
847 847
 	
848 848
 	if ($ident != "")
849 849
 	{
850
-	    if (!is_string($ident))
851
-	    {
850
+		if (!is_string($ident))
851
+		{
852 852
 		return false;
853
-	    } else {
853
+		} else {
854 854
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
855 855
 		$query_values = array(':ident' => $ident);
856
-	    }
856
+		}
857 857
 	}
858 858
 	
859 859
 	if ($limit != "")
860 860
 	{
861
-	    $limit_array = explode(",", $limit);
861
+		$limit_array = explode(",", $limit);
862 862
 	    
863
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
864
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
863
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
864
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
865 865
 	    
866
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
867
-	    {
866
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
867
+		{
868 868
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
869 869
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
870
-	    }
870
+		}
871 871
 	}
872 872
 
873 873
 	if ($sort != "")
874 874
 	{
875
-	    $search_orderby_array = $Spotter->getOrderBy();
876
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
875
+		$search_orderby_array = $Spotter->getOrderBy();
876
+		$orderby_query = $search_orderby_array[$sort]['sql'];
877 877
 	} else {
878
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
878
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
879 879
 	}
880 880
 
881 881
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -883,16 +883,16 @@  discard block
 block discarded – undo
883 883
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
884 884
 
885 885
 	return $spotter_array;
886
-    }
887
-
888
-    /**
889
-    * Gets all number of flight over countries
890
-    *
891
-    * @return Array the airline country list
892
-    *
893
-    */
894
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
895
-    {
886
+	}
887
+
888
+	/**
889
+	 * Gets all number of flight over countries
890
+	 *
891
+	 * @return Array the airline country list
892
+	 *
893
+	 */
894
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
895
+	{
896 896
 	global $globalDBdriver;
897 897
 	/*
898 898
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -902,14 +902,14 @@  discard block
 block discarded – undo
902 902
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
903 903
 		    FROM countries c, spotter_archive s
904 904
 		    WHERE c.iso2 = s.over_country ";
905
-                if ($olderthanmonths > 0) {
906
-            		if ($globalDBdriver == 'mysql') {
905
+				if ($olderthanmonths > 0) {
906
+					if ($globalDBdriver == 'mysql') {
907 907
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
908 908
 			} else {
909 909
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
910 910
 			}
911 911
 		}
912
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
912
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
913 913
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
914 914
 	if ($limit) $query .= " LIMIT 0,10";
915 915
       
@@ -922,14 +922,14 @@  discard block
 block discarded – undo
922 922
         
923 923
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
924 924
 	{
925
-	    $temp_array['flight_count'] = $row['nb'];
926
-	    $temp_array['flight_country'] = $row['name'];
927
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
928
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
929
-	    $flight_array[] = $temp_array;
925
+		$temp_array['flight_count'] = $row['nb'];
926
+		$temp_array['flight_country'] = $row['name'];
927
+		$temp_array['flight_country_iso3'] = $row['iso3'];
928
+		$temp_array['flight_country_iso2'] = $row['iso2'];
929
+		$flight_array[] = $temp_array;
930 930
 	}
931 931
 	return $flight_array;
932
-    }
932
+	}
933 933
 
934 934
 }
935 935
 ?>
936 936
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -11,46 +11,46 @@  discard block
 block discarded – undo
11 11
 	public function getFilter($filter) {
12 12
 		$filter_query = '';
13 13
 		if (isset($filter['source']) && !empty($filter['source'])) {
14
-			$filter_query = " AND format_source IN ('".implode("','",$filter['source'])."')";
14
+			$filter_query = " AND format_source IN ('".implode("','", $filter['source'])."')";
15 15
 		}
16 16
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
17
-			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
17
+			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
18 18
 		}
19 19
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
20 20
 			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
21 21
 		}
22 22
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
23
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
23
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
24 24
 		}
25 25
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
26
-			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
26
+			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
27 27
 		}
28 28
 		return $filter_query;
29 29
 	}
30 30
 
31 31
 	// Spotter_archive
32
-	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
32
+	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
33 33
 		require_once(dirname(__FILE__).'/class.Spotter.php');
34 34
 		if ($over_country == '') {
35 35
 			$Spotter = new Spotter($this->db);
36
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
36
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
37 37
 			if (!empty($data_country)) $country = $data_country['iso2'];
38 38
 			else $country = '';
39 39
 		} else $country = $over_country;
40
-		if ($airline_type === NULL) $airline_type ='';
40
+		if ($airline_type === NULL) $airline_type = '';
41 41
 	
42 42
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
43 43
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
44 44
 
45 45
 		// Route is not added in spotter_archive
46
-		$query  = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
46
+		$query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
47 47
 		        VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)";
48 48
 
49
-		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
49
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
50 50
 		try {
51 51
 			$sth = $this->db->prepare($query);
52 52
 			$sth->execute($query_values);
53
-		} catch(PDOException $e) {
53
+		} catch (PDOException $e) {
54 54
 			return "error : ".$e->getMessage();
55 55
 		}
56 56
 		return "success";
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 
71 71
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
72 72
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
73
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
73
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
74 74
 
75
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
75
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
76 76
 
77 77
                 return $spotter_array;
78 78
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
92 92
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
93 93
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
94
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
94
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
95 95
 
96 96
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
97 97
                   /*
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
                 }
105 105
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
106 106
                 */
107
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
107
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
108 108
 
109 109
                 return $spotter_array;
110 110
         }
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
         {
120 120
                 date_default_timezone_set('UTC');
121 121
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
122
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
122
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
123 123
 
124 124
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
125 125
 
126 126
                 try {
127 127
                         $sth = $this->db->prepare($query);
128 128
                         $sth->execute(array(':id' => $id));
129
-                } catch(PDOException $e) {
129
+                } catch (PDOException $e) {
130 130
                         echo $e->getMessage();
131 131
                         die;
132 132
                 }
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
         {
146 146
                 date_default_timezone_set('UTC');
147 147
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
148
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
148
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
149 149
 
150 150
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
151 151
 
152 152
                 try {
153 153
                         $sth = $this->db->prepare($query);
154 154
                         $sth->execute(array(':id' => $id));
155
-                } catch(PDOException $e) {
155
+                } catch (PDOException $e) {
156 156
                         echo $e->getMessage();
157 157
                         die;
158 158
                 }
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
                 date_default_timezone_set('UTC');
175 175
 
176 176
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
177
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
177
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
178 178
 
179 179
                 try {
180 180
                         $sth = $this->db->prepare($query);
181 181
                         $sth->execute(array(':ident' => $ident));
182
-                } catch(PDOException $e) {
182
+                } catch (PDOException $e) {
183 183
                         echo $e->getMessage();
184 184
                         die;
185 185
                 }
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
                 date_default_timezone_set('UTC');
201 201
 
202 202
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
203
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
203
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
204 204
 
205 205
                 try {
206 206
                         $sth = $this->db->prepare($query);
207 207
                         $sth->execute(array(':id' => $id));
208
-                } catch(PDOException $e) {
208
+                } catch (PDOException $e) {
209 209
                         echo $e->getMessage();
210 210
                         die;
211 211
                 }
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
                 date_default_timezone_set('UTC');
227 227
 
228 228
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
229
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
229
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
230 230
 
231 231
                 try {
232 232
                         $sth = $this->db->prepare($query);
233 233
                         $sth->execute(array(':id' => $id));
234
-                } catch(PDOException $e) {
234
+                } catch (PDOException $e) {
235 235
                         echo $e->getMessage();
236 236
                         die;
237 237
                 }
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
                 date_default_timezone_set('UTC');
254 254
 
255 255
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
256
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
256
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
257 257
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
258 258
 
259 259
                 try {
260 260
                         $sth = $this->db->prepare($query);
261 261
                         $sth->execute(array(':ident' => $ident));
262
-                } catch(PDOException $e) {
262
+                } catch (PDOException $e) {
263 263
                         echo $e->getMessage();
264 264
                         die;
265 265
                 }
@@ -276,13 +276,13 @@  discard block
 block discarded – undo
276 276
         * @return Array the spotter information
277 277
         *
278 278
         */
279
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
279
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
280 280
         {
281 281
     		$Spotter = new Spotter($this->db);
282 282
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
283
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
283
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
284 284
 
285
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
285
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
286 286
 
287 287
                 return $spotter_array;
288 288
         }
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
                 try {
296 296
                         $sth = $this->db->prepare($query);
297 297
                         $sth->execute();
298
-                } catch(PDOException $e) {
298
+                } catch (PDOException $e) {
299 299
                         echo $e->getMessage();
300 300
                         die;
301 301
                 }
@@ -307,24 +307,24 @@  discard block
 block discarded – undo
307 307
         * @return Array the spotter information
308 308
         *
309 309
         */
310
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
310
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
311 311
         {
312 312
                 global $globalDBdriver, $globalLiveInterval;
313 313
                 date_default_timezone_set('UTC');
314 314
 
315 315
                 $filter_query = '';
316 316
                 if (isset($filter['source']) && !empty($filter['source'])) {
317
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
317
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
318 318
                 }
319 319
                 // Use spotter_output also ?
320 320
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
321
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
321
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
322 322
                 }
323 323
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
324 324
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
325 325
                 }
326 326
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
327
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
327
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
328 328
                 }
329 329
 
330 330
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
                     		    FROM spotter_archive 
335 335
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
336 336
 			*/
337
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
337
+			$query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
338 338
 				    FROM spotter_archive 
339 339
 				    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
340 340
 						FROM spotter_archive l 
@@ -342,13 +342,13 @@  discard block
 block discarded – undo
342 342
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
343 343
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
344 344
                 } else {
345
-                        $query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
345
+                        $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
346 346
                 }
347 347
                 //echo $query;
348 348
                 try {
349 349
                         $sth = $this->db->prepare($query);
350 350
                         $sth->execute();
351
-                } catch(PDOException $e) {
351
+                } catch (PDOException $e) {
352 352
                         echo $e->getMessage();
353 353
                         die;
354 354
                 }
@@ -363,24 +363,24 @@  discard block
 block discarded – undo
363 363
         * @return Array the spotter information
364 364
         *
365 365
         */
366
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
366
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
367 367
         {
368 368
                 global $globalDBdriver, $globalLiveInterval;
369 369
                 date_default_timezone_set('UTC');
370 370
 
371 371
                 $filter_query = '';
372 372
                 if (isset($filter['source']) && !empty($filter['source'])) {
373
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
373
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
374 374
                 }
375 375
                 // Should use spotter_output also ?
376 376
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
377
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
377
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
378 378
                 }
379 379
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
380 380
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
381 381
                 }
382 382
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
383
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
383
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
384 384
                 }
385 385
 
386 386
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
                     		    FROM spotter_archive 
391 391
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
392 392
 			*/
393
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
393
+			$query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
394 394
 				    FROM spotter_archive_output 
395 395
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
396 396
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
406 406
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
407 407
                         */
408
-                        $query  = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
408
+                        $query = 'SELECT DISTINCT spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao as departure_airport, spotter_output.arrival_airport_icao as arrival_airport, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow
409 409
                         	    FROM spotter_output 
410 410
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_output.aircraft_icao = a.icao
411 411
                         	    WHERE spotter_output.date >= '."'".$begindate."'".' AND spotter_output.date <= '."'".$enddate."'".'
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
                 try {
418 418
                         $sth = $this->db->prepare($query);
419 419
                         $sth->execute();
420
-                } catch(PDOException $e) {
420
+                } catch (PDOException $e) {
421 421
                         echo $e->getMessage();
422 422
                         die;
423 423
                 }
@@ -432,23 +432,23 @@  discard block
 block discarded – undo
432 432
         * @return Array the spotter information
433 433
         *
434 434
         */
435
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
435
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
436 436
         {
437 437
                 global $globalDBdriver, $globalLiveInterval;
438 438
                 date_default_timezone_set('UTC');
439 439
 
440 440
                 $filter_query = '';
441 441
                 if (isset($filter['source']) && !empty($filter['source'])) {
442
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
442
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
443 443
                 }
444 444
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
445
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
445
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
446 446
                 }
447 447
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
448 448
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
449 449
                 }
450 450
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
451
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
451
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
452 452
                 }
453 453
 
454 454
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
                 try {
464 464
                         $sth = $this->db->prepare($query);
465 465
                         $sth->execute();
466
-                } catch(PDOException $e) {
466
+                } catch (PDOException $e) {
467 467
                         echo $e->getMessage();
468 468
                         die;
469 469
                 }
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
     * @return Array the spotter information
483 483
     *
484 484
     */
485
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filter=array())
485
+    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filter = array())
486 486
     {
487 487
 	global $globalTimezone, $globalDBdriver;
488 488
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 	        
505 505
 		$q_array = explode(" ", $q);
506 506
 		
507
-		foreach ($q_array as $q_item){
507
+		foreach ($q_array as $q_item) {
508 508
 		    $additional_query .= " AND (";
509 509
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
510 510
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	
537 537
 	if ($registration != "")
538 538
 	{
539
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
539
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
540 540
 	    if (!is_string($registration))
541 541
 	    {
542 542
 		return false;
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	
548 548
 	if ($aircraft_icao != "")
549 549
 	{
550
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
550
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
551 551
 	    if (!is_string($aircraft_icao))
552 552
 	    {
553 553
 		return false;
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	
559 559
 	if ($aircraft_manufacturer != "")
560 560
 	{
561
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
561
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
562 562
 	    if (!is_string($aircraft_manufacturer))
563 563
 	    {
564 564
 		return false;
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 	
580 580
 	if ($airline_icao != "")
581 581
 	{
582
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
582
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
583 583
 	    if (!is_string($airline_icao))
584 584
 	    {
585 585
 		return false;
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 	
591 591
 	if ($airline_country != "")
592 592
 	{
593
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
593
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
594 594
 	    if (!is_string($airline_country))
595 595
 	    {
596 596
 		return false;
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	
602 602
 	if ($airline_type != "")
603 603
 	{
604
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
604
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
605 605
 	    if (!is_string($airline_type))
606 606
 	    {
607 607
 		return false;
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 	
624 624
 	if ($airport != "")
625 625
 	{
626
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
626
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
627 627
 	    if (!is_string($airport))
628 628
 	    {
629 629
 		return false;
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 	
635 635
 	if ($airport_country != "")
636 636
 	{
637
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
637
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
638 638
 	    if (!is_string($airport_country))
639 639
 	    {
640 640
 		return false;
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
     
646 646
 	if ($callsign != "")
647 647
 	{
648
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
648
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
649 649
 	    if (!is_string($callsign))
650 650
 	    {
651 651
 		return false;
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 		$translate = $Translation->ident2icao($callsign);
654 654
 		if ($translate != $callsign) {
655 655
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
656
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
656
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
657 657
 		} else {
658 658
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
659 659
 		}
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 
663 663
 	if ($owner != "")
664 664
 	{
665
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
665
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
666 666
 	    if (!is_string($owner))
667 667
 	    {
668 668
 		return false;
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 
674 674
 	if ($pilot_name != "")
675 675
 	{
676
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
676
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
677 677
 	    if (!is_string($pilot_name))
678 678
 	    {
679 679
 		return false;
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	
685 685
 	if ($pilot_id != "")
686 686
 	{
687
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
687
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
688 688
 	    if (!is_string($pilot_id))
689 689
 	    {
690 690
 		return false;
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 	
696 696
 	if ($departure_airport_route != "")
697 697
 	{
698
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
698
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
699 699
 	    if (!is_string($departure_airport_route))
700 700
 	    {
701 701
 		return false;
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 	
707 707
 	if ($arrival_airport_route != "")
708 708
 	{
709
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
709
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
710 710
 	    if (!is_string($arrival_airport_route))
711 711
 	    {
712 712
 		return false;
@@ -719,8 +719,8 @@  discard block
 block discarded – undo
719 719
 	{
720 720
 	    $altitude_array = explode(",", $altitude);
721 721
 	    
722
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
723
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
722
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
723
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
724 724
 	    
725 725
 
726 726
 	    if ($altitude_array[1] != "")
@@ -738,8 +738,8 @@  discard block
 block discarded – undo
738 738
 	{
739 739
 	    $date_array = explode(",", $date_posted);
740 740
 	    
741
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
742
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
741
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
742
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
743 743
 	    
744 744
 	    if ($globalTimezone != '') {
745 745
 		date_default_timezone_set($globalTimezone);
@@ -771,8 +771,8 @@  discard block
 block discarded – undo
771 771
 	{
772 772
 	    $limit_array = explode(",", $limit);
773 773
 	    
774
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
775
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
774
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
775
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
776 776
 	    
777 777
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
778 778
 	    {
@@ -783,8 +783,8 @@  discard block
 block discarded – undo
783 783
 	
784 784
 
785 785
 	if ($origLat != "" && $origLon != "" && $dist != "") {
786
-		$dist = number_format($dist*0.621371,2,'.','');
787
-		$query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
786
+		$dist = number_format($dist*0.621371, 2, '.', '');
787
+		$query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
788 788
                           FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
789 789
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
790 790
 	} else {
@@ -801,12 +801,12 @@  discard block
 block discarded – undo
801 801
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
802 802
 		}
803 803
 
804
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
804
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
805 805
 		    WHERE spotter_archive_output.ident <> '' 
806 806
 		    ".$additional_query."
807 807
 		    ".$filter_query.$orderby_query;
808 808
 	}
809
-	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
809
+	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
810 810
 
811 811
 	return $spotter_array;
812 812
     }
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
                 try {
824 824
                         $sth = $this->db->prepare($query);
825 825
                         $sth->execute();
826
-                } catch(PDOException $e) {
826
+                } catch (PDOException $e) {
827 827
                         return "error";
828 828
                 }
829 829
 	}
@@ -860,8 +860,8 @@  discard block
 block discarded – undo
860 860
 	{
861 861
 	    $limit_array = explode(",", $limit);
862 862
 	    
863
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
864
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
863
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
864
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
865 865
 	    
866 866
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
867 867
 	    {
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
     * @return Array the airline country list
892 892
     *
893 893
     */
894
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
894
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
895 895
     {
896 896
 	global $globalDBdriver;
897 897
 	/*
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 	$flight_array = array();
921 921
 	$temp_array = array();
922 922
         
923
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
923
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
924 924
 	{
925 925
 	    $temp_array['flight_count'] = $row['nb'];
926 926
 	    $temp_array['flight_country'] = $row['name'];
Please login to merge, or discard this patch.
require/class.Scheduler.php 3 patches
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);
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
 
128 128
 	public function checkSchedule($ident) {
129 129
 		global $globalDBdriver;
130
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
131
-	        if ($globalDBdriver == 'mysql') {
130
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
131
+			if ($globalDBdriver == 'mysql') {
132 132
 			$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";
133 133
 		} else {
134 134
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident 
135 135
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
136 136
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
137 137
 		}
138
-	        $query_values = array(':ident' => $ident);
138
+			$query_values = array(':ident' => $ident);
139 139
 		 try {
140 140
 			$sth = $this->db->prepare($query);
141 141
 			$sth->execute($query_values);
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
 	}
148 148
 
149 149
 	/**
150
-	* Get flight info from Air France
151
-	* @param String $callsign The callsign
152
-	* @param String $date date we want flight number info
153
-	* @param String $carrier IATA code
154
-	* @return Flight departure and arrival airports and time
155
-	*/
150
+	 * Get flight info from Air France
151
+	 * @param String $callsign The callsign
152
+	 * @param String $date date we want flight number info
153
+	 * @param String $carrier IATA code
154
+	 * @return Flight departure and arrival airports and time
155
+	 */
156 156
 	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
157 157
 		$Common = new Common();
158 158
 		$check_date = new Datetime($date);
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 	}
189 189
 
190 190
 	/**
191
-	* Get flight info from EasyJet
192
-	* @param String $callsign The callsign
193
-	* @param String $date date we want flight number info
194
-	* @return Flight departure and arrival airports and time
195
-	*/
191
+	 * Get flight info from EasyJet
192
+	 * @param String $callsign The callsign
193
+	 * @param String $date date we want flight number info
194
+	 * @return Flight departure and arrival airports and time
195
+	 */
196 196
 	private function getEasyJet($callsign, $date = 'NOW') {
197 197
 		global $globalTimezone;
198 198
 		$Common = new Common();
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 
218 218
 	/**
219
-	* Get flight info from Ryanair
220
-	* @param String $callsign The callsign
221
-	* @return Flight departure and arrival airports and time
222
-	*/
219
+	 * Get flight info from Ryanair
220
+	 * @param String $callsign The callsign
221
+	 * @return Flight departure and arrival airports and time
222
+	 */
223 223
 	private function getRyanair($callsign) {
224 224
 		$Common = new Common();
225 225
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 	}
243 243
 
244 244
 	/**
245
-	* Get flight info from Swiss
246
-	* @param String $callsign The callsign
247
-	* @return Flight departure and arrival airports and time
248
-	*/
245
+	 * Get flight info from Swiss
246
+	 * @param String $callsign The callsign
247
+	 * @return Flight departure and arrival airports and time
248
+	 */
249 249
 	private function getSwiss($callsign) {
250 250
 		$Common = new Common();
251 251
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
 	}
275 275
 	
276 276
 	/**
277
-	* Get flight info from British Airways API
278
-	* @param String $callsign The callsign
279
-	* @param String $date date we want flight number info
280
-	* @return Flight departure and arrival airports and time
281
-	*/
277
+	 * Get flight info from British Airways API
278
+	 * @param String $callsign The callsign
279
+	 * @param String $date date we want flight number info
280
+	 * @return Flight departure and arrival airports and time
281
+	 */
282 282
 	public function getBritishAirways($callsign, $date = 'NOW') {
283 283
 		global $globalBritishAirwaysKey;
284 284
 		$Common = new Common();
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
 	}
303 303
 
304 304
 	/**
305
-	* Get flight info from Lutfhansa API
306
-	* @param String $callsign The callsign
307
-	* @param String $date date we want flight number info
308
-	* @return Flight departure and arrival airports and time
309
-	*/
305
+	 * Get flight info from Lutfhansa API
306
+	 * @param String $callsign The callsign
307
+	 * @param String $date date we want flight number info
308
+	 * @return Flight departure and arrival airports and time
309
+	 */
310 310
 	public function getLufthansa($callsign, $date = 'NOW') {
311 311
 		global $globalLufthansaKey;
312 312
 		$Common = new Common();
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 	}
337 337
 
338 338
 	/**
339
-	* Get flight info from Transavia API
340
-	* @param String $callsign The callsign
341
-	* @param String $date date we want flight number info
342
-	* @return Flight departure and arrival airports and time
343
-	*/
339
+	 * Get flight info from Transavia API
340
+	 * @param String $callsign The callsign
341
+	 * @param String $date date we want flight number info
342
+	 * @return Flight departure and arrival airports and time
343
+	 */
344 344
 	public function getTransavia($callsign, $date = 'NOW') {
345 345
 		global $globalTransaviaKey;
346 346
 		$Common = new Common();
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 	}
367 367
 
368 368
 	/**
369
-	* Get flight info from Tunisair
370
-	* @param String $callsign The callsign
371
-	* @return Flight departure and arrival airports and time
372
-	*/
369
+	 * Get flight info from Tunisair
370
+	 * @param String $callsign The callsign
371
+	 * @return Flight departure and arrival airports and time
372
+	 */
373 373
 	public function getTunisair($callsign) {
374 374
 		$Common = new Common();
375 375
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -386,10 +386,10 @@  discard block
 block discarded – undo
386 386
 	}
387 387
 
388 388
 	/**
389
-	* Get flight info from Vueling
390
-	* @param String $callsign The callsign
391
-	* @return Flight departure and arrival airports and time
392
-	*/
389
+	 * Get flight info from Vueling
390
+	 * @param String $callsign The callsign
391
+	 * @return Flight departure and arrival airports and time
392
+	 */
393 393
 	public function getVueling($callsign,$date = 'NOW') {
394 394
 		$Common = new Common();
395 395
 		$check_date = new Datetime($date);
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
 	}
412 412
 
413 413
 	/**
414
-	* Get flight info from Iberia
415
-	* @param String $callsign The callsign
416
-	* @param String $date date we want flight number info
417
-	* @return Flight departure and arrival airports and time
418
-	*/
414
+	 * Get flight info from Iberia
415
+	 * @param String $callsign The callsign
416
+	 * @param String $date date we want flight number info
417
+	 * @return Flight departure and arrival airports and time
418
+	 */
419 419
 	public function getIberia($callsign, $date = 'NOW') {
420 420
 		$Common = new Common();
421 421
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -445,11 +445,11 @@  discard block
 block discarded – undo
445 445
 	}
446 446
 
447 447
 	/**
448
-	* Get flight info from Star Alliance
449
-	* @param String $callsign The callsign
450
-	* @param String $date date we want flight number info
451
-	* @return Flight departure and arrival airports and time
452
-	*/
448
+	 * Get flight info from Star Alliance
449
+	 * @param String $callsign The callsign
450
+	 * @param String $date date we want flight number info
451
+	 * @return Flight departure and arrival airports and time
452
+	 */
453 453
 
454 454
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
455 455
 		$Common = new Common();
@@ -481,11 +481,11 @@  discard block
 block discarded – undo
481 481
 
482 482
 
483 483
 	/**
484
-	* Get flight info from Alitalia
485
-	* @param String $callsign The callsign
486
-	* @param String $date date we want flight number info
487
-	* @return Flight departure and arrival airports and time
488
-	*/
484
+	 * Get flight info from Alitalia
485
+	 * @param String $callsign The callsign
486
+	 * @param String $date date we want flight number info
487
+	 * @return Flight departure and arrival airports and time
488
+	 */
489 489
 	private function getAlitalia($callsign, $date = 'NOW') {
490 490
 		$Common = new Common();
491 491
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
 	}
505 505
 
506 506
 	/**
507
-	* Get flight info from Brussels airlines
508
-	* @param String $callsign The callsign
509
-	* @param String $date date we want flight number info
510
-	* @return Flight departure and arrival airports and time
511
-	*/
507
+	 * Get flight info from Brussels airlines
508
+	 * @param String $callsign The callsign
509
+	 * @param String $date date we want flight number info
510
+	 * @return Flight departure and arrival airports and time
511
+	 */
512 512
 	private function getBrussels($callsign, $date = 'NOW') {
513 513
 		$Common = new Common();
514 514
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -518,24 +518,24 @@  discard block
 block discarded – undo
518 518
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
519 519
 		$data = $Common->getData($url);
520 520
 		if ($data != '') {
521
-		    //echo $data;
522
-		    $parsed_json = json_decode($data);
523
-		    if (isset($parsed_json[0]->FromAirportCode)) {
521
+			//echo $data;
522
+			$parsed_json = json_decode($data);
523
+			if (isset($parsed_json[0]->FromAirportCode)) {
524 524
 			$DepartureAirportIata = $parsed_json[0]->FromAirportCode;
525 525
 			$ArrivalAirportIata = $parsed_json[0]->ToAirportCode;
526 526
 			$departureTime = date('H:i',strtotime($parsed_json[0]->ScheduledDepatureDate));
527 527
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]->ScheduledArrivalDate));
528 528
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
529
-		    }
529
+			}
530 530
 		}
531 531
 	}
532 532
 
533 533
 	/**
534
-	* Get flight info from FlightRadar24
535
-	* @param String $callsign The callsign
536
-	* @param String $date date we want flight number info
537
-	* @return Flight departure and arrival airports and time
538
-	*/
534
+	 * Get flight info from FlightRadar24
535
+	 * @param String $callsign The callsign
536
+	 * @param String $date date we want flight number info
537
+	 * @return Flight departure and arrival airports and time
538
+	 */
539 539
 /*
540 540
 	public function getFlightRadar24($callsign, $date = 'NOW') {
541 541
 		$Common = new Common();
@@ -564,11 +564,11 @@  discard block
 block discarded – undo
564 564
 	}
565 565
   */
566 566
 	/**
567
-	* Get flight info from Lufthansa
568
-	* @param String $callsign The callsign
569
-	* @param String $date date we want flight number info
570
-	* @return Flight departure and arrival airports and time
571
-	*/
567
+	 * Get flight info from Lufthansa
568
+	 * @param String $callsign The callsign
569
+	 * @param String $date date we want flight number info
570
+	 * @return Flight departure and arrival airports and time
571
+	 */
572 572
 
573 573
 /*	private function getLufthansa($callsign, $date = 'NOW') {
574 574
 		$Common = new Common();
@@ -596,10 +596,10 @@  discard block
 block discarded – undo
596 596
 	}
597 597
   */
598 598
 	/**
599
-	* Get flight info from flytap
600
-	* @param String $callsign The callsign
601
-	* @return Flight departure and arrival airports and time
602
-	*/
599
+	 * Get flight info from flytap
600
+	 * @param String $callsign The callsign
601
+	 * @return Flight departure and arrival airports and time
602
+	 */
603 603
 	private function getFlyTap($callsign) {
604 604
 		$Common = new Common();
605 605
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -622,10 +622,10 @@  discard block
 block discarded – undo
622 622
 	}
623 623
 
624 624
 	/**
625
-	* Get flight info from flightmapper
626
-	* @param String $callsign The callsign
627
-	* @return Flight departure and arrival airports and time
628
-	*/
625
+	 * Get flight info from flightmapper
626
+	 * @param String $callsign The callsign
627
+	 * @return Flight departure and arrival airports and time
628
+	 */
629 629
 	public function getFlightMapper($callsign) {
630 630
 		$Common = new Common();
631 631
 		$airline_icao = '';
@@ -653,11 +653,11 @@  discard block
 block discarded – undo
653 653
 				$aarr = '';
654 654
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
655 655
 				if ($n == 7) {
656
-				    $departureTime = $dhour;
657
-				    $arrivalTime = $ahour;
658
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
659
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
660
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
656
+					$departureTime = $dhour;
657
+					$arrivalTime = $ahour;
658
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
659
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
660
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
661 661
 				}
662 662
 			}
663 663
 		}
@@ -665,10 +665,10 @@  discard block
 block discarded – undo
665 665
 	}
666 666
 
667 667
 	/**
668
-	* Get flight info from flightaware
669
-	* @param String $callsign The callsign
670
-	* @return Flight departure and arrival airports and time
671
-	*/
668
+	 * Get flight info from flightaware
669
+	 * @param String $callsign The callsign
670
+	 * @return Flight departure and arrival airports and time
671
+	 */
672 672
 	public function getFlightAware($callsign) {
673 673
 		$Common = new Common();
674 674
 		/*
@@ -701,10 +701,10 @@  discard block
 block discarded – undo
701 701
 	}
702 702
 
703 703
 	/**
704
-	* Get flight info from CostToTravel
705
-	* @param String $callsign The callsign
706
-	* @return Flight departure and arrival airports and time
707
-	*/
704
+	 * Get flight info from CostToTravel
705
+	 * @param String $callsign The callsign
706
+	 * @return Flight departure and arrival airports and time
707
+	 */
708 708
 	public function getCostToTravel($callsign) {
709 709
 		$Common = new Common();
710 710
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -726,11 +726,11 @@  discard block
 block discarded – undo
726 726
 	}
727 727
 
728 728
 	/**
729
-	* Get flight info from Air Canada
730
-	* @param String $callsign The callsign
731
-	* @param String $date date we want flight number info
732
-	* @return Flight departure and arrival airports and time
733
-	*/
729
+	 * Get flight info from Air Canada
730
+	 * @param String $callsign The callsign
731
+	 * @param String $date date we want flight number info
732
+	 * @return Flight departure and arrival airports and time
733
+	 */
734 734
 	private function getAirCanada($callsign,$date = 'NOW') {
735 735
 		$Common = new Common();
736 736
 		date_default_timezone_set('UTC');
@@ -754,11 +754,11 @@  discard block
 block discarded – undo
754 754
 	}
755 755
 
756 756
 	/**
757
-	* Get flight info from Vietnam Airlines
758
-	* @param String $callsign The callsign
759
-	* @param String $date date we want flight number info
760
-	* @return Flight departure and arrival airports and time
761
-	*/
757
+	 * Get flight info from Vietnam Airlines
758
+	 * @param String $callsign The callsign
759
+	 * @param String $date date we want flight number info
760
+	 * @return Flight departure and arrival airports and time
761
+	 */
762 762
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
763 763
 		$Common = new Common();
764 764
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -780,12 +780,12 @@  discard block
 block discarded – undo
780 780
 	}
781 781
 
782 782
 	/**
783
-	* Get flight info from Air Berlin
784
-	* @param String $callsign The callsign
785
-	* @param String $date date we want flight number info
786
-	* @param String $carrier airline code
787
-	* @return Flight departure and arrival airports and time
788
-	*/
783
+	 * Get flight info from Air Berlin
784
+	 * @param String $callsign The callsign
785
+	 * @param String $date date we want flight number info
786
+	 * @param String $carrier airline code
787
+	 * @return Flight departure and arrival airports and time
788
+	 */
789 789
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
790 790
 		$Common = new Common();
791 791
 		date_default_timezone_set('UTC');
@@ -814,11 +814,11 @@  discard block
 block discarded – undo
814 814
 			$table = $Common->table2array($data);
815 815
 			$flight = $table;
816 816
 			if (isset($flight[5][4])) {
817
-			    $arrivalTime = $flight[5][4];
818
-			    $arrivalAirport = $flight[5][3];
817
+				$arrivalTime = $flight[5][4];
818
+				$arrivalAirport = $flight[5][3];
819 819
 			} else {
820
-			    $arrivalTime = '';
821
-			    $arrivalAirport = '';
820
+				$arrivalTime = '';
821
+				$arrivalAirport = '';
822 822
 			}
823 823
 		} else return array();
824 824
 		$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';
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 					}
1087 1087
 			}
1088 1088
 		}
1089
-	        return array();
1089
+			return array();
1090 1090
 	}
1091 1091
 }
1092 1092
 
Please login to merge, or discard this patch.
Spacing   +169 added lines, -169 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);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		 try {
140 140
 			$sth = $this->db->prepare($query);
141 141
 			$sth->execute($query_values);
142
-		} catch(PDOException $e) {
142
+		} catch (PDOException $e) {
143 143
 			return "error : ".$e->getMessage();
144 144
 		}
145 145
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -153,16 +153,16 @@  discard block
 block discarded – undo
153 153
 	* @param String $carrier IATA code
154 154
 	* @return Flight departure and arrival airports and time
155 155
 	*/
156
-	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
156
+	private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
157 157
 		$Common = new Common();
158 158
 		$check_date = new Datetime($date);
159
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
160
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
159
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
160
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
161 161
 		$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 162
 		$json = $Common->getData($url);
163 163
 	
164 164
 		$parsed_json = json_decode($json);
165
-		if (property_exists($parsed_json,'errors') === false) {
165
+		if (property_exists($parsed_json, 'errors') === false) {
166 166
 			//$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
167 167
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
168 168
 			//$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 			//$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
173 173
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
174 174
 
175
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
175
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
176 176
 			$DepartureAirportIata = $originiata[1];
177
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
177
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
178 178
 			$ArrivalAirportIata = $destinationiata[1];
179 179
 
180 180
 			/*
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
184 184
 			*/
185 185
 		
186
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
186
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
187 187
 		} else return array();
188 188
 	}
189 189
 
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 		$Common = new Common();
199 199
 		date_default_timezone_set($globalTimezone);
200 200
 		$check_date = new Datetime($date);
201
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
202
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
201
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
202
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
203 203
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
204 204
 		$json = $Common->getData($url);
205 205
 		$parsed_json = json_decode($json);
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
212 212
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
213 213
 
214
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
214
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
215 215
 		} else return array();
216 216
 	}
217 217
 
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 	*/
223 223
 	private function getRyanair($callsign) {
224 224
 		$Common = new Common();
225
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
226
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
225
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
226
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
227 227
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
228 228
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
229
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
230
-		$json = $Common->getData($url,'post',$post,$headers);
229
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
230
+		$json = $Common->getData($url, 'post', $post, $headers);
231 231
 		$parsed_json = json_decode($json);
232 232
 		if (isset($parsed_json->{'flightInfo'})) {
233 233
 			$flights = $parsed_json->{'flightInfo'};
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
237 237
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
238 238
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
239
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
239
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
240 240
 			} else return array();
241 241
 		} else return array();
242 242
 	}
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	*/
249 249
 	private function getSwiss($callsign) {
250 250
 		$Common = new Common();
251
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
252
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
251
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
252
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
253 253
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
254 254
 		$json = $Common->getData($url);
255 255
 		$parsed_json = json_decode($json);
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
264 264
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
265 265
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
266
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
267
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
266
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
267
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
268 268
 				}
269 269
 			}
270 270
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
271
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
271
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
272 272
 			} else return array();
273 273
 		} else return array();
274 274
 	}
@@ -283,21 +283,21 @@  discard block
 block discarded – undo
283 283
 		global $globalBritishAirwaysKey;
284 284
 		$Common = new Common();
285 285
 		$check_date = new Datetime($date);
286
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
287
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
286
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
287
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
288 288
 		if ($globalBritishAirwaysKey == '') return array();
289 289
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
290 290
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
291
-		$json = $Common->getData($url,'get','',$headers);
291
+		$json = $Common->getData($url, 'get', '', $headers);
292 292
 		if ($json == '') return array();
293 293
 		$parsed_json = json_decode($json);
294 294
 		$flights = $parsed_json->{'FlightsResponse'};
295 295
 		if (count($flights) > 0) {
296 296
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
297 297
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
298
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
299
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
300
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
298
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
299
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
300
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
301 301
 		} else return array();
302 302
 	}
303 303
 
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
311 311
 		global $globalLufthansaKey;
312 312
 		$Common = new Common();
313 313
 		$check_date = new Datetime($date);
314
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
315
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
314
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
315
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
316 316
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
317 317
 		$url = "https://api.lufthansa.com/v1/oauth/token";
318
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
319
-		$data = $Common->getData($url,'post',$post);
318
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
319
+		$data = $Common->getData($url, 'post', $post);
320 320
 		$parsed_data = json_decode($data);
321 321
 		if (!isset($parsed_data->{'access_token'})) return array();
322 322
 		$token = $parsed_data->{'access_token'};
323 323
 		
324 324
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
325
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
326
-		$json = $Common->getData($url,'get','',$headers);
325
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
326
+		$json = $Common->getData($url, 'get', '', $headers);
327 327
 		if ($json == '') return array();
328 328
 		$parsed_json = json_decode($json);
329 329
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
330 330
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
331
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
331
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
332 332
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
333
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
334
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
333
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
334
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
335 335
 		} else return array();
336 336
 	}
337 337
 
@@ -345,23 +345,23 @@  discard block
 block discarded – undo
345 345
 		global $globalTransaviaKey;
346 346
 		$Common = new Common();
347 347
 		$check_date = new Datetime($date);
348
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
349
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
348
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
349
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
350 350
 		if ($globalTransaviaKey == '') return array();
351 351
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
352 352
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
353 353
 		$headers = array('apikey: '.$globalTransaviaKey);
354
-		$json = $Common->getData($url,'get','',$headers);
354
+		$json = $Common->getData($url, 'get', '', $headers);
355 355
 		//echo 'result : '.$json;
356 356
 		if ($json == '') return array();
357 357
 		$parsed_json = json_decode($json);
358 358
 		
359 359
 		if (isset($parsed_json->{'data'}[0])) {
360 360
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
361
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
361
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
362 362
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
363
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
364
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
363
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
364
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
365 365
 		} else return array();
366 366
 	}
367 367
 
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 	*/
373 373
 	public function getTunisair($callsign) {
374 374
 		$Common = new Common();
375
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
376
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
375
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
376
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
377 377
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
378 378
 		$data = $Common->getData($url);
379 379
 		$table = $Common->table2array($data);
380 380
 		foreach ($table as $flight) {
381
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
382
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
381
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
382
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
383 383
 			}
384 384
 		}
385 385
 		return array();
@@ -390,21 +390,21 @@  discard block
 block discarded – undo
390 390
 	* @param String $callsign The callsign
391 391
 	* @return Flight departure and arrival airports and time
392 392
 	*/
393
-	public function getVueling($callsign,$date = 'NOW') {
393
+	public function getVueling($callsign, $date = 'NOW') {
394 394
 		$Common = new Common();
395 395
 		$check_date = new Datetime($date);
396
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
397
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
398
-		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
396
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
397
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
398
+		$final_date = str_replace('/', '%2F', $check_date->format('d/m/Y'));
399 399
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
400 400
 		$data = $Common->getData($url);
401
-		$data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data));
401
+		$data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data));
402 402
 		if ($data != '') {
403
-			preg_match('/flightOri=[A-Z]{3}/',$data,$result);
404
-			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
405
-			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
406
-			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
407
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
403
+			preg_match('/flightOri=[A-Z]{3}/', $data, $result);
404
+			$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
405
+			preg_match('/flightDest=[A-Z]{3}/', $data, $result);
406
+			$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
407
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling');
408 408
 			else return array();
409 409
 		}
410 410
 		return array();
@@ -418,27 +418,27 @@  discard block
 block discarded – undo
418 418
 	*/
419 419
 	public function getIberia($callsign, $date = 'NOW') {
420 420
 		$Common = new Common();
421
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
421
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
422 422
 		$check_date = new Datetime($date);
423
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
423
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
424 424
 		$url = "https://www.iberia.com/web/flightDetail.do";
425
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
426
-		$data = $Common->getData($url,'post',$post);
425
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
426
+		$data = $Common->getData($url, 'post', $post);
427 427
 		if ($data != '') {
428 428
 			$table = $Common->table2array($data);
429 429
 			//print_r($table);
430 430
 			if (count($table) > 0) {
431 431
 				$flight = $table;
432
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
433
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
432
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
433
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
434 434
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
435 435
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
436
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
437
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
436
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
437
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
438 438
 				if ($arrivalTime == 'Hora estimada de llegada') {
439
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
440
-				} else $arrivalTime = substr($arrivalTime,0,5);
441
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
439
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
440
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
441
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
442 442
 			}
443 443
 		}
444 444
 		return array();
@@ -451,11 +451,11 @@  discard block
 block discarded – undo
451 451
 	* @return Flight departure and arrival airports and time
452 452
 	*/
453 453
 
454
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
454
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
455 455
 		$Common = new Common();
456
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
456
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
457 457
 		$check_date = new Datetime($date);
458
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
458
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
459 459
 		$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 460
 		$data = $Common->getData($url);
461 461
 		if ($data != '') {
@@ -464,13 +464,13 @@  discard block
 block discarded – undo
464 464
 				$flight = $table;
465 465
 				//print_r($table);
466 466
 				if (isset($flight[25]) && isset($flight[29])) {
467
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
468
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
467
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
468
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
469 469
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
470 470
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
471
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
472
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
473
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
471
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
472
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
473
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
474 474
 				} else return array();
475 475
 			}
476 476
 			
@@ -488,10 +488,10 @@  discard block
 block discarded – undo
488 488
 	*/
489 489
 	private function getAlitalia($callsign, $date = 'NOW') {
490 490
 		$Common = new Common();
491
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
491
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
492 492
 		$check_date = new Datetime($date);
493
-		$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();
493
+		$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();
495 495
 		$data = $Common->getData($url);
496 496
 		if ($data != '') {
497 497
 			$table = $Common->text2array($data);
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 			$ArrivalAirportIata = '';
500 500
 			$departureTime = $table[4];
501 501
 			$arrivalTime = $table[5];
502
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
502
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
503 503
 		}
504 504
 	}
505 505
 
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 	*/
512 512
 	private function getBrussels($callsign, $date = 'NOW') {
513 513
 		$Common = new Common();
514
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
514
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
515 515
 		$check_date = new Datetime($date);
516
-		$url= "http://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";
516
+		$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 517
 		//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();
518
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
519 519
 		$data = $Common->getData($url);
520 520
 		if ($data != '') {
521 521
 		    //echo $data;
@@ -523,9 +523,9 @@  discard block
 block discarded – undo
523 523
 		    if (isset($parsed_json[0]->FromAirportCode)) {
524 524
 			$DepartureAirportIata = $parsed_json[0]->FromAirportCode;
525 525
 			$ArrivalAirportIata = $parsed_json[0]->ToAirportCode;
526
-			$departureTime = date('H:i',strtotime($parsed_json[0]->ScheduledDepatureDate));
527
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]->ScheduledArrivalDate));
528
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
526
+			$departureTime = date('H:i', strtotime($parsed_json[0]->ScheduledDepatureDate));
527
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]->ScheduledArrivalDate));
528
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
529 529
 		    }
530 530
 		}
531 531
 	}
@@ -602,21 +602,21 @@  discard block
 block discarded – undo
602 602
 	*/
603 603
 	private function getFlyTap($callsign) {
604 604
 		$Common = new Common();
605
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
606
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
605
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
606
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
607 607
 		//$check_date = new Datetime($date);
608
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
609
-		$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
-		$data = $Common->getData($url,'post',$post);
608
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
609
+		$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
+		$data = $Common->getData($url, 'post', $post);
611 611
 		if ($data != '') {
612 612
 			$table = $Common->table2array($data);
613
-			$departureTime = trim(substr($table[15][0],0,5));
614
-			$arrivalTime = trim(substr($table[35][0],0,5));
615
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
616
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
613
+			$departureTime = trim(substr($table[15][0], 0, 5));
614
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
615
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
616
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
617 617
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
618 618
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
619
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
619
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
620 620
 		}
621 621
 		return array();
622 622
 	}
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 			} 
639 639
 		}
640 640
 		if ($airline_icao == '') return array();
641
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
642
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
641
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
642
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
643 643
 		//$check_date = new Datetime($date);
644
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
644
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
645 645
 		$data = $Common->getData($url);
646 646
 		if ($data != '') {
647 647
 			$table = $Common->table2array($data);
@@ -651,13 +651,13 @@  discard block
 block discarded – undo
651 651
 				$darr = '';
652 652
 				$ahour = '';
653 653
 				$aarr = '';
654
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
654
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
655 655
 				if ($n == 7) {
656 656
 				    $departureTime = $dhour;
657 657
 				    $arrivalTime = $ahour;
658
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
659
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
660
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
658
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
659
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
660
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
661 661
 				}
662 662
 			}
663 663
 		}
@@ -681,20 +681,20 @@  discard block
 block discarded – undo
681 681
 			} 
682 682
 		}
683 683
 		*/
684
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
685
-		$url= "http://fr.flightaware.com/live/flight/".$callsign;
684
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
685
+		$url = "http://fr.flightaware.com/live/flight/".$callsign;
686 686
 		//$check_date = new Datetime($date);
687
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
687
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
688 688
 		$data = $Common->getData($url);
689 689
 		if ($data != '') {
690 690
 			$table = $Common->table2array($data);
691 691
 			if (isset($table[11][0])) {
692
-				$departureTime = str_replace('h',':',substr($table[5][0],0,5));
693
-				$arrivalTime = str_replace('h',':',substr($table[5][1],0,5));
692
+				$departureTime = str_replace('h', ':', substr($table[5][0], 0, 5));
693
+				$arrivalTime = str_replace('h', ':', substr($table[5][1], 0, 5));
694 694
 				echo $table[3][0];
695
-				sscanf($table[3][0],'%*[^(] (%3[A-Z] / %*4[A-Z])',$DepartureAirportIata);
696
-				sscanf($table[3][1],'%*[^(] (%3[A-Z] / %*4[A-Z])',$ArrivalAirportIata);
697
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightaware');
695
+				sscanf($table[3][0], '%*[^(] (%3[A-Z] / %*4[A-Z])', $DepartureAirportIata);
696
+				sscanf($table[3][1], '%*[^(] (%3[A-Z] / %*4[A-Z])', $ArrivalAirportIata);
697
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightaware');
698 698
 			}
699 699
 		}
700 700
 		return array();
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 	*/
708 708
 	public function getCostToTravel($callsign) {
709 709
 		$Common = new Common();
710
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
710
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
711 711
 		//$check_date = new Datetime($date);
712 712
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
713 713
 		$data = $Common->getData($url);
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
 			$table = $Common->table2array($data);
716 716
 			//print_r($table);
717 717
 			if (isset($table[11][1])) {
718
-				$departureTime = substr($table[11][1],0,5);
719
-				$arrivalTime = substr($table[17][1],0,5);
720
-				$DepartureAirportIata = substr($table[13][1],0,3);
721
-				$ArrivalAirportIata = substr($table[15][1],0,3);
722
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
718
+				$departureTime = substr($table[11][1], 0, 5);
719
+				$arrivalTime = substr($table[17][1], 0, 5);
720
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
721
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
722
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
723 723
 			}
724 724
 		}
725 725
 		return array();
@@ -731,13 +731,13 @@  discard block
 block discarded – undo
731 731
 	* @param String $date date we want flight number info
732 732
 	* @return Flight departure and arrival airports and time
733 733
 	*/
734
-	private function getAirCanada($callsign,$date = 'NOW') {
734
+	private function getAirCanada($callsign, $date = 'NOW') {
735 735
 		$Common = new Common();
736 736
 		date_default_timezone_set('UTC');
737 737
 		$check_date = new Datetime($date);
738
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
739
-		$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();
738
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
739
+		$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();
741 741
 		$data = $Common->getData($url);
742 742
 		$dom = new DomDocument();
743 743
 		$dom->loadXML($data);
@@ -745,11 +745,11 @@  discard block
 block discarded – undo
745 745
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
746 746
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
747 747
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
748
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
748
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
749 749
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
750 750
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
751
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
752
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
751
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
752
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
753 753
 		} else return array();
754 754
 	}
755 755
 
@@ -761,21 +761,21 @@  discard block
 block discarded – undo
761 761
 	*/
762 762
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
763 763
 		$Common = new Common();
764
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
764
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
765 765
 		$check_date = new Datetime($date);
766
-		$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();
766
+		$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();
768 768
 		$data = $Common->getData($url);
769 769
 		if ($data != '') {
770 770
 			$table = $Common->table2array($data);
771 771
 			$flight = $table;
772
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
773
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
772
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
773
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
774 774
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
775 775
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
776 776
 			$departureTime = $flight[5][1];
777 777
 			$arrivalTime = $flight[23][1];
778
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
778
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
779 779
 		}
780 780
 	}
781 781
 
@@ -786,16 +786,16 @@  discard block
 block discarded – undo
786 786
 	* @param String $carrier airline code
787 787
 	* @return Flight departure and arrival airports and time
788 788
 	*/
789
-	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
789
+	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
790 790
 		$Common = new Common();
791 791
 		date_default_timezone_set('UTC');
792 792
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
793
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
793
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
794 794
 		$check_date = new Datetime($date);
795
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
796
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
797
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
798
-		$data = $Common->getData($url,'post',$post);
795
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
796
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
797
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier);
798
+		$data = $Common->getData($url, 'post', $post);
799 799
 		//echo $data;
800 800
 		$DepartureAirportIata = '';
801 801
 		$ArrivalAirportIata = '';
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
809 809
 			else $departureAirport = '';
810 810
 		} else return array();
811
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
812
-		$data = $Common->getData($url,'post',$post);
811
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
812
+		$data = $Common->getData($url, 'post', $post);
813 813
 		if ($data != '') {
814 814
 			$table = $Common->table2array($data);
815 815
 			$flight = $table;
@@ -837,13 +837,13 @@  discard block
 block discarded – undo
837 837
 			}
838 838
 		}
839 839
 		if (isset($DepartureAirportIata)) {
840
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
840
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
841 841
 		} else return array();
842 842
 	}
843 843
 
844 844
 
845 845
 	
846
-	public function fetchSchedule($ident,$date = 'NOW') {
846
+	public function fetchSchedule($ident, $date = 'NOW') {
847 847
 		global $globalSchedulesSources, $globalSchedulesFetch;
848 848
 		//$Common = new Common();
849 849
 		if (!$globalSchedulesFetch) return array();
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 				// Brussels Airlines
914 914
 				case "BEL":
915 915
 				case "SN":
916
-					return $this->getBrussels($ident,$date);
916
+					return $this->getBrussels($ident, $date);
917 917
 /*
918 918
 				// Copa Airlines
919 919
 				case "CMP":
@@ -998,17 +998,17 @@  discard block
 block discarded – undo
998 998
 				// Air France
999 999
 				case "AF":
1000 1000
 				case "AFR":
1001
-					return $this->getAirFrance($ident,$date,'AF');
1001
+					return $this->getAirFrance($ident, $date, 'AF');
1002 1002
 				// HOP
1003 1003
 				case "A5":
1004 1004
 				case "HOP":
1005
-					return $this->getAirFrance($ident,$date,'A5');
1005
+					return $this->getAirFrance($ident, $date, 'A5');
1006 1006
 				// EasyJet
1007 1007
 				case "U2":
1008 1008
 				case "DS":
1009 1009
 				case "EZY":
1010 1010
 				case "EZS":
1011
-					return $this->getEasyJet($ident,$date);
1011
+					return $this->getEasyJet($ident, $date);
1012 1012
 				// Ryanair
1013 1013
 				case "FR":
1014 1014
 				case "RYR":
@@ -1058,25 +1058,25 @@  discard block
 block discarded – undo
1058 1058
 					return $this->getIberia($ident);
1059 1059
 				// Vietnam Airlines
1060 1060
 				case "HVN":
1061
-					return $this->getVietnamAirlines($ident,$date);
1061
+					return $this->getVietnamAirlines($ident, $date);
1062 1062
 				// Air Berlin
1063 1063
 				case "AB":
1064 1064
 				case "BER":
1065
-					return $this->getAirBerlin($ident,$date,'AB');
1065
+					return $this->getAirBerlin($ident, $date, 'AB');
1066 1066
 				// NIKI
1067 1067
 				case "HG":
1068 1068
 				case "NLY":
1069
-					return $this->getAirBerlin($ident,$date,'HG');
1069
+					return $this->getAirBerlin($ident, $date, 'HG');
1070 1070
 				// BelAir
1071 1071
 				case "4T":
1072 1072
 				case "BHP":
1073
-					return $this->getAirBerlin($ident,$date,'4T');
1073
+					return $this->getAirBerlin($ident, $date, '4T');
1074 1074
 				default:
1075 1075
 					// Randomly use a generic function to get hours
1076 1076
 					if (strlen($airline_icao) == 2) {
1077
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1077
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1078 1078
 						if (count($globalSchedulesSources) > 0) {
1079
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1079
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1080 1080
 							$source = $globalSchedulesSources[$rand];
1081 1081
 							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1082 1082
 							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
Please login to merge, or discard this patch.
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.
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   +346 added lines, -346 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")) {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 			}
145 145
 			if ($globalTransaction) $Connection->db->commit();
146 146
 		}
147
-                return '';
147
+				return '';
148 148
 	}
149 149
 	
150 150
 	public static function retrieve_route_skyteam($database_file) {
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
 		try {
157 157
 			//$Connection = new Connection();
158 158
 			$sth = $Connection->db->prepare($query);
159
-                        $sth->execute(array(':source' => 'skyteam'));
160
-                } catch(PDOException $e) {
161
-                        return "error : ".$e->getMessage();
162
-                }
159
+						$sth->execute(array(':source' => 'skyteam'));
160
+				} catch(PDOException $e) {
161
+						return "error : ".$e->getMessage();
162
+				}
163 163
 
164
-    		if ($globalDebug) echo " - Add routes to DB -";
164
+			if ($globalDebug) echo " - Add routes to DB -";
165 165
 
166 166
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
167 167
 		$Spotter = new Spotter();
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 				return "error : ".$e->getMessage();
185 185
 			}
186 186
 		}
187
-                return '';
187
+				return '';
188 188
 	}
189 189
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
190 190
 		global $globalTransaction;
@@ -193,27 +193,27 @@  discard block
 block discarded – undo
193 193
 		try {
194 194
 			$Connection = new Connection();
195 195
 			$sth = $Connection->db->prepare($query);
196
-                        $sth->execute(array(':source' => $database_file));
197
-                } catch(PDOException $e) {
198
-                        return "error : ".$e->getMessage();
199
-                }
196
+						$sth->execute(array(':source' => $database_file));
197
+				} catch(PDOException $e) {
198
+						return "error : ".$e->getMessage();
199
+				}
200 200
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
201 201
 		try {
202 202
 			$Connection = new Connection();
203 203
 			$sth = $Connection->db->prepare($query);
204
-                        $sth->execute(array(':source' => $database_file));
205
-                } catch(PDOException $e) {
206
-                        return "error : ".$e->getMessage();
207
-                }
204
+						$sth->execute(array(':source' => $database_file));
205
+				} catch(PDOException $e) {
206
+						return "error : ".$e->getMessage();
207
+				}
208 208
 
209
-    		update_db::connect_sqlite($database_file);
209
+			update_db::connect_sqlite($database_file);
210 210
 		$query = 'select * from Aircraft';
211 211
 		try {
212
-                        $sth = update_db::$db_sqlite->prepare($query);
213
-                        $sth->execute();
214
-                } catch(PDOException $e) {
215
-                        return "error : ".$e->getMessage();
216
-                }
212
+						$sth = update_db::$db_sqlite->prepare($query);
213
+						$sth->execute();
214
+				} catch(PDOException $e) {
215
+						return "error : ".$e->getMessage();
216
+				}
217 217
 		//$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)';
218 218
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
219 219
 		
@@ -224,17 +224,17 @@  discard block
 block discarded – undo
224 224
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
225 225
 		try {
226 226
 			if ($globalTransaction) $Connection->db->beginTransaction();
227
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
227
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
228 228
 			//$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']);
229 229
 				if ($values['UserString4'] == 'M') $type = 'military';
230 230
 				else $type = null;
231 231
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
232 232
 				$sth_dest->execute($query_dest_values);
233 233
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
234
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
235
-				    $sth_dest_owner->execute($query_dest_owner_values);
234
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
235
+					$sth_dest_owner->execute($query_dest_owner_values);
236 236
 				}
237
-            		}
237
+					}
238 238
 			if ($globalTransaction) $Connection->db->commit();
239 239
 		} catch(PDOException $e) {
240 240
 			return "error : ".$e->getMessage();
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 		try {
245 245
 			$Connection = new Connection();
246 246
 			$sth = $Connection->db->prepare($query);
247
-                        $sth->execute(array(':source' => $database_file));
248
-                } catch(PDOException $e) {
249
-                        return "error : ".$e->getMessage();
250
-                }
247
+						$sth->execute(array(':source' => $database_file));
248
+				} catch(PDOException $e) {
249
+						return "error : ".$e->getMessage();
250
+				}
251 251
 		return '';
252 252
 	}
253 253
 
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 		try {
260 260
 			$Connection = new Connection();
261 261
 			$sth = $Connection->db->prepare($query);
262
-                        $sth->execute(array(':source' => $database_file));
263
-                } catch(PDOException $e) {
264
-                        return "error : ".$e->getMessage();
265
-                }
262
+						$sth->execute(array(':source' => $database_file));
263
+				} catch(PDOException $e) {
264
+						return "error : ".$e->getMessage();
265
+				}
266 266
 		
267 267
 		if ($fh = fopen($database_file,"r")) {
268 268
 			//$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)';
@@ -272,26 +272,26 @@  discard block
 block discarded – undo
272 272
 			$sth_dest = $Connection->db->prepare($query_dest);
273 273
 			try {
274 274
 				if ($globalTransaction) $Connection->db->beginTransaction();
275
-            			while (!feof($fh)) {
276
-            				$values = array();
277
-            				$line = $Common->hex2str(fgets($fh,9999));
275
+						while (!feof($fh)) {
276
+							$values = array();
277
+							$line = $Common->hex2str(fgets($fh,9999));
278 278
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
279
-            				$values['ModeS'] = substr($line,0,6);
280
-            				$values['Registration'] = trim(substr($line,69,6));
281
-            				$aircraft_name = trim(substr($line,48,6));
282
-            				// Check if we can find ICAO, else set it to GLID
283
-            				$aircraft_name_split = explode(' ',$aircraft_name);
284
-            				$search_more = '';
285
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
286
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
287
-            				$sth_search = $Connection->db->prepare($query_search);
279
+							$values['ModeS'] = substr($line,0,6);
280
+							$values['Registration'] = trim(substr($line,69,6));
281
+							$aircraft_name = trim(substr($line,48,6));
282
+							// Check if we can find ICAO, else set it to GLID
283
+							$aircraft_name_split = explode(' ',$aircraft_name);
284
+							$search_more = '';
285
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
286
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
287
+							$sth_search = $Connection->db->prepare($query_search);
288 288
 					try {
289
-                                    		$sth_search->execute();
290
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
291
-	            				//if (count($result) > 0) {
292
-	            				if (isset($result['icao']) && $result['icao'] != '') {
293
-	            				    $values['ICAOTypeCode'] = $result['icao'];
294
-	            				} 
289
+											$sth_search->execute();
290
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
291
+								//if (count($result) > 0) {
292
+								if (isset($result['icao']) && $result['icao'] != '') {
293
+									$values['ICAOTypeCode'] = $result['icao'];
294
+								} 
295 295
 					} catch(PDOException $e) {
296 296
 						return "error : ".$e->getMessage();
297 297
 					}
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
 		try {
315 315
 			$Connection = new Connection();
316 316
 			$sth = $Connection->db->prepare($query);
317
-                        $sth->execute(array(':source' => $database_file));
318
-                } catch(PDOException $e) {
319
-                        return "error : ".$e->getMessage();
320
-                }
317
+						$sth->execute(array(':source' => $database_file));
318
+				} catch(PDOException $e) {
319
+						return "error : ".$e->getMessage();
320
+				}
321 321
 		return '';
322 322
 	}
323 323
 
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
 		try {
329 329
 			$Connection = new Connection();
330 330
 			$sth = $Connection->db->prepare($query);
331
-                        $sth->execute(array(':source' => $database_file));
332
-                } catch(PDOException $e) {
333
-                        return "error : ".$e->getMessage();
334
-                }
331
+						$sth->execute(array(':source' => $database_file));
332
+				} catch(PDOException $e) {
333
+						return "error : ".$e->getMessage();
334
+				}
335 335
 		
336 336
 		if ($fh = fopen($database_file,"r")) {
337 337
 			//$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)';
@@ -342,24 +342,24 @@  discard block
 block discarded – undo
342 342
 			try {
343 343
 				if ($globalTransaction) $Connection->db->beginTransaction();
344 344
 				$tmp = fgetcsv($fh,9999,',',"'");
345
-            			while (!feof($fh)) {
346
-            				$line = fgetcsv($fh,9999,',',"'");
345
+						while (!feof($fh)) {
346
+							$line = fgetcsv($fh,9999,',',"'");
347 347
             				
348 348
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
349 349
 					//print_r($line);
350
-            				$values['ModeS'] = $line[1];
351
-            				$values['Registration'] = $line[3];
352
-            				$aircraft_name = $line[2];
353
-            				// Check if we can find ICAO, else set it to GLID
354
-            				$aircraft_name_split = explode(' ',$aircraft_name);
355
-            				$search_more = '';
356
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
357
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
358
-            				$sth_search = $Connection->db->prepare($query_search);
350
+							$values['ModeS'] = $line[1];
351
+							$values['Registration'] = $line[3];
352
+							$aircraft_name = $line[2];
353
+							// Check if we can find ICAO, else set it to GLID
354
+							$aircraft_name_split = explode(' ',$aircraft_name);
355
+							$search_more = '';
356
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
357
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
358
+							$sth_search = $Connection->db->prepare($query_search);
359 359
 					try {
360
-                                    		$sth_search->execute();
361
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
362
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
360
+											$sth_search->execute();
361
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
362
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
363 363
 					} catch(PDOException $e) {
364 364
 						return "error : ".$e->getMessage();
365 365
 					}
@@ -382,10 +382,10 @@  discard block
 block discarded – undo
382 382
 		try {
383 383
 			$Connection = new Connection();
384 384
 			$sth = $Connection->db->prepare($query);
385
-                        $sth->execute(array(':source' => $database_file));
386
-                } catch(PDOException $e) {
387
-                        return "error : ".$e->getMessage();
388
-                }
385
+						$sth->execute(array(':source' => $database_file));
386
+				} catch(PDOException $e) {
387
+						return "error : ".$e->getMessage();
388
+				}
389 389
 		return '';
390 390
 	}
391 391
 
@@ -396,10 +396,10 @@  discard block
 block discarded – undo
396 396
 		try {
397 397
 			$Connection = new Connection();
398 398
 			$sth = $Connection->db->prepare($query);
399
-                        $sth->execute(array(':source' => $database_file));
400
-                } catch(PDOException $e) {
401
-                        return "error : ".$e->getMessage();
402
-                }
399
+						$sth->execute(array(':source' => $database_file));
400
+				} catch(PDOException $e) {
401
+						return "error : ".$e->getMessage();
402
+				}
403 403
 		
404 404
 		if ($fh = fopen($database_file,"r")) {
405 405
 			//$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)';
@@ -410,95 +410,95 @@  discard block
 block discarded – undo
410 410
 			try {
411 411
 				if ($globalTransaction) $Connection->db->beginTransaction();
412 412
 				$tmp = fgetcsv($fh,9999,',','"');
413
-            			while (!feof($fh)) {
414
-            				$line = fgetcsv($fh,9999,',','"');
415
-            				$values = array();
416
-            				//print_r($line);
417
-            				if ($country == 'F') {
418
-            				    $values['registration'] = $line[0];
419
-            				    $values['base'] = $line[4];
420
-            				    $values['owner'] = $line[5];
421
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
422
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
423
-					    $values['cancel'] = $line[7];
413
+						while (!feof($fh)) {
414
+							$line = fgetcsv($fh,9999,',','"');
415
+							$values = array();
416
+							//print_r($line);
417
+							if ($country == 'F') {
418
+								$values['registration'] = $line[0];
419
+								$values['base'] = $line[4];
420
+								$values['owner'] = $line[5];
421
+								if ($line[6] == '') $values['date_first_reg'] = null;
422
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
423
+						$values['cancel'] = $line[7];
424 424
 					} elseif ($country == 'EI') {
425
-					    // TODO : add modeS & reg to aircraft_modes
426
-            				    $values['registration'] = $line[0];
427
-            				    $values['base'] = $line[3];
428
-            				    $values['owner'] = $line[2];
429
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
430
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
431
-					    $values['cancel'] = '';
425
+						// TODO : add modeS & reg to aircraft_modes
426
+								$values['registration'] = $line[0];
427
+								$values['base'] = $line[3];
428
+								$values['owner'] = $line[2];
429
+								if ($line[1] == '') $values['date_first_reg'] = null;
430
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
431
+						$values['cancel'] = '';
432 432
 					} elseif ($country == 'HB') {
433
-					    // TODO : add modeS & reg to aircraft_modes
434
-            				    $values['registration'] = $line[0];
435
-            				    $values['base'] = null;
436
-            				    $values['owner'] = $line[5];
437
-            				    $values['date_first_reg'] = null;
438
-					    $values['cancel'] = '';
433
+						// TODO : add modeS & reg to aircraft_modes
434
+								$values['registration'] = $line[0];
435
+								$values['base'] = null;
436
+								$values['owner'] = $line[5];
437
+								$values['date_first_reg'] = null;
438
+						$values['cancel'] = '';
439 439
 					} elseif ($country == 'OK') {
440
-					    // TODO : add modeS & reg to aircraft_modes
441
-            				    $values['registration'] = $line[3];
442
-            				    $values['base'] = null;
443
-            				    $values['owner'] = $line[5];
444
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
445
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
446
-					    $values['cancel'] = '';
440
+						// TODO : add modeS & reg to aircraft_modes
441
+								$values['registration'] = $line[3];
442
+								$values['base'] = null;
443
+								$values['owner'] = $line[5];
444
+								if ($line[18] == '') $values['date_first_reg'] = null;
445
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
446
+						$values['cancel'] = '';
447 447
 					} elseif ($country == 'VH') {
448
-					    // TODO : add modeS & reg to aircraft_modes
449
-            				    $values['registration'] = $line[0];
450
-            				    $values['base'] = null;
451
-            				    $values['owner'] = $line[12];
452
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
453
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
454
-
455
-					    $values['cancel'] = $line[39];
448
+						// TODO : add modeS & reg to aircraft_modes
449
+								$values['registration'] = $line[0];
450
+								$values['base'] = null;
451
+								$values['owner'] = $line[12];
452
+								if ($line[28] == '') $values['date_first_reg'] = null;
453
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
454
+
455
+						$values['cancel'] = $line[39];
456 456
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
457
-            				    $values['registration'] = $line[0];
458
-            				    $values['base'] = null;
459
-            				    $values['owner'] = $line[4];
460
-            				    $values['date_first_reg'] = null;
461
-					    $values['cancel'] = '';
457
+								$values['registration'] = $line[0];
458
+								$values['base'] = null;
459
+								$values['owner'] = $line[4];
460
+								$values['date_first_reg'] = null;
461
+						$values['cancel'] = '';
462 462
 					} elseif ($country == 'CC') {
463
-            				    $values['registration'] = $line[0];
464
-            				    $values['base'] = null;
465
-            				    $values['owner'] = $line[6];
466
-            				    $values['date_first_reg'] = null;
467
-					    $values['cancel'] = '';
463
+								$values['registration'] = $line[0];
464
+								$values['base'] = null;
465
+								$values['owner'] = $line[6];
466
+								$values['date_first_reg'] = null;
467
+						$values['cancel'] = '';
468 468
 					} elseif ($country == 'HJ') {
469
-            				    $values['registration'] = $line[0];
470
-            				    $values['base'] = null;
471
-            				    $values['owner'] = $line[8];
472
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
473
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
474
-					    $values['cancel'] = '';
469
+								$values['registration'] = $line[0];
470
+								$values['base'] = null;
471
+								$values['owner'] = $line[8];
472
+								if ($line[7] == '') $values['date_first_reg'] = null;
473
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
474
+						$values['cancel'] = '';
475 475
 					} elseif ($country == 'PP') {
476
-            				    $values['registration'] = $line[0];
477
-            				    $values['base'] = null;
478
-            				    $values['owner'] = $line[4];
479
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
480
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
481
-					    $values['cancel'] = $line[7];
476
+								$values['registration'] = $line[0];
477
+								$values['base'] = null;
478
+								$values['owner'] = $line[4];
479
+								if ($line[6] == '') $values['date_first_reg'] = null;
480
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
481
+						$values['cancel'] = $line[7];
482 482
 					} elseif ($country == 'E7') {
483
-            				    $values['registration'] = $line[0];
484
-            				    $values['base'] = null;
485
-            				    $values['owner'] = $line[4];
486
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
487
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
488
-					    $values['cancel'] = '';
483
+								$values['registration'] = $line[0];
484
+								$values['base'] = null;
485
+								$values['owner'] = $line[4];
486
+								if ($line[5] == '') $values['date_first_reg'] = null;
487
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
488
+						$values['cancel'] = '';
489 489
 					} elseif ($country == '8Q') {
490
-            				    $values['registration'] = $line[0];
491
-            				    $values['base'] = null;
492
-            				    $values['owner'] = $line[3];
493
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
494
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
495
-					    $values['cancel'] = '';
490
+								$values['registration'] = $line[0];
491
+								$values['base'] = null;
492
+								$values['owner'] = $line[3];
493
+								if ($line[7] == '') $values['date_first_reg'] = null;
494
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
495
+						$values['cancel'] = '';
496 496
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
497
-            				    $values['registration'] = $line[0];
498
-            				    $values['base'] = null;
499
-            				    $values['owner'] = $line[3];
500
-            				    $values['date_first_reg'] = null;
501
-					    $values['cancel'] = '';
497
+								$values['registration'] = $line[0];
498
+								$values['base'] = null;
499
+								$values['owner'] = $line[3];
500
+								$values['date_first_reg'] = null;
501
+						$values['cancel'] = '';
502 502
 					}
503 503
 					if ($values['cancel'] == '' && $values['registration'] != null) {
504 504
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -620,20 +620,20 @@  discard block
 block discarded – undo
620 620
 		try {
621 621
 			$Connection = new Connection();
622 622
 			$sth = $Connection->db->prepare($query);
623
-                        $sth->execute();
624
-                } catch(PDOException $e) {
625
-                        return "error : ".$e->getMessage();
626
-                }
623
+						$sth->execute();
624
+				} catch(PDOException $e) {
625
+						return "error : ".$e->getMessage();
626
+				}
627 627
 
628 628
 
629 629
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
630 630
 		try {
631 631
 			$Connection = new Connection();
632 632
 			$sth = $Connection->db->prepare($query);
633
-                        $sth->execute();
634
-                } catch(PDOException $e) {
635
-                        return "error : ".$e->getMessage();
636
-                }
633
+						$sth->execute();
634
+				} catch(PDOException $e) {
635
+						return "error : ".$e->getMessage();
636
+				}
637 637
 
638 638
 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)
639 639
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
@@ -699,10 +699,10 @@  discard block
 block discarded – undo
699 699
 		try {
700 700
 			$Connection = new Connection();
701 701
 			$sth = $Connection->db->prepare($query);
702
-                        $sth->execute();
703
-                } catch(PDOException $e) {
704
-                        return "error : ".$e->getMessage();
705
-                }
702
+						$sth->execute();
703
+				} catch(PDOException $e) {
704
+						return "error : ".$e->getMessage();
705
+				}
706 706
 
707 707
 
708 708
 		if ($globalDebug) echo "Insert Not available Airport...\n";
@@ -712,10 +712,10 @@  discard block
 block discarded – undo
712 712
 		try {
713 713
 			$Connection = new Connection();
714 714
 			$sth = $Connection->db->prepare($query);
715
-                        $sth->execute($query_values);
716
-                } catch(PDOException $e) {
717
-                        return "error : ".$e->getMessage();
718
-                }
715
+						$sth->execute($query_values);
716
+				} catch(PDOException $e) {
717
+						return "error : ".$e->getMessage();
718
+				}
719 719
 		$i++;
720 720
 /*
721 721
 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 
830 830
 
831 831
 
832
-                return "success";
832
+				return "success";
833 833
 	}
834 834
 	
835 835
 	public static function translation() {
@@ -845,10 +845,10 @@  discard block
 block discarded – undo
845 845
 		try {
846 846
 			$Connection = new Connection();
847 847
 			$sth = $Connection->db->prepare($query);
848
-                        $sth->execute(array(':source' => 'translation.csv'));
849
-                } catch(PDOException $e) {
850
-                        return "error : ".$e->getMessage();
851
-                }
848
+						$sth->execute(array(':source' => 'translation.csv'));
849
+				} catch(PDOException $e) {
850
+						return "error : ".$e->getMessage();
851
+				}
852 852
 
853 853
 		
854 854
 		//update_db::unzip($out_file);
@@ -867,21 +867,21 @@  discard block
 block discarded – undo
867 867
 					$data = $row;
868 868
 					$operator = $data[2];
869 869
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
870
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
871
-                                                //echo substr($operator, 0, 2)."\n";;
872
-                                                if (count($airline_array) > 0) {
870
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
871
+												//echo substr($operator, 0, 2)."\n";;
872
+												if (count($airline_array) > 0) {
873 873
 							//print_r($airline_array);
874 874
 							$operator = $airline_array[0]['icao'].substr($operator,2);
875
-                                                }
876
-                                        }
875
+												}
876
+										}
877 877
 					
878 878
 					$operator_correct = $data[3];
879 879
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
880
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
881
-                                                if (count($airline_array) > 0) {
882
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
883
-                                            	}
884
-                                        }
880
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
881
+												if (count($airline_array) > 0) {
882
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
883
+												}
884
+										}
885 885
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
886 886
 					try {
887 887
 						$sth = $Connection->db->prepare($query);
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 			//$Connection->db->commit();
896 896
 		}
897 897
 		return '';
898
-        }
898
+		}
899 899
 	
900 900
 	public static function translation_fam() {
901 901
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -905,10 +905,10 @@  discard block
 block discarded – undo
905 905
 		try {
906 906
 			$Connection = new Connection();
907 907
 			$sth = $Connection->db->prepare($query);
908
-                        $sth->execute(array(':source' => 'website_fam'));
909
-                } catch(PDOException $e) {
910
-                        return "error : ".$e->getMessage();
911
-                }
908
+						$sth->execute(array(':source' => 'website_fam'));
909
+				} catch(PDOException $e) {
910
+						return "error : ".$e->getMessage();
911
+				}
912 912
 
913 913
 		
914 914
 		//update_db::unzip($out_file);
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 			//$Connection->db->commit();
938 938
 		}
939 939
 		return '';
940
-        }
940
+		}
941 941
 
942 942
 	public static function tle($filename,$tletype) {
943 943
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -948,10 +948,10 @@  discard block
 block discarded – undo
948 948
 		try {
949 949
 			$Connection = new Connection();
950 950
 			$sth = $Connection->db->prepare($query);
951
-                        $sth->execute(array(':source' => $filename));
952
-                } catch(PDOException $e) {
953
-                        return "error : ".$e->getMessage();
954
-                }
951
+						$sth->execute(array(':source' => $filename));
952
+				} catch(PDOException $e) {
953
+						return "error : ".$e->getMessage();
954
+				}
955 955
 		
956 956
 		$Connection = new Connection();
957 957
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -986,54 +986,54 @@  discard block
 block discarded – undo
986 986
 			//$Connection->db->commit();
987 987
 		}
988 988
 		return '';
989
-        }
989
+		}
990 990
 
991 991
 	/**
992
-        * Convert a HTML table to an array
993
-        * @param String $data HTML page
994
-        * @return Array array of the tables in HTML page
995
-        */
996
-        private static function table2array($data) {
997
-                $html = str_get_html($data);
998
-                $tabledata=array();
999
-                foreach($html->find('tr') as $element)
1000
-                {
1001
-                        $td = array();
1002
-                        foreach( $element->find('th') as $row)
1003
-                        {
1004
-                                $td [] = trim($row->plaintext);
1005
-                        }
1006
-                        $td=array_filter($td);
1007
-                        $tabledata[] = $td;
1008
-
1009
-                        $td = array();
1010
-                        $tdi = array();
1011
-                        foreach( $element->find('td') as $row)
1012
-                        {
1013
-                                $td [] = trim($row->plaintext);
1014
-                                $tdi [] = trim($row->innertext);
1015
-                        }
1016
-                        $td=array_filter($td);
1017
-                        $tdi=array_filter($tdi);
1018
-                    //    $tabledata[]=array_merge($td,$tdi);
1019
-                        $tabledata[]=$td;
1020
-                }
1021
-                return(array_filter($tabledata));
1022
-        }
1023
-
1024
-       /**
1025
-        * Get data from form result
1026
-        * @param String $url form URL
1027
-        * @return String the result
1028
-        */
1029
-        private static function getData($url) {
1030
-                $ch = curl_init();
1031
-                curl_setopt($ch, CURLOPT_URL, $url);
1032
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1033
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1034
-                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');
1035
-                return curl_exec($ch);
1036
-        }
992
+	 * Convert a HTML table to an array
993
+	 * @param String $data HTML page
994
+	 * @return Array array of the tables in HTML page
995
+	 */
996
+		private static function table2array($data) {
997
+				$html = str_get_html($data);
998
+				$tabledata=array();
999
+				foreach($html->find('tr') as $element)
1000
+				{
1001
+						$td = array();
1002
+						foreach( $element->find('th') as $row)
1003
+						{
1004
+								$td [] = trim($row->plaintext);
1005
+						}
1006
+						$td=array_filter($td);
1007
+						$tabledata[] = $td;
1008
+
1009
+						$td = array();
1010
+						$tdi = array();
1011
+						foreach( $element->find('td') as $row)
1012
+						{
1013
+								$td [] = trim($row->plaintext);
1014
+								$tdi [] = trim($row->innertext);
1015
+						}
1016
+						$td=array_filter($td);
1017
+						$tdi=array_filter($tdi);
1018
+					//    $tabledata[]=array_merge($td,$tdi);
1019
+						$tabledata[]=$td;
1020
+				}
1021
+				return(array_filter($tabledata));
1022
+		}
1023
+
1024
+	   /**
1025
+	    * Get data from form result
1026
+	    * @param String $url form URL
1027
+	    * @return String the result
1028
+	    */
1029
+		private static function getData($url) {
1030
+				$ch = curl_init();
1031
+				curl_setopt($ch, CURLOPT_URL, $url);
1032
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1033
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1034
+				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');
1035
+				return curl_exec($ch);
1036
+		}
1037 1037
 /*
1038 1038
 	public static function waypoints() {
1039 1039
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 			if ($globalTransaction) $Connection->db->commit();
1117 1117
 		}
1118 1118
 		return '';
1119
-        }
1119
+		}
1120 1120
 
1121 1121
 	public static function ivao_airlines($filename) {
1122 1122
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1125,10 +1125,10 @@  discard block
 block discarded – undo
1125 1125
 		try {
1126 1126
 			$Connection = new Connection();
1127 1127
 			$sth = $Connection->db->prepare($query);
1128
-                        $sth->execute();
1129
-                } catch(PDOException $e) {
1130
-                        return "error : ".$e->getMessage();
1131
-                }
1128
+						$sth->execute();
1129
+				} catch(PDOException $e) {
1130
+						return "error : ".$e->getMessage();
1131
+				}
1132 1132
 
1133 1133
 		$header = NULL;
1134 1134
 		$delimiter = ':';
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 			if ($globalTransaction) $Connection->db->commit();
1153 1153
 		}
1154 1154
 		return '';
1155
-        }
1155
+		}
1156 1156
 	
1157 1157
 	public static function update_airspace() {
1158 1158
 		global $tmp_dir, $globalDBdriver;
@@ -1162,11 +1162,11 @@  discard block
 block discarded – undo
1162 1162
 			$query = 'DROP TABLE airspace';
1163 1163
 			try {
1164 1164
 				$sth = $Connection->db->prepare($query);
1165
-                    		$sth->execute();
1166
-	                } catch(PDOException $e) {
1165
+							$sth->execute();
1166
+					} catch(PDOException $e) {
1167 1167
 				return "error : ".$e->getMessage();
1168
-	                }
1169
-	        }
1168
+					}
1169
+			}
1170 1170
 
1171 1171
 
1172 1172
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1200,10 +1200,10 @@  discard block
 block discarded – undo
1200 1200
 			$query = 'DROP TABLE countries';
1201 1201
 			try {
1202 1202
 				$sth = $Connection->db->prepare($query);
1203
-            	        	$sth->execute();
1204
-	                } catch(PDOException $e) {
1205
-    	                	echo "error : ".$e->getMessage();
1206
-	                }
1203
+							$sth->execute();
1204
+					} catch(PDOException $e) {
1205
+							echo "error : ".$e->getMessage();
1206
+					}
1207 1207
 		}
1208 1208
 		if ($globalDBdriver == 'mysql') {
1209 1209
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -1675,12 +1675,12 @@  discard block
 block discarded – undo
1675 1675
 		echo $data;
1676 1676
 		*/
1677 1677
 		if (file_exists($tmp_dir.'aircrafts.html')) {
1678
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1679
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
1680
-		    $result = fread($fh,100000000);
1681
-		    //echo $result;
1682
-		    //var_dump(str_get_html($result));
1683
-		    //print_r(self::table2array($result));
1678
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1679
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
1680
+			$result = fread($fh,100000000);
1681
+			//echo $result;
1682
+			//var_dump(str_get_html($result));
1683
+			//print_r(self::table2array($result));
1684 1684
 		}
1685 1685
 
1686 1686
 	}
@@ -1694,10 +1694,10 @@  discard block
 block discarded – undo
1694 1694
 		try {
1695 1695
 			$Connection = new Connection();
1696 1696
 			$sth = $Connection->db->prepare($query);
1697
-                        $sth->execute();
1698
-                } catch(PDOException $e) {
1699
-                        return "error : ".$e->getMessage();
1700
-                }
1697
+						$sth->execute();
1698
+				} catch(PDOException $e) {
1699
+						return "error : ".$e->getMessage();
1700
+				}
1701 1701
 
1702 1702
 		$error = '';
1703 1703
 		if ($globalDebug) echo "Notam : Download...";
@@ -1753,8 +1753,8 @@  discard block
 block discarded – undo
1753 1753
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
1754 1754
 					$data['permanent'] = 0;
1755 1755
 				} else {
1756
-				    $data['date_end'] = NULL;
1757
-				    $data['permanent'] = 1;
1756
+					$data['date_end'] = NULL;
1757
+					$data['permanent'] = 1;
1758 1758
 				}
1759 1759
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
1760 1760
 				$NOTAM = new NOTAM();
@@ -1778,13 +1778,13 @@  discard block
 block discarded – undo
1778 1778
 		try {
1779 1779
 			$Connection = new Connection();
1780 1780
 			$sth = $Connection->db->prepare($query);
1781
-                        $sth->execute();
1782
-                } catch(PDOException $e) {
1783
-                        return "error : ".$e->getMessage();
1784
-                }
1785
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
1786
-                if ($row['nb'] > 0) return false;
1787
-                else return true;
1781
+						$sth->execute();
1782
+				} catch(PDOException $e) {
1783
+						return "error : ".$e->getMessage();
1784
+				}
1785
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
1786
+				if ($row['nb'] > 0) return false;
1787
+				else return true;
1788 1788
 	}
1789 1789
 
1790 1790
 	public static function insert_last_update() {
@@ -1793,10 +1793,10 @@  discard block
 block discarded – undo
1793 1793
 		try {
1794 1794
 			$Connection = new Connection();
1795 1795
 			$sth = $Connection->db->prepare($query);
1796
-                        $sth->execute();
1797
-                } catch(PDOException $e) {
1798
-                        return "error : ".$e->getMessage();
1799
-                }
1796
+						$sth->execute();
1797
+				} catch(PDOException $e) {
1798
+						return "error : ".$e->getMessage();
1799
+				}
1800 1800
 	}
1801 1801
 
1802 1802
 	public static function check_last_notam_update() {
@@ -1809,13 +1809,13 @@  discard block
 block discarded – undo
1809 1809
 		try {
1810 1810
 			$Connection = new Connection();
1811 1811
 			$sth = $Connection->db->prepare($query);
1812
-                        $sth->execute();
1813
-                } catch(PDOException $e) {
1814
-                        return "error : ".$e->getMessage();
1815
-                }
1816
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
1817
-                if ($row['nb'] > 0) return false;
1818
-                else return true;
1812
+						$sth->execute();
1813
+				} catch(PDOException $e) {
1814
+						return "error : ".$e->getMessage();
1815
+				}
1816
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
1817
+				if ($row['nb'] > 0) return false;
1818
+				else return true;
1819 1819
 	}
1820 1820
 
1821 1821
 	public static function insert_last_notam_update() {
@@ -1824,10 +1824,10 @@  discard block
 block discarded – undo
1824 1824
 		try {
1825 1825
 			$Connection = new Connection();
1826 1826
 			$sth = $Connection->db->prepare($query);
1827
-                        $sth->execute();
1828
-                } catch(PDOException $e) {
1829
-                        return "error : ".$e->getMessage();
1830
-                }
1827
+						$sth->execute();
1828
+				} catch(PDOException $e) {
1829
+						return "error : ".$e->getMessage();
1830
+				}
1831 1831
 	}
1832 1832
 
1833 1833
 	public static function check_last_owner_update() {
@@ -1840,13 +1840,13 @@  discard block
 block discarded – undo
1840 1840
 		try {
1841 1841
 			$Connection = new Connection();
1842 1842
 			$sth = $Connection->db->prepare($query);
1843
-                        $sth->execute();
1844
-                } catch(PDOException $e) {
1845
-                        return "error : ".$e->getMessage();
1846
-                }
1847
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
1848
-                if ($row['nb'] > 0) return false;
1849
-                else return true;
1843
+						$sth->execute();
1844
+				} catch(PDOException $e) {
1845
+						return "error : ".$e->getMessage();
1846
+				}
1847
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
1848
+				if ($row['nb'] > 0) return false;
1849
+				else return true;
1850 1850
 	}
1851 1851
 
1852 1852
 	public static function insert_last_owner_update() {
@@ -1855,10 +1855,10 @@  discard block
 block discarded – undo
1855 1855
 		try {
1856 1856
 			$Connection = new Connection();
1857 1857
 			$sth = $Connection->db->prepare($query);
1858
-                        $sth->execute();
1859
-                } catch(PDOException $e) {
1860
-                        return "error : ".$e->getMessage();
1861
-                }
1858
+						$sth->execute();
1859
+				} catch(PDOException $e) {
1860
+						return "error : ".$e->getMessage();
1861
+				}
1862 1862
 	}
1863 1863
 	public static function check_last_schedules_update() {
1864 1864
 		global $globalDBdriver;
@@ -1870,13 +1870,13 @@  discard block
 block discarded – undo
1870 1870
 		try {
1871 1871
 			$Connection = new Connection();
1872 1872
 			$sth = $Connection->db->prepare($query);
1873
-                        $sth->execute();
1874
-                } catch(PDOException $e) {
1875
-                        return "error : ".$e->getMessage();
1876
-                }
1877
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
1878
-                if ($row['nb'] > 0) return false;
1879
-                else return true;
1873
+						$sth->execute();
1874
+				} catch(PDOException $e) {
1875
+						return "error : ".$e->getMessage();
1876
+				}
1877
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
1878
+				if ($row['nb'] > 0) return false;
1879
+				else return true;
1880 1880
 	}
1881 1881
 
1882 1882
 	public static function insert_last_schedules_update() {
@@ -1885,10 +1885,10 @@  discard block
 block discarded – undo
1885 1885
 		try {
1886 1886
 			$Connection = new Connection();
1887 1887
 			$sth = $Connection->db->prepare($query);
1888
-                        $sth->execute();
1889
-                } catch(PDOException $e) {
1890
-                        return "error : ".$e->getMessage();
1891
-                }
1888
+						$sth->execute();
1889
+				} catch(PDOException $e) {
1890
+						return "error : ".$e->getMessage();
1891
+				}
1892 1892
 	}
1893 1893
 	public static function check_last_tle_update() {
1894 1894
 		global $globalDBdriver;
@@ -1900,13 +1900,13 @@  discard block
 block discarded – undo
1900 1900
 		try {
1901 1901
 			$Connection = new Connection();
1902 1902
 			$sth = $Connection->db->prepare($query);
1903
-                        $sth->execute();
1904
-                } catch(PDOException $e) {
1905
-                        return "error : ".$e->getMessage();
1906
-                }
1907
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
1908
-                if ($row['nb'] > 0) return false;
1909
-                else return true;
1903
+						$sth->execute();
1904
+				} catch(PDOException $e) {
1905
+						return "error : ".$e->getMessage();
1906
+				}
1907
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
1908
+				if ($row['nb'] > 0) return false;
1909
+				else return true;
1910 1910
 	}
1911 1911
 
1912 1912
 	public static function insert_last_tle_update() {
@@ -1915,10 +1915,10 @@  discard block
 block discarded – undo
1915 1915
 		try {
1916 1916
 			$Connection = new Connection();
1917 1917
 			$sth = $Connection->db->prepare($query);
1918
-                        $sth->execute();
1919
-                } catch(PDOException $e) {
1920
-                        return "error : ".$e->getMessage();
1921
-                }
1918
+						$sth->execute();
1919
+				} catch(PDOException $e) {
1920
+						return "error : ".$e->getMessage();
1921
+				}
1922 1922
 	}
1923 1923
 	
1924 1924
 	public static function update_all() {
Please login to merge, or discard this patch.
Spacing   +231 added lines, -231 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 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
 				}
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 		return '';
945 945
         }
946 946
 
947
-	public static function tle($filename,$tletype) {
947
+	public static function tle($filename, $tletype) {
948 948
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
949 949
 		global $tmp_dir, $globalTransaction;
950 950
 		//$Spotter = new Spotter();
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
 			$Connection = new Connection();
955 955
 			$sth = $Connection->db->prepare($query);
956 956
                         $sth->execute(array(':source' => $filename));
957
-                } catch(PDOException $e) {
957
+                } catch (PDOException $e) {
958 958
                         return "error : ".$e->getMessage();
959 959
                 }
960 960
 		
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
980 980
 					try {
981 981
 						$sth = $Connection->db->prepare($query);
982
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
983
-					} catch(PDOException $e) {
982
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
983
+					} catch (PDOException $e) {
984 984
 						return "error : ".$e->getMessage();
985 985
 					}
986 986
 
@@ -1000,28 +1000,28 @@  discard block
 block discarded – undo
1000 1000
         */
1001 1001
         private static function table2array($data) {
1002 1002
                 $html = str_get_html($data);
1003
-                $tabledata=array();
1004
-                foreach($html->find('tr') as $element)
1003
+                $tabledata = array();
1004
+                foreach ($html->find('tr') as $element)
1005 1005
                 {
1006 1006
                         $td = array();
1007
-                        foreach( $element->find('th') as $row)
1007
+                        foreach ($element->find('th') as $row)
1008 1008
                         {
1009 1009
                                 $td [] = trim($row->plaintext);
1010 1010
                         }
1011
-                        $td=array_filter($td);
1011
+                        $td = array_filter($td);
1012 1012
                         $tabledata[] = $td;
1013 1013
 
1014 1014
                         $td = array();
1015 1015
                         $tdi = array();
1016
-                        foreach( $element->find('td') as $row)
1016
+                        foreach ($element->find('td') as $row)
1017 1017
                         {
1018 1018
                                 $td [] = trim($row->plaintext);
1019 1019
                                 $tdi [] = trim($row->innertext);
1020 1020
                         }
1021
-                        $td=array_filter($td);
1022
-                        $tdi=array_filter($tdi);
1021
+                        $td = array_filter($td);
1022
+                        $tdi = array_filter($tdi);
1023 1023
                     //    $tabledata[]=array_merge($td,$tdi);
1024
-                        $tabledata[]=$td;
1024
+                        $tabledata[] = $td;
1025 1025
                 }
1026 1026
                 return(array_filter($tabledata));
1027 1027
         }
@@ -1094,13 +1094,13 @@  discard block
 block discarded – undo
1094 1094
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1095 1095
 			{
1096 1096
 				$i++;
1097
-				if($i > 3 && count($row) > 2) {
1097
+				if ($i > 3 && count($row) > 2) {
1098 1098
 					$data = array_values(array_filter($row));
1099 1099
 					$cntdata = count($data);
1100 1100
 					if ($cntdata > 10) {
1101 1101
 						$value = $data[9];
1102 1102
 						
1103
-						for ($i =10;$i < $cntdata;$i++) {
1103
+						for ($i = 10; $i < $cntdata; $i++) {
1104 1104
 							$value .= ' '.$data[$i];
1105 1105
 						}
1106 1106
 						$data[9] = $value;
@@ -1110,8 +1110,8 @@  discard block
 block discarded – undo
1110 1110
 						$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)';
1111 1111
 						try {
1112 1112
 							$sth = $Connection->db->prepare($query);
1113
-							$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]));
1114
-						} catch(PDOException $e) {
1113
+							$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]));
1114
+						} catch (PDOException $e) {
1115 1115
 							return "error : ".$e->getMessage();
1116 1116
 						}
1117 1117
 					}
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 			$Connection = new Connection();
1133 1133
 			$sth = $Connection->db->prepare($query);
1134 1134
                         $sth->execute();
1135
-                } catch(PDOException $e) {
1135
+                } catch (PDOException $e) {
1136 1136
                         return "error : ".$e->getMessage();
1137 1137
                 }
1138 1138
 
@@ -1144,12 +1144,12 @@  discard block
 block discarded – undo
1144 1144
 			if ($globalTransaction) $Connection->db->beginTransaction();
1145 1145
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1146 1146
 			{
1147
-				if(count($row) > 1) {
1147
+				if (count($row) > 1) {
1148 1148
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1149 1149
 					try {
1150 1150
 						$sth = $Connection->db->prepare($query);
1151
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1152
-					} catch(PDOException $e) {
1151
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1152
+					} catch (PDOException $e) {
1153 1153
 						return "error : ".$e->getMessage();
1154 1154
 					}
1155 1155
 				}
@@ -1169,21 +1169,21 @@  discard block
 block discarded – undo
1169 1169
 			try {
1170 1170
 				$sth = $Connection->db->prepare($query);
1171 1171
                     		$sth->execute();
1172
-	                } catch(PDOException $e) {
1172
+	                } catch (PDOException $e) {
1173 1173
 				return "error : ".$e->getMessage();
1174 1174
 	                }
1175 1175
 	        }
1176 1176
 
1177 1177
 
1178
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1178
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1179 1179
 		else {
1180
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1180
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1181 1181
 			$query = "CREATE EXTENSION postgis";
1182
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1182
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1183 1183
 			try {
1184 1184
 				$sth = $Connection->db->prepare($query);
1185 1185
 				$sth->execute();
1186
-			} catch(PDOException $e) {
1186
+			} catch (PDOException $e) {
1187 1187
 				return "error : ".$e->getMessage();
1188 1188
 			}
1189 1189
 		}
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 		include_once('class.create_db.php');
1197 1197
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1198 1198
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1199
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1199
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1200 1200
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1201 1201
 			if ($globalDebug) echo "Gunzip...";
1202 1202
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
@@ -1227,14 +1227,14 @@  discard block
 block discarded – undo
1227 1227
 			try {
1228 1228
 				$sth = $Connection->db->prepare($query);
1229 1229
             	        	$sth->execute();
1230
-	                } catch(PDOException $e) {
1230
+	                } catch (PDOException $e) {
1231 1231
     	                	echo "error : ".$e->getMessage();
1232 1232
 	                }
1233 1233
 		}
1234 1234
 		if ($globalDBdriver == 'mysql') {
1235
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1235
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1236 1236
 		} else {
1237
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1237
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1238 1238
 		}
1239 1239
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1240 1240
 		return $error;
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1248 1248
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1249 1249
 //		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');
1250
-		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');
1250
+		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');
1251 1251
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1252 1252
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1253 1253
 		return $error;
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1268 1268
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1269 1269
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1270
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1270
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1271 1271
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1272 1272
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1273 1273
 		if ($error != '') {
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 		global $tmp_dir, $globalDebug;
1281 1281
 		$error = '';
1282 1282
 		if ($globalDebug) echo "Routes : Download...";
1283
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1283
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1284 1284
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1285 1285
 			if ($globalDebug) echo "Gunzip...";
1286 1286
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
 		global $tmp_dir, $globalDebug;
1297 1297
 		$error = '';
1298 1298
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1299
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1299
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1300 1300
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1301 1301
 			if ($globalDebug) echo "Gunzip...";
1302 1302
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
 		global $tmp_dir, $globalDebug;
1313 1313
 		$error = '';
1314 1314
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1315
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1315
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1316 1316
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1317 1317
 			if ($globalDebug) echo "Gunzip...";
1318 1318
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 		} elseif ($globalDebug) echo "Done\n";
1340 1340
 */
1341 1341
 		if ($globalDebug) echo "Modes : Download...";
1342
-		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1342
+		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip', $tmp_dir.'basestation_latest.zip', 'http://planebase.biz/bstnsqb');
1343 1343
 		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1344 1344
 			if ($globalDebug) echo "Unzip...";
1345 1345
 			update_db::unzip($tmp_dir.'basestation_latest.zip');
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
 	public static function update_ModeS_flarm() {
1356 1356
 		global $tmp_dir, $globalDebug;
1357 1357
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1358
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1358
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1359 1359
 		if (file_exists($tmp_dir.'data.fln')) {
1360 1360
 			if ($globalDebug) echo "Add to DB...";
1361 1361
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
 	public static function update_ModeS_ogn() {
1370 1370
 		global $tmp_dir, $globalDebug;
1371 1371
 		if ($globalDebug) echo "Modes OGN: Download...";
1372
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1372
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1373 1373
 		if (file_exists($tmp_dir.'ogn.csv')) {
1374 1374
 			if ($globalDebug) echo "Add to DB...";
1375 1375
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1384,173 +1384,173 @@  discard block
 block discarded – undo
1384 1384
 		global $tmp_dir, $globalDebug;
1385 1385
 		
1386 1386
 		if ($globalDebug) echo "Owner France: Download...";
1387
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1387
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1388 1388
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1389 1389
 			if ($globalDebug) echo "Add to DB...";
1390
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1390
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1391 1391
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1392 1392
 		if ($error != '') {
1393 1393
 			return $error;
1394 1394
 		} elseif ($globalDebug) echo "Done\n";
1395 1395
 		
1396 1396
 		if ($globalDebug) echo "Owner Ireland: Download...";
1397
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1397
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1398 1398
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1399 1399
 			if ($globalDebug) echo "Add to DB...";
1400
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1400
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1401 1401
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1402 1402
 		if ($error != '') {
1403 1403
 			return $error;
1404 1404
 		} elseif ($globalDebug) echo "Done\n";
1405 1405
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1406
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1406
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1407 1407
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1408 1408
 			if ($globalDebug) echo "Add to DB...";
1409
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1409
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1410 1410
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1411 1411
 		if ($error != '') {
1412 1412
 			return $error;
1413 1413
 		} elseif ($globalDebug) echo "Done\n";
1414 1414
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1415
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1415
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1416 1416
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1417 1417
 			if ($globalDebug) echo "Add to DB...";
1418
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1418
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1419 1419
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1420 1420
 		if ($error != '') {
1421 1421
 			return $error;
1422 1422
 		} elseif ($globalDebug) echo "Done\n";
1423 1423
 		if ($globalDebug) echo "Owner Australia: Download...";
1424
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1424
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1425 1425
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1426 1426
 			if ($globalDebug) echo "Add to DB...";
1427
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1427
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1428 1428
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1429 1429
 		if ($error != '') {
1430 1430
 			return $error;
1431 1431
 		} elseif ($globalDebug) echo "Done\n";
1432 1432
 		if ($globalDebug) echo "Owner Austria: Download...";
1433
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1433
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1434 1434
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1435 1435
 			if ($globalDebug) echo "Add to DB...";
1436
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1436
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1437 1437
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1438 1438
 		if ($error != '') {
1439 1439
 			return $error;
1440 1440
 		} elseif ($globalDebug) echo "Done\n";
1441 1441
 		if ($globalDebug) echo "Owner Chile: Download...";
1442
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1442
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1443 1443
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1444 1444
 			if ($globalDebug) echo "Add to DB...";
1445
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1445
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1446 1446
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1447 1447
 		if ($error != '') {
1448 1448
 			return $error;
1449 1449
 		} elseif ($globalDebug) echo "Done\n";
1450 1450
 		if ($globalDebug) echo "Owner Colombia: Download...";
1451
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1451
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1452 1452
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1453 1453
 			if ($globalDebug) echo "Add to DB...";
1454
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1454
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1455 1455
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1456 1456
 		if ($error != '') {
1457 1457
 			return $error;
1458 1458
 		} elseif ($globalDebug) echo "Done\n";
1459 1459
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1460
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1460
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1461 1461
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1462 1462
 			if ($globalDebug) echo "Add to DB...";
1463
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1463
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1464 1464
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1465 1465
 		if ($error != '') {
1466 1466
 			return $error;
1467 1467
 		} elseif ($globalDebug) echo "Done\n";
1468 1468
 		if ($globalDebug) echo "Owner Brazil: Download...";
1469
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1469
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1470 1470
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1471 1471
 			if ($globalDebug) echo "Add to DB...";
1472
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1472
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1473 1473
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1474 1474
 		if ($error != '') {
1475 1475
 			return $error;
1476 1476
 		} elseif ($globalDebug) echo "Done\n";
1477 1477
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1478
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1478
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1479 1479
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1480 1480
 			if ($globalDebug) echo "Add to DB...";
1481
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1481
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1482 1482
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1483 1483
 		if ($error != '') {
1484 1484
 			return $error;
1485 1485
 		} elseif ($globalDebug) echo "Done\n";
1486 1486
 		if ($globalDebug) echo "Owner Croatia: Download...";
1487
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1487
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1488 1488
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1489 1489
 			if ($globalDebug) echo "Add to DB...";
1490
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1490
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1491 1491
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1492 1492
 		if ($error != '') {
1493 1493
 			return $error;
1494 1494
 		} elseif ($globalDebug) echo "Done\n";
1495 1495
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1496
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1496
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1497 1497
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1498 1498
 			if ($globalDebug) echo "Add to DB...";
1499
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1499
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1500 1500
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1501 1501
 		if ($error != '') {
1502 1502
 			return $error;
1503 1503
 		} elseif ($globalDebug) echo "Done\n";
1504 1504
 		if ($globalDebug) echo "Owner Maldives: Download...";
1505
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1505
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1506 1506
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1507 1507
 			if ($globalDebug) echo "Add to DB...";
1508
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1508
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1509 1509
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1510 1510
 		if ($error != '') {
1511 1511
 			return $error;
1512 1512
 		} elseif ($globalDebug) echo "Done\n";
1513 1513
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1514
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1514
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1515 1515
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1516 1516
 			if ($globalDebug) echo "Add to DB...";
1517
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1517
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1518 1518
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1519 1519
 		if ($error != '') {
1520 1520
 			return $error;
1521 1521
 		} elseif ($globalDebug) echo "Done\n";
1522 1522
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1523
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1523
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1524 1524
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1525 1525
 			if ($globalDebug) echo "Add to DB...";
1526
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1526
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1527 1527
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1528 1528
 		if ($error != '') {
1529 1529
 			return $error;
1530 1530
 		} elseif ($globalDebug) echo "Done\n";
1531 1531
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1532
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1532
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1533 1533
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1534 1534
 			if ($globalDebug) echo "Add to DB...";
1535
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1535
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1536 1536
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1537 1537
 		if ($error != '') {
1538 1538
 			return $error;
1539 1539
 		} elseif ($globalDebug) echo "Done\n";
1540 1540
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1541
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1541
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1542 1542
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1543 1543
 			if ($globalDebug) echo "Add to DB...";
1544
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1544
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1545 1545
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1546 1546
 		if ($error != '') {
1547 1547
 			return $error;
1548 1548
 		} elseif ($globalDebug) echo "Done\n";
1549 1549
 		if ($globalDebug) echo "Owner Iceland: Download...";
1550
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1550
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1551 1551
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1552 1552
 			if ($globalDebug) echo "Add to DB...";
1553
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1553
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1554 1554
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1555 1555
 		if ($error != '') {
1556 1556
 			return $error;
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 		global $tmp_dir, $globalDebug;
1563 1563
 		$error = '';
1564 1564
 		if ($globalDebug) echo "Translation : Download...";
1565
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1565
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1566 1566
 		if (file_exists($tmp_dir.'translation.zip')) {
1567 1567
 			if ($globalDebug) echo "Unzip...";
1568 1568
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 	public static function update_translation_fam() {
1579 1579
 		global $tmp_dir, $globalDebug;
1580 1580
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1581
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1581
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1582 1582
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1583 1583
 			if ($globalDebug) echo "Gunzip...";
1584 1584
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1594,15 +1594,15 @@  discard block
 block discarded – undo
1594 1594
 	public static function update_tle() {
1595 1595
 		global $tmp_dir, $globalDebug;
1596 1596
 		if ($globalDebug) echo "Download TLE : Download...";
1597
-		$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',
1598
-		'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',
1599
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1597
+		$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',
1598
+		'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',
1599
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
1600 1600
 		foreach ($alltle as $filename) {
1601 1601
 			if ($globalDebug) echo "downloading ".$filename.'...';
1602
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1602
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
1603 1603
 			if (file_exists($tmp_dir.$filename)) {
1604 1604
 				if ($globalDebug) echo "Add to DB ".$filename."...";
1605
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1605
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
1606 1606
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
1607 1607
 			if ($error != '') {
1608 1608
 				echo $error."\n";
@@ -1615,32 +1615,32 @@  discard block
 block discarded – undo
1615 1615
 		global $tmp_dir, $globalDebug;
1616 1616
 		$error = '';
1617 1617
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
1618
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1618
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
1619 1619
 		if (file_exists($tmp_dir.'models.md5sum')) {
1620 1620
 			if ($globalDebug) echo "Check files...\n";
1621 1621
 			$newmodelsdb = array();
1622
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1623
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1622
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
1623
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1624 1624
 					$model = trim($row[2]);
1625 1625
 					$newmodelsdb[$model] = trim($row[0]);
1626 1626
 				}
1627 1627
 			}
1628 1628
 			$modelsdb = array();
1629 1629
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
1630
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
1631
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1630
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
1631
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1632 1632
 						$model = trim($row[2]);
1633 1633
 						$modelsdb[$model] = trim($row[0]);
1634 1634
 					}
1635 1635
 				}
1636 1636
 			}
1637
-			$diff = array_diff($newmodelsdb,$modelsdb);
1637
+			$diff = array_diff($newmodelsdb, $modelsdb);
1638 1638
 			foreach ($diff as $key => $value) {
1639 1639
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
1640
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1640
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
1641 1641
 				
1642 1642
 			}
1643
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1643
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
1644 1644
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
1645 1645
 		if ($error != '') {
1646 1646
 			return $error;
@@ -1652,32 +1652,32 @@  discard block
 block discarded – undo
1652 1652
 		global $tmp_dir, $globalDebug;
1653 1653
 		$error = '';
1654 1654
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
1655
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1655
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
1656 1656
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1657 1657
 			if ($globalDebug) echo "Check files...\n";
1658 1658
 			$newmodelsdb = array();
1659
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1660
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1659
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
1660
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1661 1661
 					$model = trim($row[2]);
1662 1662
 					$newmodelsdb[$model] = trim($row[0]);
1663 1663
 				}
1664 1664
 			}
1665 1665
 			$modelsdb = array();
1666 1666
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
1667
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
1668
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1667
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
1668
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1669 1669
 						$model = trim($row[2]);
1670 1670
 						$modelsdb[$model] = trim($row[0]);
1671 1671
 					}
1672 1672
 				}
1673 1673
 			}
1674
-			$diff = array_diff($newmodelsdb,$modelsdb);
1674
+			$diff = array_diff($newmodelsdb, $modelsdb);
1675 1675
 			foreach ($diff as $key => $value) {
1676 1676
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
1677
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
1677
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
1678 1678
 				
1679 1679
 			}
1680
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
1680
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
1681 1681
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
1682 1682
 		if ($error != '') {
1683 1683
 			return $error;
@@ -1700,8 +1700,8 @@  discard block
 block discarded – undo
1700 1700
 		*/
1701 1701
 		if (file_exists($tmp_dir.'aircrafts.html')) {
1702 1702
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1703
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
1704
-		    $result = fread($fh,100000000);
1703
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
1704
+		    $result = fread($fh, 100000000);
1705 1705
 		    //echo $result;
1706 1706
 		    //var_dump(str_get_html($result));
1707 1707
 		    //print_r(self::table2array($result));
@@ -1719,23 +1719,23 @@  discard block
 block discarded – undo
1719 1719
 			$Connection = new Connection();
1720 1720
 			$sth = $Connection->db->prepare($query);
1721 1721
                         $sth->execute();
1722
-                } catch(PDOException $e) {
1722
+                } catch (PDOException $e) {
1723 1723
                         return "error : ".$e->getMessage();
1724 1724
                 }
1725 1725
 
1726 1726
 		$error = '';
1727 1727
 		if ($globalDebug) echo "Notam : Download...";
1728
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
1728
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
1729 1729
 		if (file_exists($tmp_dir.'notam.rss')) {
1730
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
1730
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
1731 1731
 			foreach ($notams['channel']['item'] as $notam) {
1732
-				$title = explode(':',$notam['title']);
1732
+				$title = explode(':', $notam['title']);
1733 1733
 				$data['ref'] = trim($title[0]);
1734 1734
 				unset($title[0]);
1735
-				$data['title'] = trim(implode(':',$title));
1736
-				$description = strip_tags($notam['description'],'<pre>');
1737
-				preg_match(':^(.*?)<pre>:',$description,$match);
1738
-				$q = explode('/',$match[1]);
1735
+				$data['title'] = trim(implode(':', $title));
1736
+				$description = strip_tags($notam['description'], '<pre>');
1737
+				preg_match(':^(.*?)<pre>:', $description, $match);
1738
+				$q = explode('/', $match[1]);
1739 1739
 				$data['fir'] = $q[0];
1740 1740
 				$data['code'] = $q[1];
1741 1741
 				$ifrvfr = $q[2];
@@ -1751,30 +1751,30 @@  discard block
 block discarded – undo
1751 1751
 				$data['lower_limit'] = $q[5];
1752 1752
 				$data['upper_limit'] = $q[6];
1753 1753
 				$latlonrad = $q[7];
1754
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
1755
-				$latitude = $Common->convertDec($las,'latitude');
1756
-				$longitude = $Common->convertDec($lns,'longitude');
1754
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
1755
+				$latitude = $Common->convertDec($las, 'latitude');
1756
+				$longitude = $Common->convertDec($lns, 'longitude');
1757 1757
 				if ($lac == 'S') $latitude = '-'.$latitude;
1758 1758
 				if ($lnc == 'W') $longitude = '-'.$longitude;
1759 1759
 				$data['center_latitude'] = $latitude;
1760 1760
 				$data['center_longitude'] = $longitude;
1761 1761
 				$data['radius'] = intval($radius);
1762 1762
 				
1763
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
1763
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
1764 1764
 				$data['text'] = $match[1];
1765
-				preg_match(':</pre>(.*?)$:',$description,$match);
1765
+				preg_match(':</pre>(.*?)$:', $description, $match);
1766 1766
 				$fromto = $match[1];
1767
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
1767
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
1768 1768
 				$fromall = trim($match[1]);
1769
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
1769
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
1770 1770
 				$from = trim($match[1]);
1771
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
1772
-				preg_match('#TO:(.*?)$#',$fromto,$match);
1771
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
1772
+				preg_match('#TO:(.*?)$#', $fromto, $match);
1773 1773
 				$toall = trim($match[1]);
1774
-				if (!preg_match(':Permanent:',$toall)) {
1775
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
1774
+				if (!preg_match(':Permanent:', $toall)) {
1775
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
1776 1776
 					$to = trim($match[1]);
1777
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
1777
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
1778 1778
 					$data['permanent'] = 0;
1779 1779
 				} else {
1780 1780
 				    $data['date_end'] = NULL;
@@ -1782,7 +1782,7 @@  discard block
 block discarded – undo
1782 1782
 				}
1783 1783
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
1784 1784
 				$NOTAM = new NOTAM();
1785
-				$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']);
1785
+				$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']);
1786 1786
 				unset($data);
1787 1787
 			} 
1788 1788
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -1803,7 +1803,7 @@  discard block
 block discarded – undo
1803 1803
 			$Connection = new Connection();
1804 1804
 			$sth = $Connection->db->prepare($query);
1805 1805
                         $sth->execute();
1806
-                } catch(PDOException $e) {
1806
+                } catch (PDOException $e) {
1807 1807
                         return "error : ".$e->getMessage();
1808 1808
                 }
1809 1809
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1818,7 +1818,7 @@  discard block
 block discarded – undo
1818 1818
 			$Connection = new Connection();
1819 1819
 			$sth = $Connection->db->prepare($query);
1820 1820
                         $sth->execute();
1821
-                } catch(PDOException $e) {
1821
+                } catch (PDOException $e) {
1822 1822
                         return "error : ".$e->getMessage();
1823 1823
                 }
1824 1824
 	}
@@ -1834,7 +1834,7 @@  discard block
 block discarded – undo
1834 1834
 			$Connection = new Connection();
1835 1835
 			$sth = $Connection->db->prepare($query);
1836 1836
                         $sth->execute();
1837
-                } catch(PDOException $e) {
1837
+                } catch (PDOException $e) {
1838 1838
                         return "error : ".$e->getMessage();
1839 1839
                 }
1840 1840
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
 			$Connection = new Connection();
1850 1850
 			$sth = $Connection->db->prepare($query);
1851 1851
                         $sth->execute();
1852
-                } catch(PDOException $e) {
1852
+                } catch (PDOException $e) {
1853 1853
                         return "error : ".$e->getMessage();
1854 1854
                 }
1855 1855
 	}
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
 			$Connection = new Connection();
1866 1866
 			$sth = $Connection->db->prepare($query);
1867 1867
                         $sth->execute();
1868
-                } catch(PDOException $e) {
1868
+                } catch (PDOException $e) {
1869 1869
                         return "error : ".$e->getMessage();
1870 1870
                 }
1871 1871
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1880,7 +1880,7 @@  discard block
 block discarded – undo
1880 1880
 			$Connection = new Connection();
1881 1881
 			$sth = $Connection->db->prepare($query);
1882 1882
                         $sth->execute();
1883
-                } catch(PDOException $e) {
1883
+                } catch (PDOException $e) {
1884 1884
                         return "error : ".$e->getMessage();
1885 1885
                 }
1886 1886
 	}
@@ -1895,7 +1895,7 @@  discard block
 block discarded – undo
1895 1895
 			$Connection = new Connection();
1896 1896
 			$sth = $Connection->db->prepare($query);
1897 1897
                         $sth->execute();
1898
-                } catch(PDOException $e) {
1898
+                } catch (PDOException $e) {
1899 1899
                         return "error : ".$e->getMessage();
1900 1900
                 }
1901 1901
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1910,7 +1910,7 @@  discard block
 block discarded – undo
1910 1910
 			$Connection = new Connection();
1911 1911
 			$sth = $Connection->db->prepare($query);
1912 1912
                         $sth->execute();
1913
-                } catch(PDOException $e) {
1913
+                } catch (PDOException $e) {
1914 1914
                         return "error : ".$e->getMessage();
1915 1915
                 }
1916 1916
 	}
@@ -1925,7 +1925,7 @@  discard block
 block discarded – undo
1925 1925
 			$Connection = new Connection();
1926 1926
 			$sth = $Connection->db->prepare($query);
1927 1927
                         $sth->execute();
1928
-                } catch(PDOException $e) {
1928
+                } catch (PDOException $e) {
1929 1929
                         return "error : ".$e->getMessage();
1930 1930
                 }
1931 1931
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1940,7 +1940,7 @@  discard block
 block discarded – undo
1940 1940
 			$Connection = new Connection();
1941 1941
 			$sth = $Connection->db->prepare($query);
1942 1942
                         $sth->execute();
1943
-                } catch(PDOException $e) {
1943
+                } catch (PDOException $e) {
1944 1944
                         return "error : ".$e->getMessage();
1945 1945
                 }
1946 1946
 	}
Please login to merge, or discard this patch.
Braces   +693 added lines, -240 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';
@@ -1090,7 +1211,9 @@  discard block
 block discarded – undo
1090 1211
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1091 1212
 		{
1092 1213
 			$i = 0;
1093
-			if ($globalTransaction) $Connection->db->beginTransaction();
1214
+			if ($globalTransaction) {
1215
+				$Connection->db->beginTransaction();
1216
+			}
1094 1217
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1095 1218
 			{
1096 1219
 				$i++;
@@ -1118,7 +1241,9 @@  discard block
 block discarded – undo
1118 1241
 				}
1119 1242
 			}
1120 1243
 			fclose($handle);
1121
-			if ($globalTransaction) $Connection->db->commit();
1244
+			if ($globalTransaction) {
1245
+				$Connection->db->commit();
1246
+			}
1122 1247
 		}
1123 1248
 		return '';
1124 1249
         }
@@ -1141,7 +1266,9 @@  discard block
 block discarded – undo
1141 1266
 		$Connection = new Connection();
1142 1267
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1143 1268
 		{
1144
-			if ($globalTransaction) $Connection->db->beginTransaction();
1269
+			if ($globalTransaction) {
1270
+				$Connection->db->beginTransaction();
1271
+			}
1145 1272
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1146 1273
 			{
1147 1274
 				if(count($row) > 1) {
@@ -1155,7 +1282,9 @@  discard block
 block discarded – undo
1155 1282
 				}
1156 1283
 			}
1157 1284
 			fclose($handle);
1158
-			if ($globalTransaction) $Connection->db->commit();
1285
+			if ($globalTransaction) {
1286
+				$Connection->db->commit();
1287
+			}
1159 1288
 		}
1160 1289
 		return '';
1161 1290
         }
@@ -1175,8 +1304,9 @@  discard block
 block discarded – undo
1175 1304
 	        }
1176 1305
 
1177 1306
 
1178
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1179
-		else {
1307
+		if ($globalDBdriver == 'mysql') {
1308
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1309
+		} else {
1180 1310
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1181 1311
 			$query = "CREATE EXTENSION postgis";
1182 1312
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1195,19 +1325,29 @@  discard block
 block discarded – undo
1195 1325
 		global $tmp_dir, $globalDebug;
1196 1326
 		include_once('class.create_db.php');
1197 1327
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1198
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1328
+		if ($globalDebug) {
1329
+			echo "NOTAM from FlightAirMap website : Download...";
1330
+		}
1199 1331
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1200 1332
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1201
-			if ($globalDebug) echo "Gunzip...";
1333
+			if ($globalDebug) {
1334
+				echo "Gunzip...";
1335
+			}
1202 1336
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1203
-			if ($globalDebug) echo "Add to DB...";
1337
+			if ($globalDebug) {
1338
+				echo "Add to DB...";
1339
+			}
1204 1340
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1205 1341
 			$NOTAM = new NOTAM();
1206 1342
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1207
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1343
+		} else {
1344
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1345
+		}
1208 1346
 		if ($error != '') {
1209 1347
 			return $error;
1210
-		} elseif ($globalDebug) echo "Done\n";
1348
+		} elseif ($globalDebug) {
1349
+			echo "Done\n";
1350
+		}
1211 1351
 		return '';
1212 1352
 	}
1213 1353
 
@@ -1261,67 +1401,111 @@  discard block
 block discarded – undo
1261 1401
 		//if ($globalDebug) echo "IVAO : Download...";
1262 1402
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1263 1403
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1264
-			if ($globalDebug) echo "Unzip...";
1404
+			if ($globalDebug) {
1405
+				echo "Unzip...";
1406
+			}
1265 1407
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1266
-			if ($globalDebug) echo "Add to DB...";
1408
+			if ($globalDebug) {
1409
+				echo "Add to DB...";
1410
+			}
1267 1411
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1268
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1412
+			if ($globalDebug) {
1413
+				echo "Copy airlines logos to airlines images directory...";
1414
+			}
1269 1415
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1270
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1271
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1272
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1416
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1417
+					$error = "Failed to copy airlines logo.";
1418
+				}
1419
+			} else {
1420
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1421
+			}
1422
+		} else {
1423
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1424
+		}
1273 1425
 		if ($error != '') {
1274 1426
 			return $error;
1275
-		} elseif ($globalDebug) echo "Done\n";
1427
+		} elseif ($globalDebug) {
1428
+			echo "Done\n";
1429
+		}
1276 1430
 		return '';
1277 1431
 	}
1278 1432
 
1279 1433
 	public static function update_routes() {
1280 1434
 		global $tmp_dir, $globalDebug;
1281 1435
 		$error = '';
1282
-		if ($globalDebug) echo "Routes : Download...";
1436
+		if ($globalDebug) {
1437
+			echo "Routes : Download...";
1438
+		}
1283 1439
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1284 1440
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1285
-			if ($globalDebug) echo "Gunzip...";
1441
+			if ($globalDebug) {
1442
+				echo "Gunzip...";
1443
+			}
1286 1444
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1287
-			if ($globalDebug) echo "Add to DB...";
1445
+			if ($globalDebug) {
1446
+				echo "Add to DB...";
1447
+			}
1288 1448
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1289
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1449
+		} else {
1450
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1451
+		}
1290 1452
 		if ($error != '') {
1291 1453
 			return $error;
1292
-		} elseif ($globalDebug) echo "Done\n";
1454
+		} elseif ($globalDebug) {
1455
+			echo "Done\n";
1456
+		}
1293 1457
 		return '';
1294 1458
 	}
1295 1459
 	public static function update_oneworld() {
1296 1460
 		global $tmp_dir, $globalDebug;
1297 1461
 		$error = '';
1298
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1462
+		if ($globalDebug) {
1463
+			echo "Schedules Oneworld : Download...";
1464
+		}
1299 1465
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1300 1466
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1301
-			if ($globalDebug) echo "Gunzip...";
1467
+			if ($globalDebug) {
1468
+				echo "Gunzip...";
1469
+			}
1302 1470
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1303
-			if ($globalDebug) echo "Add to DB...";
1471
+			if ($globalDebug) {
1472
+				echo "Add to DB...";
1473
+			}
1304 1474
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1305
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1475
+		} else {
1476
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1477
+		}
1306 1478
 		if ($error != '') {
1307 1479
 			return $error;
1308
-		} elseif ($globalDebug) echo "Done\n";
1480
+		} elseif ($globalDebug) {
1481
+			echo "Done\n";
1482
+		}
1309 1483
 		return '';
1310 1484
 	}
1311 1485
 	public static function update_skyteam() {
1312 1486
 		global $tmp_dir, $globalDebug;
1313 1487
 		$error = '';
1314
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1488
+		if ($globalDebug) {
1489
+			echo "Schedules Skyteam : Download...";
1490
+		}
1315 1491
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1316 1492
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1317
-			if ($globalDebug) echo "Gunzip...";
1493
+			if ($globalDebug) {
1494
+				echo "Gunzip...";
1495
+			}
1318 1496
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1319
-			if ($globalDebug) echo "Add to DB...";
1497
+			if ($globalDebug) {
1498
+				echo "Add to DB...";
1499
+			}
1320 1500
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1321
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1501
+		} else {
1502
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1503
+		}
1322 1504
 		if ($error != '') {
1323 1505
 			return $error;
1324
-		} elseif ($globalDebug) echo "Done\n";
1506
+		} elseif ($globalDebug) {
1507
+			echo "Done\n";
1508
+		}
1325 1509
 		return '';
1326 1510
 	}
1327 1511
 	public static function update_ModeS() {
@@ -1338,275 +1522,483 @@  discard block
 block discarded – undo
1338 1522
 			exit;
1339 1523
 		} elseif ($globalDebug) echo "Done\n";
1340 1524
 */
1341
-		if ($globalDebug) echo "Modes : Download...";
1525
+		if ($globalDebug) {
1526
+			echo "Modes : Download...";
1527
+		}
1342 1528
 		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1343 1529
 		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1344
-			if ($globalDebug) echo "Unzip...";
1530
+			if ($globalDebug) {
1531
+				echo "Unzip...";
1532
+			}
1345 1533
 			update_db::unzip($tmp_dir.'basestation_latest.zip');
1346
-			if ($globalDebug) echo "Add to DB...";
1534
+			if ($globalDebug) {
1535
+				echo "Add to DB...";
1536
+			}
1347 1537
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1348
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1538
+		} else {
1539
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1540
+		}
1349 1541
 		if ($error != '') {
1350 1542
 			return $error;
1351
-		} elseif ($globalDebug) echo "Done\n";
1543
+		} elseif ($globalDebug) {
1544
+			echo "Done\n";
1545
+		}
1352 1546
 		return '';
1353 1547
 	}
1354 1548
 
1355 1549
 	public static function update_ModeS_flarm() {
1356 1550
 		global $tmp_dir, $globalDebug;
1357
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1551
+		if ($globalDebug) {
1552
+			echo "Modes Flarmnet: Download...";
1553
+		}
1358 1554
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1359 1555
 		if (file_exists($tmp_dir.'data.fln')) {
1360
-			if ($globalDebug) echo "Add to DB...";
1556
+			if ($globalDebug) {
1557
+				echo "Add to DB...";
1558
+			}
1361 1559
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1362
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1560
+		} else {
1561
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1562
+		}
1363 1563
 		if ($error != '') {
1364 1564
 			return $error;
1365
-		} elseif ($globalDebug) echo "Done\n";
1565
+		} elseif ($globalDebug) {
1566
+			echo "Done\n";
1567
+		}
1366 1568
 		return '';
1367 1569
 	}
1368 1570
 
1369 1571
 	public static function update_ModeS_ogn() {
1370 1572
 		global $tmp_dir, $globalDebug;
1371
-		if ($globalDebug) echo "Modes OGN: Download...";
1573
+		if ($globalDebug) {
1574
+			echo "Modes OGN: Download...";
1575
+		}
1372 1576
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1373 1577
 		if (file_exists($tmp_dir.'ogn.csv')) {
1374
-			if ($globalDebug) echo "Add to DB...";
1578
+			if ($globalDebug) {
1579
+				echo "Add to DB...";
1580
+			}
1375 1581
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1376
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1582
+		} else {
1583
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1584
+		}
1377 1585
 		if ($error != '') {
1378 1586
 			return $error;
1379
-		} elseif ($globalDebug) echo "Done\n";
1587
+		} elseif ($globalDebug) {
1588
+			echo "Done\n";
1589
+		}
1380 1590
 		return '';
1381 1591
 	}
1382 1592
 
1383 1593
 	public static function update_owner() {
1384 1594
 		global $tmp_dir, $globalDebug;
1385 1595
 		
1386
-		if ($globalDebug) echo "Owner France: Download...";
1596
+		if ($globalDebug) {
1597
+			echo "Owner France: Download...";
1598
+		}
1387 1599
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1388 1600
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1389
-			if ($globalDebug) echo "Add to DB...";
1601
+			if ($globalDebug) {
1602
+				echo "Add to DB...";
1603
+			}
1390 1604
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1391
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1605
+		} else {
1606
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1607
+		}
1392 1608
 		if ($error != '') {
1393 1609
 			return $error;
1394
-		} elseif ($globalDebug) echo "Done\n";
1610
+		} elseif ($globalDebug) {
1611
+			echo "Done\n";
1612
+		}
1395 1613
 		
1396
-		if ($globalDebug) echo "Owner Ireland: Download...";
1614
+		if ($globalDebug) {
1615
+			echo "Owner Ireland: Download...";
1616
+		}
1397 1617
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1398 1618
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1399
-			if ($globalDebug) echo "Add to DB...";
1619
+			if ($globalDebug) {
1620
+				echo "Add to DB...";
1621
+			}
1400 1622
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1401
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1623
+		} else {
1624
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1625
+		}
1402 1626
 		if ($error != '') {
1403 1627
 			return $error;
1404
-		} elseif ($globalDebug) echo "Done\n";
1405
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1628
+		} elseif ($globalDebug) {
1629
+			echo "Done\n";
1630
+		}
1631
+		if ($globalDebug) {
1632
+			echo "Owner Switzerland: Download...";
1633
+		}
1406 1634
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1407 1635
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1408
-			if ($globalDebug) echo "Add to DB...";
1636
+			if ($globalDebug) {
1637
+				echo "Add to DB...";
1638
+			}
1409 1639
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1410
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1640
+		} else {
1641
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1642
+		}
1411 1643
 		if ($error != '') {
1412 1644
 			return $error;
1413
-		} elseif ($globalDebug) echo "Done\n";
1414
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
1645
+		} elseif ($globalDebug) {
1646
+			echo "Done\n";
1647
+		}
1648
+		if ($globalDebug) {
1649
+			echo "Owner Czech Republic: Download...";
1650
+		}
1415 1651
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1416 1652
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1417
-			if ($globalDebug) echo "Add to DB...";
1653
+			if ($globalDebug) {
1654
+				echo "Add to DB...";
1655
+			}
1418 1656
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1419
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1657
+		} else {
1658
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1659
+		}
1420 1660
 		if ($error != '') {
1421 1661
 			return $error;
1422
-		} elseif ($globalDebug) echo "Done\n";
1423
-		if ($globalDebug) echo "Owner Australia: Download...";
1662
+		} elseif ($globalDebug) {
1663
+			echo "Done\n";
1664
+		}
1665
+		if ($globalDebug) {
1666
+			echo "Owner Australia: Download...";
1667
+		}
1424 1668
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1425 1669
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1426
-			if ($globalDebug) echo "Add to DB...";
1670
+			if ($globalDebug) {
1671
+				echo "Add to DB...";
1672
+			}
1427 1673
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1428
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1674
+		} else {
1675
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1676
+		}
1429 1677
 		if ($error != '') {
1430 1678
 			return $error;
1431
-		} elseif ($globalDebug) echo "Done\n";
1432
-		if ($globalDebug) echo "Owner Austria: Download...";
1679
+		} elseif ($globalDebug) {
1680
+			echo "Done\n";
1681
+		}
1682
+		if ($globalDebug) {
1683
+			echo "Owner Austria: Download...";
1684
+		}
1433 1685
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1434 1686
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1435
-			if ($globalDebug) echo "Add to DB...";
1687
+			if ($globalDebug) {
1688
+				echo "Add to DB...";
1689
+			}
1436 1690
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1437
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1691
+		} else {
1692
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1693
+		}
1438 1694
 		if ($error != '') {
1439 1695
 			return $error;
1440
-		} elseif ($globalDebug) echo "Done\n";
1441
-		if ($globalDebug) echo "Owner Chile: Download...";
1696
+		} elseif ($globalDebug) {
1697
+			echo "Done\n";
1698
+		}
1699
+		if ($globalDebug) {
1700
+			echo "Owner Chile: Download...";
1701
+		}
1442 1702
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1443 1703
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1444
-			if ($globalDebug) echo "Add to DB...";
1704
+			if ($globalDebug) {
1705
+				echo "Add to DB...";
1706
+			}
1445 1707
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1446
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1708
+		} else {
1709
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1710
+		}
1447 1711
 		if ($error != '') {
1448 1712
 			return $error;
1449
-		} elseif ($globalDebug) echo "Done\n";
1450
-		if ($globalDebug) echo "Owner Colombia: Download...";
1713
+		} elseif ($globalDebug) {
1714
+			echo "Done\n";
1715
+		}
1716
+		if ($globalDebug) {
1717
+			echo "Owner Colombia: Download...";
1718
+		}
1451 1719
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1452 1720
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1453
-			if ($globalDebug) echo "Add to DB...";
1721
+			if ($globalDebug) {
1722
+				echo "Add to DB...";
1723
+			}
1454 1724
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1455
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1725
+		} else {
1726
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1727
+		}
1456 1728
 		if ($error != '') {
1457 1729
 			return $error;
1458
-		} elseif ($globalDebug) echo "Done\n";
1459
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1730
+		} elseif ($globalDebug) {
1731
+			echo "Done\n";
1732
+		}
1733
+		if ($globalDebug) {
1734
+			echo "Owner Bosnia Herzegobina: Download...";
1735
+		}
1460 1736
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1461 1737
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1462
-			if ($globalDebug) echo "Add to DB...";
1738
+			if ($globalDebug) {
1739
+				echo "Add to DB...";
1740
+			}
1463 1741
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1464
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1742
+		} else {
1743
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1744
+		}
1465 1745
 		if ($error != '') {
1466 1746
 			return $error;
1467
-		} elseif ($globalDebug) echo "Done\n";
1468
-		if ($globalDebug) echo "Owner Brazil: Download...";
1747
+		} elseif ($globalDebug) {
1748
+			echo "Done\n";
1749
+		}
1750
+		if ($globalDebug) {
1751
+			echo "Owner Brazil: Download...";
1752
+		}
1469 1753
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1470 1754
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1471
-			if ($globalDebug) echo "Add to DB...";
1755
+			if ($globalDebug) {
1756
+				echo "Add to DB...";
1757
+			}
1472 1758
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1473
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1759
+		} else {
1760
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1761
+		}
1474 1762
 		if ($error != '') {
1475 1763
 			return $error;
1476
-		} elseif ($globalDebug) echo "Done\n";
1477
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1764
+		} elseif ($globalDebug) {
1765
+			echo "Done\n";
1766
+		}
1767
+		if ($globalDebug) {
1768
+			echo "Owner Cayman Islands: Download...";
1769
+		}
1478 1770
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1479 1771
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1480
-			if ($globalDebug) echo "Add to DB...";
1772
+			if ($globalDebug) {
1773
+				echo "Add to DB...";
1774
+			}
1481 1775
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1482
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1776
+		} else {
1777
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1778
+		}
1483 1779
 		if ($error != '') {
1484 1780
 			return $error;
1485
-		} elseif ($globalDebug) echo "Done\n";
1486
-		if ($globalDebug) echo "Owner Croatia: Download...";
1781
+		} elseif ($globalDebug) {
1782
+			echo "Done\n";
1783
+		}
1784
+		if ($globalDebug) {
1785
+			echo "Owner Croatia: Download...";
1786
+		}
1487 1787
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1488 1788
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1489
-			if ($globalDebug) echo "Add to DB...";
1789
+			if ($globalDebug) {
1790
+				echo "Add to DB...";
1791
+			}
1490 1792
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1491
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1793
+		} else {
1794
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1795
+		}
1492 1796
 		if ($error != '') {
1493 1797
 			return $error;
1494
-		} elseif ($globalDebug) echo "Done\n";
1495
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
1798
+		} elseif ($globalDebug) {
1799
+			echo "Done\n";
1800
+		}
1801
+		if ($globalDebug) {
1802
+			echo "Owner Luxembourg: Download...";
1803
+		}
1496 1804
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1497 1805
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1498
-			if ($globalDebug) echo "Add to DB...";
1806
+			if ($globalDebug) {
1807
+				echo "Add to DB...";
1808
+			}
1499 1809
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1500
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1810
+		} else {
1811
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1812
+		}
1501 1813
 		if ($error != '') {
1502 1814
 			return $error;
1503
-		} elseif ($globalDebug) echo "Done\n";
1504
-		if ($globalDebug) echo "Owner Maldives: Download...";
1815
+		} elseif ($globalDebug) {
1816
+			echo "Done\n";
1817
+		}
1818
+		if ($globalDebug) {
1819
+			echo "Owner Maldives: Download...";
1820
+		}
1505 1821
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1506 1822
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1507
-			if ($globalDebug) echo "Add to DB...";
1823
+			if ($globalDebug) {
1824
+				echo "Add to DB...";
1825
+			}
1508 1826
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1509
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1827
+		} else {
1828
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1829
+		}
1510 1830
 		if ($error != '') {
1511 1831
 			return $error;
1512
-		} elseif ($globalDebug) echo "Done\n";
1513
-		if ($globalDebug) echo "Owner New Zealand: Download...";
1832
+		} elseif ($globalDebug) {
1833
+			echo "Done\n";
1834
+		}
1835
+		if ($globalDebug) {
1836
+			echo "Owner New Zealand: Download...";
1837
+		}
1514 1838
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1515 1839
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1516
-			if ($globalDebug) echo "Add to DB...";
1840
+			if ($globalDebug) {
1841
+				echo "Add to DB...";
1842
+			}
1517 1843
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1518
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1844
+		} else {
1845
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1846
+		}
1519 1847
 		if ($error != '') {
1520 1848
 			return $error;
1521
-		} elseif ($globalDebug) echo "Done\n";
1522
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1849
+		} elseif ($globalDebug) {
1850
+			echo "Done\n";
1851
+		}
1852
+		if ($globalDebug) {
1853
+			echo "Owner Papua New Guinea: Download...";
1854
+		}
1523 1855
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1524 1856
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1525
-			if ($globalDebug) echo "Add to DB...";
1857
+			if ($globalDebug) {
1858
+				echo "Add to DB...";
1859
+			}
1526 1860
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1527
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1861
+		} else {
1862
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1863
+		}
1528 1864
 		if ($error != '') {
1529 1865
 			return $error;
1530
-		} elseif ($globalDebug) echo "Done\n";
1531
-		if ($globalDebug) echo "Owner Slovakia: Download...";
1866
+		} elseif ($globalDebug) {
1867
+			echo "Done\n";
1868
+		}
1869
+		if ($globalDebug) {
1870
+			echo "Owner Slovakia: Download...";
1871
+		}
1532 1872
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1533 1873
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1534
-			if ($globalDebug) echo "Add to DB...";
1874
+			if ($globalDebug) {
1875
+				echo "Add to DB...";
1876
+			}
1535 1877
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1536
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1878
+		} else {
1879
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1880
+		}
1537 1881
 		if ($error != '') {
1538 1882
 			return $error;
1539
-		} elseif ($globalDebug) echo "Done\n";
1540
-		if ($globalDebug) echo "Owner Ecuador: Download...";
1883
+		} elseif ($globalDebug) {
1884
+			echo "Done\n";
1885
+		}
1886
+		if ($globalDebug) {
1887
+			echo "Owner Ecuador: Download...";
1888
+		}
1541 1889
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1542 1890
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1543
-			if ($globalDebug) echo "Add to DB...";
1891
+			if ($globalDebug) {
1892
+				echo "Add to DB...";
1893
+			}
1544 1894
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1545
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1895
+		} else {
1896
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1897
+		}
1546 1898
 		if ($error != '') {
1547 1899
 			return $error;
1548
-		} elseif ($globalDebug) echo "Done\n";
1549
-		if ($globalDebug) echo "Owner Iceland: Download...";
1900
+		} elseif ($globalDebug) {
1901
+			echo "Done\n";
1902
+		}
1903
+		if ($globalDebug) {
1904
+			echo "Owner Iceland: Download...";
1905
+		}
1550 1906
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1551 1907
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1552
-			if ($globalDebug) echo "Add to DB...";
1908
+			if ($globalDebug) {
1909
+				echo "Add to DB...";
1910
+			}
1553 1911
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1554
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1912
+		} else {
1913
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1914
+		}
1555 1915
 		if ($error != '') {
1556 1916
 			return $error;
1557
-		} elseif ($globalDebug) echo "Done\n";
1917
+		} elseif ($globalDebug) {
1918
+			echo "Done\n";
1919
+		}
1558 1920
 		return '';
1559 1921
 	}
1560 1922
 
1561 1923
 	public static function update_translation() {
1562 1924
 		global $tmp_dir, $globalDebug;
1563 1925
 		$error = '';
1564
-		if ($globalDebug) echo "Translation : Download...";
1926
+		if ($globalDebug) {
1927
+			echo "Translation : Download...";
1928
+		}
1565 1929
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1566 1930
 		if (file_exists($tmp_dir.'translation.zip')) {
1567
-			if ($globalDebug) echo "Unzip...";
1931
+			if ($globalDebug) {
1932
+				echo "Unzip...";
1933
+			}
1568 1934
 			update_db::unzip($tmp_dir.'translation.zip');
1569
-			if ($globalDebug) echo "Add to DB...";
1935
+			if ($globalDebug) {
1936
+				echo "Add to DB...";
1937
+			}
1570 1938
 			$error = update_db::translation();
1571
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
1939
+		} else {
1940
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
1941
+		}
1572 1942
 		if ($error != '') {
1573 1943
 			return $error;
1574
-		} elseif ($globalDebug) echo "Done\n";
1944
+		} elseif ($globalDebug) {
1945
+			echo "Done\n";
1946
+		}
1575 1947
 		return '';
1576 1948
 	}
1577 1949
 
1578 1950
 	public static function update_translation_fam() {
1579 1951
 		global $tmp_dir, $globalDebug;
1580
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1952
+		if ($globalDebug) {
1953
+			echo "Translation from FlightAirMap website : Download...";
1954
+		}
1581 1955
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1582 1956
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1583
-			if ($globalDebug) echo "Gunzip...";
1957
+			if ($globalDebug) {
1958
+				echo "Gunzip...";
1959
+			}
1584 1960
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1585
-			if ($globalDebug) echo "Add to DB...";
1961
+			if ($globalDebug) {
1962
+				echo "Add to DB...";
1963
+			}
1586 1964
 			$error = update_db::translation_fam();
1587
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
1965
+		} else {
1966
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
1967
+		}
1588 1968
 		if ($error != '') {
1589 1969
 			return $error;
1590
-		} elseif ($globalDebug) echo "Done\n";
1970
+		} elseif ($globalDebug) {
1971
+			echo "Done\n";
1972
+		}
1591 1973
 		return '';
1592 1974
 	}
1593 1975
 
1594 1976
 	public static function update_tle() {
1595 1977
 		global $tmp_dir, $globalDebug;
1596
-		if ($globalDebug) echo "Download TLE : Download...";
1978
+		if ($globalDebug) {
1979
+			echo "Download TLE : Download...";
1980
+		}
1597 1981
 		$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',
1598 1982
 		'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',
1599 1983
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1600 1984
 		foreach ($alltle as $filename) {
1601
-			if ($globalDebug) echo "downloading ".$filename.'...';
1985
+			if ($globalDebug) {
1986
+				echo "downloading ".$filename.'...';
1987
+			}
1602 1988
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1603 1989
 			if (file_exists($tmp_dir.$filename)) {
1604
-				if ($globalDebug) echo "Add to DB ".$filename."...";
1990
+				if ($globalDebug) {
1991
+					echo "Add to DB ".$filename."...";
1992
+				}
1605 1993
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1606
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
1994
+			} else {
1995
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
1996
+			}
1607 1997
 			if ($error != '') {
1608 1998
 				echo $error."\n";
1609
-			} elseif ($globalDebug) echo "Done\n";
1999
+			} elseif ($globalDebug) {
2000
+				echo "Done\n";
2001
+			}
1610 2002
 		}
1611 2003
 		return '';
1612 2004
 	}
@@ -1614,10 +2006,14 @@  discard block
 block discarded – undo
1614 2006
 	public static function update_models() {
1615 2007
 		global $tmp_dir, $globalDebug;
1616 2008
 		$error = '';
1617
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2009
+		if ($globalDebug) {
2010
+			echo "Models from FlightAirMap website : Download...";
2011
+		}
1618 2012
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1619 2013
 		if (file_exists($tmp_dir.'models.md5sum')) {
1620
-			if ($globalDebug) echo "Check files...\n";
2014
+			if ($globalDebug) {
2015
+				echo "Check files...\n";
2016
+			}
1621 2017
 			$newmodelsdb = array();
1622 2018
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1623 2019
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1636,25 +2032,35 @@  discard block
 block discarded – undo
1636 2032
 			}
1637 2033
 			$diff = array_diff($newmodelsdb,$modelsdb);
1638 2034
 			foreach ($diff as $key => $value) {
1639
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2035
+				if ($globalDebug) {
2036
+					echo 'Downloading model '.$key.' ...'."\n";
2037
+				}
1640 2038
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1641 2039
 				
1642 2040
 			}
1643 2041
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1644
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2042
+		} else {
2043
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2044
+		}
1645 2045
 		if ($error != '') {
1646 2046
 			return $error;
1647
-		} elseif ($globalDebug) echo "Done\n";
2047
+		} elseif ($globalDebug) {
2048
+			echo "Done\n";
2049
+		}
1648 2050
 		return '';
1649 2051
 	}
1650 2052
 
1651 2053
 	public static function update_space_models() {
1652 2054
 		global $tmp_dir, $globalDebug;
1653 2055
 		$error = '';
1654
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2056
+		if ($globalDebug) {
2057
+			echo "Space models from FlightAirMap website : Download...";
2058
+		}
1655 2059
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1656 2060
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1657
-			if ($globalDebug) echo "Check files...\n";
2061
+			if ($globalDebug) {
2062
+				echo "Check files...\n";
2063
+			}
1658 2064
 			$newmodelsdb = array();
1659 2065
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1660 2066
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1673,15 +2079,21 @@  discard block
 block discarded – undo
1673 2079
 			}
1674 2080
 			$diff = array_diff($newmodelsdb,$modelsdb);
1675 2081
 			foreach ($diff as $key => $value) {
1676
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2082
+				if ($globalDebug) {
2083
+					echo 'Downloading space model '.$key.' ...'."\n";
2084
+				}
1677 2085
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
1678 2086
 				
1679 2087
 			}
1680 2088
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
1681
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2089
+		} else {
2090
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2091
+		}
1682 2092
 		if ($error != '') {
1683 2093
 			return $error;
1684
-		} elseif ($globalDebug) echo "Done\n";
2094
+		} elseif ($globalDebug) {
2095
+			echo "Done\n";
2096
+		}
1685 2097
 		return '';
1686 2098
 	}
1687 2099
 
@@ -1724,7 +2136,9 @@  discard block
 block discarded – undo
1724 2136
                 }
1725 2137
 
1726 2138
 		$error = '';
1727
-		if ($globalDebug) echo "Notam : Download...";
2139
+		if ($globalDebug) {
2140
+			echo "Notam : Download...";
2141
+		}
1728 2142
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
1729 2143
 		if (file_exists($tmp_dir.'notam.rss')) {
1730 2144
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -1739,14 +2153,30 @@  discard block
 block discarded – undo
1739 2153
 				$data['fir'] = $q[0];
1740 2154
 				$data['code'] = $q[1];
1741 2155
 				$ifrvfr = $q[2];
1742
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
1743
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
1744
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
1745
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
1746
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
1747
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
1748
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
1749
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2156
+				if ($ifrvfr == 'IV') {
2157
+					$data['rules'] = 'IFR/VFR';
2158
+				}
2159
+				if ($ifrvfr == 'I') {
2160
+					$data['rules'] = 'IFR';
2161
+				}
2162
+				if ($ifrvfr == 'V') {
2163
+					$data['rules'] = 'VFR';
2164
+				}
2165
+				if ($q[4] == 'A') {
2166
+					$data['scope'] = 'Airport warning';
2167
+				}
2168
+				if ($q[4] == 'E') {
2169
+					$data['scope'] = 'Enroute warning';
2170
+				}
2171
+				if ($q[4] == 'W') {
2172
+					$data['scope'] = 'Navigation warning';
2173
+				}
2174
+				if ($q[4] == 'AE') {
2175
+					$data['scope'] = 'Airport/Enroute warning';
2176
+				}
2177
+				if ($q[4] == 'AW') {
2178
+					$data['scope'] = 'Airport/Navigation warning';
2179
+				}
1750 2180
 				//$data['scope'] = $q[4];
1751 2181
 				$data['lower_limit'] = $q[5];
1752 2182
 				$data['upper_limit'] = $q[6];
@@ -1754,8 +2184,12 @@  discard block
 block discarded – undo
1754 2184
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
1755 2185
 				$latitude = $Common->convertDec($las,'latitude');
1756 2186
 				$longitude = $Common->convertDec($lns,'longitude');
1757
-				if ($lac == 'S') $latitude = '-'.$latitude;
1758
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2187
+				if ($lac == 'S') {
2188
+					$latitude = '-'.$latitude;
2189
+				}
2190
+				if ($lnc == 'W') {
2191
+					$longitude = '-'.$longitude;
2192
+				}
1759 2193
 				$data['center_latitude'] = $latitude;
1760 2194
 				$data['center_longitude'] = $longitude;
1761 2195
 				$data['radius'] = intval($radius);
@@ -1785,10 +2219,14 @@  discard block
 block discarded – undo
1785 2219
 				$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']);
1786 2220
 				unset($data);
1787 2221
 			} 
1788
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2222
+		} else {
2223
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2224
+		}
1789 2225
 		if ($error != '') {
1790 2226
 			return $error;
1791
-		} elseif ($globalDebug) echo "Done\n";
2227
+		} elseif ($globalDebug) {
2228
+			echo "Done\n";
2229
+		}
1792 2230
 		return '';
1793 2231
 	}
1794 2232
 	
@@ -1807,8 +2245,11 @@  discard block
 block discarded – undo
1807 2245
                         return "error : ".$e->getMessage();
1808 2246
                 }
1809 2247
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
1810
-                if ($row['nb'] > 0) return false;
1811
-                else return true;
2248
+                if ($row['nb'] > 0) {
2249
+                	return false;
2250
+                } else {
2251
+                	return true;
2252
+                }
1812 2253
 	}
1813 2254
 
1814 2255
 	public static function insert_last_update() {
@@ -1838,8 +2279,11 @@  discard block
 block discarded – undo
1838 2279
                         return "error : ".$e->getMessage();
1839 2280
                 }
1840 2281
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
1841
-                if ($row['nb'] > 0) return false;
1842
-                else return true;
2282
+                if ($row['nb'] > 0) {
2283
+                	return false;
2284
+                } else {
2285
+                	return true;
2286
+                }
1843 2287
 	}
1844 2288
 
1845 2289
 	public static function insert_last_notam_update() {
@@ -1869,8 +2313,11 @@  discard block
 block discarded – undo
1869 2313
                         return "error : ".$e->getMessage();
1870 2314
                 }
1871 2315
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
1872
-                if ($row['nb'] > 0) return false;
1873
-                else return true;
2316
+                if ($row['nb'] > 0) {
2317
+                	return false;
2318
+                } else {
2319
+                	return true;
2320
+                }
1874 2321
 	}
1875 2322
 
1876 2323
 	public static function insert_last_owner_update() {
@@ -1899,8 +2346,11 @@  discard block
 block discarded – undo
1899 2346
                         return "error : ".$e->getMessage();
1900 2347
                 }
1901 2348
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
1902
-                if ($row['nb'] > 0) return false;
1903
-                else return true;
2349
+                if ($row['nb'] > 0) {
2350
+                	return false;
2351
+                } else {
2352
+                	return true;
2353
+                }
1904 2354
 	}
1905 2355
 
1906 2356
 	public static function insert_last_schedules_update() {
@@ -1929,8 +2379,11 @@  discard block
 block discarded – undo
1929 2379
                         return "error : ".$e->getMessage();
1930 2380
                 }
1931 2381
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
1932
-                if ($row['nb'] > 0) return false;
1933
-                else return true;
2382
+                if ($row['nb'] > 0) {
2383
+                	return false;
2384
+                } else {
2385
+                	return true;
2386
+                }
1934 2387
 	}
1935 2388
 
1936 2389
 	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.
require/libs/Predict/Predict/Math.php 3 patches
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -42,6 +42,10 @@  discard block
 block discarded – undo
42 42
     }
43 43
 
44 44
     /* Returns arccosine of rgument */
45
+
46
+    /**
47
+     * @param double $arg
48
+     */
45 49
     public static function ArcCos($arg)
46 50
     {
47 51
         return Predict::pio2 - self::ArcSin($arg);
@@ -68,6 +72,10 @@  discard block
 block discarded – undo
68 72
     }
69 73
 
70 74
     /* Multiplies the vector v1 by the scalar k to produce the vector v2 */
75
+
76
+    /**
77
+     * @param integer $k
78
+     */
71 79
     public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2)
72 80
     {
73 81
         $v2->x = $k * $v1->x;
@@ -155,6 +163,10 @@  discard block
 block discarded – undo
155 163
     }
156 164
 
157 165
     /* Returns arg1 mod arg2 */
166
+
167
+    /**
168
+     * @param double $arg1
169
+     */
158 170
     public static function Modulus($arg1, $arg2)
159 171
     {
160 172
         $ret_val  = $arg1;
@@ -169,6 +181,10 @@  discard block
 block discarded – undo
169 181
     }
170 182
 
171 183
     /* Returns fractional part of double argument */
184
+
185
+    /**
186
+     * @param double $arg
187
+     */
172 188
     public static function Frac($arg)
173 189
     {
174 190
         return $arg - floor($arg);
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -19,178 +19,178 @@
 block discarded – undo
19 19
  */
20 20
 class Predict_Math
21 21
 {
22
-    /* Returns sign of a float */
23
-    public static function Sign($arg)
24
-    {
25
-        if ($arg > 0 ) {
26
-            return 1;
27
-        } else if ($arg < 0 ) {
28
-            return -1;
29
-        } else {
30
-            return 0;
31
-        }
32
-    }
33
-
34
-    /* Returns the arcsine of the argument */
35
-    public static function ArcSin($arg)
36
-    {
37
-        if (abs($arg) >= 1 ) {
38
-            return (self::Sign($arg) * Predict::pio2);
39
-        } else {
40
-            return(atan($arg / sqrt(1 - $arg * $arg)));
41
-        }
42
-    }
43
-
44
-    /* Returns arccosine of rgument */
45
-    public static function ArcCos($arg)
46
-    {
47
-        return Predict::pio2 - self::ArcSin($arg);
48
-    }
49
-
50
-    /* Adds vectors v1 and v2 together to produce v3 */
51
-    public static function Vec_Add(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3)
52
-    {
53
-        $v3->x = $v1->x + $v2->x;
54
-        $v3->y = $v1->y + $v2->y;
55
-        $v3->z = $v1->z + $v2->z;
56
-
57
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
58
-    }
59
-
60
-    /* Subtracts vector v2 from v1 to produce v3 */
61
-    public static function Vec_Sub(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3)
62
-    {
63
-        $v3->x = $v1->x - $v2->x;
64
-        $v3->y = $v1->y - $v2->y;
65
-        $v3->z = $v1->z - $v2->z;
66
-
67
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
68
-    }
69
-
70
-    /* Multiplies the vector v1 by the scalar k to produce the vector v2 */
71
-    public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2)
72
-    {
73
-        $v2->x = $k * $v1->x;
74
-        $v2->y = $k * $v1->y;
75
-        $v2->z = $k * $v1->z;
76
-        $v2->w = abs($k) * $v1->w;
77
-    }
78
-
79
-    /* Multiplies the vector v1 by the scalar k */
80
-    public static function Scale_Vector($k, Predict_Vector $v)
81
-    {
82
-        $v->x *= $k;
83
-        $v->y *= $k;
84
-        $v->z *= $k;
85
-
86
-        $v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z);
87
-    }
88
-
89
-    /* Returns the dot product of two vectors */
90
-    public static function Dot(Predict_Vector $v1, Predict_Vector $v2)
91
-    {
92
-        return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z);
93
-    }
94
-
95
-    /* Calculates the angle between vectors v1 and v2 */
96
-    public static function Angle(Predict_Vector $v1, Predict_Vector $v2)
97
-    {
98
-        $v1->w = sqrt($v1->x * $v1->x + $v1->y * $v1->y + $v1->z * $v1->z);
99
-        $v2->w = sqrt($v2->x * $v2->x + $v2->y * $v2->y + $v2->z * $v2->z);
100
-        return (self::ArcCos(self::Dot($v1, $v2) / ($v1->w * $v2->w)));
101
-    }
102
-
103
-    /* Produces cross product of v1 and v2, and returns in v3 */
104
-    public static function Cross(Predict_Vector $v1, Predict_Vector $v2 ,Predict_Vector $v3)
105
-    {
106
-        $v3->x = $v1->y * $v2->z - $v1->z * $v2->y;
107
-        $v3->y = $v1->z * $v2->x - $v1->x * $v2->z;
108
-        $v3->z = $v1->x * $v2->y - $v1->y * $v2->x;
109
-
110
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
111
-    }
112
-
113
-    /* Normalizes a vector */
114
-    public static function Normalize(Predict_Vector $v )
115
-    {
116
-        $v->x /= $v->w;
117
-        $v->y /= $v->w;
118
-        $v->z /= $v->w;
119
-    }
120
-
121
-    /* Four-quadrant arctan function */
122
-    public static function AcTan($sinx, $cosx)
123
-    {
124
-        if ($cosx == 0) {
125
-            if ($sinx > 0) {
126
-                return Predict::pio2;
127
-            } else {
128
-                return Predict::x3pio2;
129
-            }
130
-        } else {
131
-            if ($cosx > 0) {
132
-                if ($sinx > 0) {
133
-                    return atan($sinx / $cosx);
134
-                } else {
135
-                    return Predict::twopi + atan($sinx / $cosx);
136
-                }
137
-            } else {
138
-                return Predict::pi + atan($sinx / $cosx);
139
-            }
140
-        }
141
-    }
142
-
143
-    /* Returns mod 2pi of argument */
144
-    public static function FMod2p($x)
145
-    {
146
-        $ret_val  = $x;
147
-        $i        = (int) ($ret_val / Predict::twopi);
148
-        $ret_val -= $i * Predict::twopi;
149
-
150
-        if ($ret_val < 0) {
151
-            $ret_val += Predict::twopi;
152
-        }
153
-
154
-        return $ret_val;
155
-    }
156
-
157
-    /* Returns arg1 mod arg2 */
158
-    public static function Modulus($arg1, $arg2)
159
-    {
160
-        $ret_val  = $arg1;
161
-        $i        = (int) ($ret_val / $arg2);
162
-        $ret_val -= $i * $arg2;
163
-
164
-        if ($ret_val < 0) {
165
-            $ret_val += $arg2;
166
-        }
167
-
168
-        return $ret_val;
169
-    }
170
-
171
-    /* Returns fractional part of double argument */
172
-    public static function Frac($arg)
173
-    {
174
-        return $arg - floor($arg);
175
-    }
176
-
177
-    /* Converts the satellite's position and velocity  */
178
-    /* vectors from normalised values to km and km/sec */
179
-    public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel)
180
-    {
181
-        self::Scale_Vector(Predict::xkmper, $pos);
182
-        self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel);
183
-    }
184
-
185
-    /* Returns angle in radians from arg in degrees */
186
-    public static function Radians($arg)
187
-    {
188
-        return $arg * Predict::de2ra;
189
-    }
190
-
191
-    /* Returns angle in degrees from arg in rads */
192
-    public static function Degrees($arg)
193
-    {
194
-      return $arg / Predict::de2ra;
195
-    }
22
+	/* Returns sign of a float */
23
+	public static function Sign($arg)
24
+	{
25
+		if ($arg > 0 ) {
26
+			return 1;
27
+		} else if ($arg < 0 ) {
28
+			return -1;
29
+		} else {
30
+			return 0;
31
+		}
32
+	}
33
+
34
+	/* Returns the arcsine of the argument */
35
+	public static function ArcSin($arg)
36
+	{
37
+		if (abs($arg) >= 1 ) {
38
+			return (self::Sign($arg) * Predict::pio2);
39
+		} else {
40
+			return(atan($arg / sqrt(1 - $arg * $arg)));
41
+		}
42
+	}
43
+
44
+	/* Returns arccosine of rgument */
45
+	public static function ArcCos($arg)
46
+	{
47
+		return Predict::pio2 - self::ArcSin($arg);
48
+	}
49
+
50
+	/* Adds vectors v1 and v2 together to produce v3 */
51
+	public static function Vec_Add(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3)
52
+	{
53
+		$v3->x = $v1->x + $v2->x;
54
+		$v3->y = $v1->y + $v2->y;
55
+		$v3->z = $v1->z + $v2->z;
56
+
57
+		$v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
58
+	}
59
+
60
+	/* Subtracts vector v2 from v1 to produce v3 */
61
+	public static function Vec_Sub(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3)
62
+	{
63
+		$v3->x = $v1->x - $v2->x;
64
+		$v3->y = $v1->y - $v2->y;
65
+		$v3->z = $v1->z - $v2->z;
66
+
67
+		$v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
68
+	}
69
+
70
+	/* Multiplies the vector v1 by the scalar k to produce the vector v2 */
71
+	public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2)
72
+	{
73
+		$v2->x = $k * $v1->x;
74
+		$v2->y = $k * $v1->y;
75
+		$v2->z = $k * $v1->z;
76
+		$v2->w = abs($k) * $v1->w;
77
+	}
78
+
79
+	/* Multiplies the vector v1 by the scalar k */
80
+	public static function Scale_Vector($k, Predict_Vector $v)
81
+	{
82
+		$v->x *= $k;
83
+		$v->y *= $k;
84
+		$v->z *= $k;
85
+
86
+		$v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z);
87
+	}
88
+
89
+	/* Returns the dot product of two vectors */
90
+	public static function Dot(Predict_Vector $v1, Predict_Vector $v2)
91
+	{
92
+		return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z);
93
+	}
94
+
95
+	/* Calculates the angle between vectors v1 and v2 */
96
+	public static function Angle(Predict_Vector $v1, Predict_Vector $v2)
97
+	{
98
+		$v1->w = sqrt($v1->x * $v1->x + $v1->y * $v1->y + $v1->z * $v1->z);
99
+		$v2->w = sqrt($v2->x * $v2->x + $v2->y * $v2->y + $v2->z * $v2->z);
100
+		return (self::ArcCos(self::Dot($v1, $v2) / ($v1->w * $v2->w)));
101
+	}
102
+
103
+	/* Produces cross product of v1 and v2, and returns in v3 */
104
+	public static function Cross(Predict_Vector $v1, Predict_Vector $v2 ,Predict_Vector $v3)
105
+	{
106
+		$v3->x = $v1->y * $v2->z - $v1->z * $v2->y;
107
+		$v3->y = $v1->z * $v2->x - $v1->x * $v2->z;
108
+		$v3->z = $v1->x * $v2->y - $v1->y * $v2->x;
109
+
110
+		$v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
111
+	}
112
+
113
+	/* Normalizes a vector */
114
+	public static function Normalize(Predict_Vector $v )
115
+	{
116
+		$v->x /= $v->w;
117
+		$v->y /= $v->w;
118
+		$v->z /= $v->w;
119
+	}
120
+
121
+	/* Four-quadrant arctan function */
122
+	public static function AcTan($sinx, $cosx)
123
+	{
124
+		if ($cosx == 0) {
125
+			if ($sinx > 0) {
126
+				return Predict::pio2;
127
+			} else {
128
+				return Predict::x3pio2;
129
+			}
130
+		} else {
131
+			if ($cosx > 0) {
132
+				if ($sinx > 0) {
133
+					return atan($sinx / $cosx);
134
+				} else {
135
+					return Predict::twopi + atan($sinx / $cosx);
136
+				}
137
+			} else {
138
+				return Predict::pi + atan($sinx / $cosx);
139
+			}
140
+		}
141
+	}
142
+
143
+	/* Returns mod 2pi of argument */
144
+	public static function FMod2p($x)
145
+	{
146
+		$ret_val  = $x;
147
+		$i        = (int) ($ret_val / Predict::twopi);
148
+		$ret_val -= $i * Predict::twopi;
149
+
150
+		if ($ret_val < 0) {
151
+			$ret_val += Predict::twopi;
152
+		}
153
+
154
+		return $ret_val;
155
+	}
156
+
157
+	/* Returns arg1 mod arg2 */
158
+	public static function Modulus($arg1, $arg2)
159
+	{
160
+		$ret_val  = $arg1;
161
+		$i        = (int) ($ret_val / $arg2);
162
+		$ret_val -= $i * $arg2;
163
+
164
+		if ($ret_val < 0) {
165
+			$ret_val += $arg2;
166
+		}
167
+
168
+		return $ret_val;
169
+	}
170
+
171
+	/* Returns fractional part of double argument */
172
+	public static function Frac($arg)
173
+	{
174
+		return $arg - floor($arg);
175
+	}
176
+
177
+	/* Converts the satellite's position and velocity  */
178
+	/* vectors from normalised values to km and km/sec */
179
+	public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel)
180
+	{
181
+		self::Scale_Vector(Predict::xkmper, $pos);
182
+		self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel);
183
+	}
184
+
185
+	/* Returns angle in radians from arg in degrees */
186
+	public static function Radians($arg)
187
+	{
188
+		return $arg * Predict::de2ra;
189
+	}
190
+
191
+	/* Returns angle in degrees from arg in rads */
192
+	public static function Degrees($arg)
193
+	{
194
+	  return $arg / Predict::de2ra;
195
+	}
196 196
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
     /* Returns sign of a float */
23 23
     public static function Sign($arg)
24 24
     {
25
-        if ($arg > 0 ) {
25
+        if ($arg > 0) {
26 26
             return 1;
27
-        } else if ($arg < 0 ) {
27
+        } else if ($arg < 0) {
28 28
             return -1;
29 29
         } else {
30 30
             return 0;
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
     /* Returns the arcsine of the argument */
35 35
     public static function ArcSin($arg)
36 36
     {
37
-        if (abs($arg) >= 1 ) {
38
-            return (self::Sign($arg) * Predict::pio2);
37
+        if (abs($arg) >= 1) {
38
+            return (self::Sign($arg)*Predict::pio2);
39 39
         } else {
40
-            return(atan($arg / sqrt(1 - $arg * $arg)));
40
+            return(atan($arg/sqrt(1 - $arg*$arg)));
41 41
         }
42 42
     }
43 43
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $v3->y = $v1->y + $v2->y;
55 55
         $v3->z = $v1->z + $v2->z;
56 56
 
57
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
57
+        $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z);
58 58
     }
59 59
 
60 60
     /* Subtracts vector v2 from v1 to produce v3 */
@@ -64,16 +64,16 @@  discard block
 block discarded – undo
64 64
         $v3->y = $v1->y - $v2->y;
65 65
         $v3->z = $v1->z - $v2->z;
66 66
 
67
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
67
+        $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z);
68 68
     }
69 69
 
70 70
     /* Multiplies the vector v1 by the scalar k to produce the vector v2 */
71 71
     public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2)
72 72
     {
73
-        $v2->x = $k * $v1->x;
74
-        $v2->y = $k * $v1->y;
75
-        $v2->z = $k * $v1->z;
76
-        $v2->w = abs($k) * $v1->w;
73
+        $v2->x = $k*$v1->x;
74
+        $v2->y = $k*$v1->y;
75
+        $v2->z = $k*$v1->z;
76
+        $v2->w = abs($k)*$v1->w;
77 77
     }
78 78
 
79 79
     /* Multiplies the vector v1 by the scalar k */
@@ -83,35 +83,35 @@  discard block
 block discarded – undo
83 83
         $v->y *= $k;
84 84
         $v->z *= $k;
85 85
 
86
-        $v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z);
86
+        $v->w = sqrt($v->x*$v->x + $v->y*$v->y + $v->z*$v->z);
87 87
     }
88 88
 
89 89
     /* Returns the dot product of two vectors */
90 90
     public static function Dot(Predict_Vector $v1, Predict_Vector $v2)
91 91
     {
92
-        return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z);
92
+        return ($v1->x*$v2->x + $v1->y*$v2->y + $v1->z*$v2->z);
93 93
     }
94 94
 
95 95
     /* Calculates the angle between vectors v1 and v2 */
96 96
     public static function Angle(Predict_Vector $v1, Predict_Vector $v2)
97 97
     {
98
-        $v1->w = sqrt($v1->x * $v1->x + $v1->y * $v1->y + $v1->z * $v1->z);
99
-        $v2->w = sqrt($v2->x * $v2->x + $v2->y * $v2->y + $v2->z * $v2->z);
100
-        return (self::ArcCos(self::Dot($v1, $v2) / ($v1->w * $v2->w)));
98
+        $v1->w = sqrt($v1->x*$v1->x + $v1->y*$v1->y + $v1->z*$v1->z);
99
+        $v2->w = sqrt($v2->x*$v2->x + $v2->y*$v2->y + $v2->z*$v2->z);
100
+        return (self::ArcCos(self::Dot($v1, $v2)/($v1->w*$v2->w)));
101 101
     }
102 102
 
103 103
     /* Produces cross product of v1 and v2, and returns in v3 */
104
-    public static function Cross(Predict_Vector $v1, Predict_Vector $v2 ,Predict_Vector $v3)
104
+    public static function Cross(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3)
105 105
     {
106
-        $v3->x = $v1->y * $v2->z - $v1->z * $v2->y;
107
-        $v3->y = $v1->z * $v2->x - $v1->x * $v2->z;
108
-        $v3->z = $v1->x * $v2->y - $v1->y * $v2->x;
106
+        $v3->x = $v1->y*$v2->z - $v1->z*$v2->y;
107
+        $v3->y = $v1->z*$v2->x - $v1->x*$v2->z;
108
+        $v3->z = $v1->x*$v2->y - $v1->y*$v2->x;
109 109
 
110
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
110
+        $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z);
111 111
     }
112 112
 
113 113
     /* Normalizes a vector */
114
-    public static function Normalize(Predict_Vector $v )
114
+    public static function Normalize(Predict_Vector $v)
115 115
     {
116 116
         $v->x /= $v->w;
117 117
         $v->y /= $v->w;
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
         } else {
131 131
             if ($cosx > 0) {
132 132
                 if ($sinx > 0) {
133
-                    return atan($sinx / $cosx);
133
+                    return atan($sinx/$cosx);
134 134
                 } else {
135
-                    return Predict::twopi + atan($sinx / $cosx);
135
+                    return Predict::twopi + atan($sinx/$cosx);
136 136
                 }
137 137
             } else {
138
-                return Predict::pi + atan($sinx / $cosx);
138
+                return Predict::pi + atan($sinx/$cosx);
139 139
             }
140 140
         }
141 141
     }
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
     public static function FMod2p($x)
145 145
     {
146 146
         $ret_val  = $x;
147
-        $i        = (int) ($ret_val / Predict::twopi);
148
-        $ret_val -= $i * Predict::twopi;
147
+        $i        = (int) ($ret_val/Predict::twopi);
148
+        $ret_val -= $i*Predict::twopi;
149 149
 
150 150
         if ($ret_val < 0) {
151 151
             $ret_val += Predict::twopi;
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
     public static function Modulus($arg1, $arg2)
159 159
     {
160 160
         $ret_val  = $arg1;
161
-        $i        = (int) ($ret_val / $arg2);
162
-        $ret_val -= $i * $arg2;
161
+        $i        = (int) ($ret_val/$arg2);
162
+        $ret_val -= $i*$arg2;
163 163
 
164 164
         if ($ret_val < 0) {
165 165
             $ret_val += $arg2;
@@ -179,18 +179,18 @@  discard block
 block discarded – undo
179 179
     public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel)
180 180
     {
181 181
         self::Scale_Vector(Predict::xkmper, $pos);
182
-        self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel);
182
+        self::Scale_Vector(Predict::xkmper*Predict::xmnpda/Predict::secday, $vel);
183 183
     }
184 184
 
185 185
     /* Returns angle in radians from arg in degrees */
186 186
     public static function Radians($arg)
187 187
     {
188
-        return $arg * Predict::de2ra;
188
+        return $arg*Predict::de2ra;
189 189
     }
190 190
 
191 191
     /* Returns angle in degrees from arg in rads */
192 192
     public static function Degrees($arg)
193 193
     {
194
-      return $arg / Predict::de2ra;
194
+      return $arg/Predict::de2ra;
195 195
     }
196 196
 }
Please login to merge, or discard this patch.
require/libs/Predict/Predict/Sat.php 4 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
     }
125 125
 
126 126
     /** Initialise satellite data.
127
-     *  @param sat The satellite to initialise.
128
-     *  @param qth Optional QTH info, use (0,0) if NULL.
127
+     *  @param sat Predict_Sat satellite to initialise.
128
+     *  @param qth Predict_QTH QTH info, use (0,0) if NULL.
129 129
      *
130 130
      * This function calculates the satellite data at t = 0, ie. epoch time
131 131
      * The function is called automatically by gtk_sat_data_read_sat.
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
 
217 217
     /** Determinte whether satellite is in geostationary orbit.
218 218
      *  @author John A. Magliacane, KD2BD
219
-     *  @param sat Pointer to satellite data.
220
-     *  @return TRUE if the satellite appears to be in geostationary orbit,
219
+     *  @param sat Predict_Sat to satellite data.
220
+     *  @return boolean if the satellite appears to be in geostationary orbit,
221 221
      *          FALSE otherwise.
222 222
      *
223 223
      * A satellite is in geostationary orbit if
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
     /** Determine whether satellite has decayed.
240 240
      *  @author John A. Magliacane, KD2BD
241 241
      *  @author Alexandru Csete, OZ9AEC
242
-     *  @param sat Pointer to satellite data.
243
-     *  @return TRUE if the satellite appears to have decayed, FALSE otherwise.
242
+     *  @param sat Predict_Sat to satellite data.
243
+     *  @return boolean if the satellite appears to have decayed, FALSE otherwise.
244 244
      *  @bug Modified version of the predict code but it is not tested.
245 245
      *
246 246
      * A satellite is decayed if
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
      * @param float       $time The daynum the satellite is calculated for
274 274
      * @param Predict_QTH $qth  The observer location
275 275
      *
276
-     * @return null on failure, float otherwise
276
+     * @return null|double on failure, float otherwise
277 277
      */
278 278
     public function calculateApparentMagnitude($time, Predict_QTH $qth)
279 279
     {
Please login to merge, or discard this patch.
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -22,304 +22,304 @@
 block discarded – undo
22 22
  */
23 23
 class Predict_Sat
24 24
 {
25
-    // Fifth root of a hundred, used for magnitude calculation
26
-    const POGSONS_RATIO = 2.5118864315096;
27
-
28
-    public $name     = null;
29
-    public $nickname = null;
30
-    public $website  = null;
31
-
32
-    public $tle      = null;   /*!< Keplerian elements */
33
-    public $flags    = 0;      /*!< Flags for algo ctrl */
34
-    public $sgps     = null;
35
-    public $dps      = null;
36
-    public $deep_arg = null;
37
-    public $pos      = null;   /*!< Raw position and range */
38
-    public $vel      = null;   /*!< Raw velocity */
39
-
40
-    /*** FIXME: REMOVE */
41
-    public $bearing = null;   /*!< Az, El, range and vel */
42
-    public $astro   = null;   /*!< Ra and Decl */
43
-    /*** END */
44
-
45
-    /* time keeping fields */
46
-    public $jul_epoch = null;
47
-    public $jul_utc   = null;
48
-    public $tsince    = null;
49
-    public $aos       = null;    /*!< Next AOS. */
50
-    public $los       = null;    /*!< Next LOS */
51
-
52
-    public $az         = null;   /*!< Azimuth [deg] */
53
-    public $el         = null;   /*!< Elevation [deg] */
54
-    public $range      = null;   /*!< Range [km] */
55
-    public $range_rate = null;   /*!< Range Rate [km/sec] */
56
-    public $ra         = null;   /*!< Right Ascension [deg] */
57
-    public $dec        = null;   /*!< Declination [deg] */
58
-    public $ssplat     = null;   /*!< SSP latitude [deg] */
59
-    public $ssplon     = null;   /*!< SSP longitude [deg] */
60
-    public $alt        = null;   /*!< altitude [km] */
61
-    public $velo       = null;   /*!< velocity [km/s] */
62
-    public $ma         = null;   /*!< mean anomaly */
63
-    public $footprint  = null;   /*!< footprint */
64
-    public $phase      = null;   /*!< orbit phase */
65
-    public $meanmo     = null;   /*!< mean motion kept in rev/day */
66
-    public $orbit      = null;   /*!< orbit number */
67
-    public $otype      = null;   /*!< orbit type. */
68
-
69
-    public function __construct(Predict_TLE $tle)
70
-    {
71
-        $headerParts    = explode(' ', $tle->header);
72
-        $this->name     = $headerParts[0];
73
-        $this->nickname = $this->name;
74
-        $this->tle      = $tle;
75
-        $this->pos      = new Predict_Vector();
76
-        $this->vel      = new Predict_Vector();
77
-        $this->sgps     = new Predict_SGSDPStatic();
78
-        $this->deep_arg = new Predict_DeepArg();
79
-        $this->dps      = new Predict_DeepStatic();
80
-
81
-        $this->select_ephemeris();
82
-        $this->sat_data_init_sat($this);
83
-    }
84
-
85
-    /* Selects the apropriate ephemeris type to be used */
86
-    /* for predictions according to the data in the TLE */
87
-    /* It also processes values in the tle set so that  */
88
-    /* they are apropriate for the sgp4/sdp4 routines   */
89
-    public function select_ephemeris()
90
-    {
91
-        /* Preprocess tle set */
92
-        $this->tle->xnodeo *= Predict::de2ra;
93
-        $this->tle->omegao *= Predict::de2ra;
94
-        $this->tle->xmo    *= Predict::de2ra;
95
-        $this->tle->xincl  *= Predict::de2ra;
96
-        $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda;
97
-
98
-        /* store mean motion before conversion */
99
-        $this->meanmo       = $this->tle->xno;
100
-        $this->tle->xno     = $this->tle->xno * $temp * Predict::xmnpda;
101
-        $this->tle->xndt2o *= $temp;
102
-        $this->tle->xndd6o  = $this->tle->xndd6o * $temp / Predict::xmnpda;
103
-        $this->tle->bstar  /= Predict::ae;
104
-
105
-        /* Period > 225 minutes is deep space */
106
-        $dd1 = Predict::xke / $this->tle->xno;
107
-        $dd2 = Predict::tothrd;
108
-        $a1 = pow($dd1, $dd2);
109
-        $r1 = cos($this->tle->xincl);
110
-        $dd1 = 1.0 - $this->tle->eo * $this->tle->eo;
111
-        $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5);
112
-        $del1 = $temp / ($a1 * $a1);
113
-        $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 *
114
-                                 ($del1 * 1.654320987654321 + 1.0)));
115
-        $delo = $temp / ($ao * $ao);
116
-        $xnodp = $this->tle->xno / ($delo + 1.0);
117
-
118
-        /* Select a deep-space/near-earth ephemeris */
119
-        if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) {
120
-            $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
121
-        } else {
122
-            $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
123
-        }
124
-    }
125
-
126
-    /** Initialise satellite data.
127
-     *  @param sat The satellite to initialise.
128
-     *  @param qth Optional QTH info, use (0,0) if NULL.
129
-     *
130
-     * This function calculates the satellite data at t = 0, ie. epoch time
131
-     * The function is called automatically by gtk_sat_data_read_sat.
132
-     */
133
-    public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null)
134
-    {
135
-        $obs_geodetic = new Predict_Geodetic();
136
-        $obs_set = new Predict_ObsSet();
137
-        $sat_geodetic = new Predict_Geodetic();
138
-        /* double jul_utc, age; */
139
-
140
-        $jul_utc = Predict_Time::Julian_Date_of_Epoch($sat->tle->epoch); // => tsince = 0.0
141
-        $sat->jul_epoch = $jul_utc;
142
-
143
-        /* initialise observer location */
144
-        if ($qth != null) {
145
-            $obs_geodetic->lon = $qth->lon * Predict::de2ra;
146
-            $obs_geodetic->lat = $qth->lat * Predict::de2ra;
147
-            $obs_geodetic->alt = $qth->alt / 1000.0;
148
-            $obs_geodetic->theta = 0;
149
-        }
150
-        else {
151
-            $obs_geodetic->lon = 0.0;
152
-            $obs_geodetic->lat = 0.0;
153
-            $obs_geodetic->alt = 0.0;
154
-            $obs_geodetic->theta = 0;
155
-        }
156
-
157
-        /* execute computations */
158
-        $sdpsgp = Predict_SGPSDP::getInstance($sat);
159
-        if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
160
-            $sdpsgp->SDP4($sat, 0.0);
161
-        } else {
162
-            $sdpsgp->SGP4($sat, 0.0);
163
-        }
164
-
165
-        /* scale position and velocity to km and km/sec */
166
-        Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
167
-
168
-        /* get the velocity of the satellite */
169
-        $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
170
-        $sat->velo = $sat->vel->w;
171
-        Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
172
-        Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic);
173
-
174
-        while ($sat_geodetic->lon < -Predict::pi) {
175
-            $sat_geodetic->lon += Predict::twopi;
176
-        }
177
-
178
-        while ($sat_geodetic->lon > Predict::pi) {
179
-            $sat_geodetic->lon -= Predict::twopi;
180
-        }
181
-
182
-        $sat->az = Predict_Math::Degrees($obs_set->az);
183
-        $sat->el = Predict_Math::Degrees($obs_set->el);
184
-        $sat->range = $obs_set->range;
185
-        $sat->range_rate = $obs_set->range_rate;
186
-        $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat);
187
-        $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
188
-        $sat->alt = $sat_geodetic->alt;
189
-        $sat->ma = Predict_Math::Degrees($sat->phase);
190
-        $sat->ma *= 256.0 / 360.0;
191
-        $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w);
192
-        $age = 0.0;
193
-        $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi +
194
-                                   $age * $sat->tle->bstar * Predict::ae) * $age +
195
-                                  $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1;
196
-
197
-        /* orbit type */
198
-        $sat->otype = $sat->get_orbit_type($sat);
199
-    }
200
-
201
-    public function get_orbit_type(Predict_Sat $sat)
202
-    {
203
-         $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN;
204
-
205
-         if ($this->geostationary($sat)) {
206
-              $orbit = Predict_SGPSDP::ORBIT_TYPE_GEO;
207
-         } else if ($this->decayed($sat)) {
208
-              $orbit = Predict_SGPSDP::ORBIT_TYPE_DECAYED;
209
-         } else {
210
-              $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN;
211
-         }
212
-
213
-         return $orbit;
214
-    }
215
-
216
-
217
-    /** Determinte whether satellite is in geostationary orbit.
218
-     *  @author John A. Magliacane, KD2BD
219
-     *  @param sat Pointer to satellite data.
220
-     *  @return TRUE if the satellite appears to be in geostationary orbit,
221
-     *          FALSE otherwise.
222
-     *
223
-     * A satellite is in geostationary orbit if
224
-     *
225
-     *     fabs (sat.meanmotion - 1.0027) < 0.0002
226
-     *
227
-     * Note: Appearantly, the mean motion can deviate much more from 1.0027 than 0.0002
228
-     */
229
-    public function geostationary(Predict_Sat $sat)
230
-    {
231
-         if (abs($sat->meanmo - 1.0027) < 0.0002) {
232
-              return true;
233
-         } else {
234
-              return false;
235
-        }
236
-    }
237
-
238
-
239
-    /** Determine whether satellite has decayed.
240
-     *  @author John A. Magliacane, KD2BD
241
-     *  @author Alexandru Csete, OZ9AEC
242
-     *  @param sat Pointer to satellite data.
243
-     *  @return TRUE if the satellite appears to have decayed, FALSE otherwise.
244
-     *  @bug Modified version of the predict code but it is not tested.
245
-     *
246
-     * A satellite is decayed if
247
-     *
248
-     *    satepoch + ((16.666666 - sat.meanmo) / (10.0*fabs(sat.drag))) < "now"
249
-     *
250
-     */
251
-    public function decayed(Predict_Sat $sat)
252
-    {
253
-        /* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the
25
+	// Fifth root of a hundred, used for magnitude calculation
26
+	const POGSONS_RATIO = 2.5118864315096;
27
+
28
+	public $name     = null;
29
+	public $nickname = null;
30
+	public $website  = null;
31
+
32
+	public $tle      = null;   /*!< Keplerian elements */
33
+	public $flags    = 0;      /*!< Flags for algo ctrl */
34
+	public $sgps     = null;
35
+	public $dps      = null;
36
+	public $deep_arg = null;
37
+	public $pos      = null;   /*!< Raw position and range */
38
+	public $vel      = null;   /*!< Raw velocity */
39
+
40
+	/*** FIXME: REMOVE */
41
+	public $bearing = null;   /*!< Az, El, range and vel */
42
+	public $astro   = null;   /*!< Ra and Decl */
43
+	/*** END */
44
+
45
+	/* time keeping fields */
46
+	public $jul_epoch = null;
47
+	public $jul_utc   = null;
48
+	public $tsince    = null;
49
+	public $aos       = null;    /*!< Next AOS. */
50
+	public $los       = null;    /*!< Next LOS */
51
+
52
+	public $az         = null;   /*!< Azimuth [deg] */
53
+	public $el         = null;   /*!< Elevation [deg] */
54
+	public $range      = null;   /*!< Range [km] */
55
+	public $range_rate = null;   /*!< Range Rate [km/sec] */
56
+	public $ra         = null;   /*!< Right Ascension [deg] */
57
+	public $dec        = null;   /*!< Declination [deg] */
58
+	public $ssplat     = null;   /*!< SSP latitude [deg] */
59
+	public $ssplon     = null;   /*!< SSP longitude [deg] */
60
+	public $alt        = null;   /*!< altitude [km] */
61
+	public $velo       = null;   /*!< velocity [km/s] */
62
+	public $ma         = null;   /*!< mean anomaly */
63
+	public $footprint  = null;   /*!< footprint */
64
+	public $phase      = null;   /*!< orbit phase */
65
+	public $meanmo     = null;   /*!< mean motion kept in rev/day */
66
+	public $orbit      = null;   /*!< orbit number */
67
+	public $otype      = null;   /*!< orbit type. */
68
+
69
+	public function __construct(Predict_TLE $tle)
70
+	{
71
+		$headerParts    = explode(' ', $tle->header);
72
+		$this->name     = $headerParts[0];
73
+		$this->nickname = $this->name;
74
+		$this->tle      = $tle;
75
+		$this->pos      = new Predict_Vector();
76
+		$this->vel      = new Predict_Vector();
77
+		$this->sgps     = new Predict_SGSDPStatic();
78
+		$this->deep_arg = new Predict_DeepArg();
79
+		$this->dps      = new Predict_DeepStatic();
80
+
81
+		$this->select_ephemeris();
82
+		$this->sat_data_init_sat($this);
83
+	}
84
+
85
+	/* Selects the apropriate ephemeris type to be used */
86
+	/* for predictions according to the data in the TLE */
87
+	/* It also processes values in the tle set so that  */
88
+	/* they are apropriate for the sgp4/sdp4 routines   */
89
+	public function select_ephemeris()
90
+	{
91
+		/* Preprocess tle set */
92
+		$this->tle->xnodeo *= Predict::de2ra;
93
+		$this->tle->omegao *= Predict::de2ra;
94
+		$this->tle->xmo    *= Predict::de2ra;
95
+		$this->tle->xincl  *= Predict::de2ra;
96
+		$temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda;
97
+
98
+		/* store mean motion before conversion */
99
+		$this->meanmo       = $this->tle->xno;
100
+		$this->tle->xno     = $this->tle->xno * $temp * Predict::xmnpda;
101
+		$this->tle->xndt2o *= $temp;
102
+		$this->tle->xndd6o  = $this->tle->xndd6o * $temp / Predict::xmnpda;
103
+		$this->tle->bstar  /= Predict::ae;
104
+
105
+		/* Period > 225 minutes is deep space */
106
+		$dd1 = Predict::xke / $this->tle->xno;
107
+		$dd2 = Predict::tothrd;
108
+		$a1 = pow($dd1, $dd2);
109
+		$r1 = cos($this->tle->xincl);
110
+		$dd1 = 1.0 - $this->tle->eo * $this->tle->eo;
111
+		$temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5);
112
+		$del1 = $temp / ($a1 * $a1);
113
+		$ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 *
114
+								 ($del1 * 1.654320987654321 + 1.0)));
115
+		$delo = $temp / ($ao * $ao);
116
+		$xnodp = $this->tle->xno / ($delo + 1.0);
117
+
118
+		/* Select a deep-space/near-earth ephemeris */
119
+		if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) {
120
+			$this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
121
+		} else {
122
+			$this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
123
+		}
124
+	}
125
+
126
+	/** Initialise satellite data.
127
+	 *  @param sat The satellite to initialise.
128
+	 *  @param qth Optional QTH info, use (0,0) if NULL.
129
+	 *
130
+	 * This function calculates the satellite data at t = 0, ie. epoch time
131
+	 * The function is called automatically by gtk_sat_data_read_sat.
132
+	 */
133
+	public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null)
134
+	{
135
+		$obs_geodetic = new Predict_Geodetic();
136
+		$obs_set = new Predict_ObsSet();
137
+		$sat_geodetic = new Predict_Geodetic();
138
+		/* double jul_utc, age; */
139
+
140
+		$jul_utc = Predict_Time::Julian_Date_of_Epoch($sat->tle->epoch); // => tsince = 0.0
141
+		$sat->jul_epoch = $jul_utc;
142
+
143
+		/* initialise observer location */
144
+		if ($qth != null) {
145
+			$obs_geodetic->lon = $qth->lon * Predict::de2ra;
146
+			$obs_geodetic->lat = $qth->lat * Predict::de2ra;
147
+			$obs_geodetic->alt = $qth->alt / 1000.0;
148
+			$obs_geodetic->theta = 0;
149
+		}
150
+		else {
151
+			$obs_geodetic->lon = 0.0;
152
+			$obs_geodetic->lat = 0.0;
153
+			$obs_geodetic->alt = 0.0;
154
+			$obs_geodetic->theta = 0;
155
+		}
156
+
157
+		/* execute computations */
158
+		$sdpsgp = Predict_SGPSDP::getInstance($sat);
159
+		if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
160
+			$sdpsgp->SDP4($sat, 0.0);
161
+		} else {
162
+			$sdpsgp->SGP4($sat, 0.0);
163
+		}
164
+
165
+		/* scale position and velocity to km and km/sec */
166
+		Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
167
+
168
+		/* get the velocity of the satellite */
169
+		$sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
170
+		$sat->velo = $sat->vel->w;
171
+		Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
172
+		Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic);
173
+
174
+		while ($sat_geodetic->lon < -Predict::pi) {
175
+			$sat_geodetic->lon += Predict::twopi;
176
+		}
177
+
178
+		while ($sat_geodetic->lon > Predict::pi) {
179
+			$sat_geodetic->lon -= Predict::twopi;
180
+		}
181
+
182
+		$sat->az = Predict_Math::Degrees($obs_set->az);
183
+		$sat->el = Predict_Math::Degrees($obs_set->el);
184
+		$sat->range = $obs_set->range;
185
+		$sat->range_rate = $obs_set->range_rate;
186
+		$sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat);
187
+		$sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
188
+		$sat->alt = $sat_geodetic->alt;
189
+		$sat->ma = Predict_Math::Degrees($sat->phase);
190
+		$sat->ma *= 256.0 / 360.0;
191
+		$sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w);
192
+		$age = 0.0;
193
+		$sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi +
194
+								   $age * $sat->tle->bstar * Predict::ae) * $age +
195
+								  $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1;
196
+
197
+		/* orbit type */
198
+		$sat->otype = $sat->get_orbit_type($sat);
199
+	}
200
+
201
+	public function get_orbit_type(Predict_Sat $sat)
202
+	{
203
+		 $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN;
204
+
205
+		 if ($this->geostationary($sat)) {
206
+			  $orbit = Predict_SGPSDP::ORBIT_TYPE_GEO;
207
+		 } else if ($this->decayed($sat)) {
208
+			  $orbit = Predict_SGPSDP::ORBIT_TYPE_DECAYED;
209
+		 } else {
210
+			  $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN;
211
+		 }
212
+
213
+		 return $orbit;
214
+	}
215
+
216
+
217
+	/** Determinte whether satellite is in geostationary orbit.
218
+	 *  @author John A. Magliacane, KD2BD
219
+	 *  @param sat Pointer to satellite data.
220
+	 *  @return TRUE if the satellite appears to be in geostationary orbit,
221
+	 *          FALSE otherwise.
222
+	 *
223
+	 * A satellite is in geostationary orbit if
224
+	 *
225
+	 *     fabs (sat.meanmotion - 1.0027) < 0.0002
226
+	 *
227
+	 * Note: Appearantly, the mean motion can deviate much more from 1.0027 than 0.0002
228
+	 */
229
+	public function geostationary(Predict_Sat $sat)
230
+	{
231
+		 if (abs($sat->meanmo - 1.0027) < 0.0002) {
232
+			  return true;
233
+		 } else {
234
+			  return false;
235
+		}
236
+	}
237
+
238
+
239
+	/** Determine whether satellite has decayed.
240
+	 *  @author John A. Magliacane, KD2BD
241
+	 *  @author Alexandru Csete, OZ9AEC
242
+	 *  @param sat Pointer to satellite data.
243
+	 *  @return TRUE if the satellite appears to have decayed, FALSE otherwise.
244
+	 *  @bug Modified version of the predict code but it is not tested.
245
+	 *
246
+	 * A satellite is decayed if
247
+	 *
248
+	 *    satepoch + ((16.666666 - sat.meanmo) / (10.0*fabs(sat.drag))) < "now"
249
+	 *
250
+	 */
251
+	public function decayed(Predict_Sat $sat)
252
+	{
253
+		/* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the
254 254
            value matches up with the value in predict 2.2.3 */
255
-        /*** FIXME decayed is treated as a static quantity.
255
+		/*** FIXME decayed is treated as a static quantity.
256 256
              It is time dependent. Also sat->jul_utc is often zero
257 257
              when this function is called
258 258
         ***/
259
-        if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) {
260
-    		return true;
261
-    	} elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) /
262
-                               (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) {
263
-              return true;
264
-        } else {
265
-              return false;
266
-        }
267
-    }
268
-
269
-    /**
270
-     * Experimental attempt at calculating apparent magnitude.  Known intrinsic
271
-     * magnitudes are listed inside the function for now.
272
-     *
273
-     * @param float       $time The daynum the satellite is calculated for
274
-     * @param Predict_QTH $qth  The observer location
275
-     *
276
-     * @return null on failure, float otherwise
277
-     */
278
-    public function calculateApparentMagnitude($time, Predict_QTH $qth)
279
-    {
280
-        // Recorded intrinsic magnitudes and their respective
281
-        // illumination and distance from heavens-above.com
282
-        static $intrinsicMagnitudes = array(
283
-            '25544' => array(
284
-                'mag'      => -1.3,
285
-                'illum'    => .5,
286
-                'distance' => 1000,
287
-            )
288
-        );
289
-
290
-        // Return null if we don't have a record of the intrinsic mag
291
-        if (!isset($intrinsicMagnitudes[$this->tle->catnr])) {
292
-            return null;
293
-        }
294
-        $imag = $intrinsicMagnitudes[$this->tle->catnr];
295
-
296
-        // Convert the observer's geodetic info to radians and km so
297
-        // we can compare vectors
298
-        $observerGeo      = new Predict_Geodetic();
299
-        $observerGeo->lat = Predict_Math::Radians($qth->lat);
300
-        $observerGeo->lon = Predict_Math::Radians($qth->lon);
301
-        $observerGeo->alt = $qth->alt * 1000;
302
-
303
-        // Now determine the sun and observer positions
304
-        $observerPos      = new Predict_Vector();
305
-        $observerVel      = new Predict_Vector();
306
-        $solarVector      = new Predict_Vector();
307
-        Predict_Solar::Calculate_Solar_Position($time, $solarVector);
308
-        Predict_SGPObs::Calculate_User_PosVel($time, $observerGeo, $observerPos, $observerVel);
309
-
310
-        // Determine the solar phase and and thus the percent illumination
311
-        $observerSatPos = new Predict_Vector();
312
-        Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos);
313
-        $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos));
314
-        $illum      = $phaseAngle / 180;
315
-
316
-        $illuminationChange            = $illum / $imag['illum'];
317
-        $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2);
318
-        $changeInMagnitude             = log(
319
-            $illuminationChange * $inverseSquareOfDistanceChange,
320
-            self::POGSONS_RATIO
321
-        );
322
-
323
-        return $imag['mag'] - $changeInMagnitude;
324
-    }
259
+		if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) {
260
+			return true;
261
+		} elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) /
262
+							   (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) {
263
+			  return true;
264
+		} else {
265
+			  return false;
266
+		}
267
+	}
268
+
269
+	/**
270
+	 * Experimental attempt at calculating apparent magnitude.  Known intrinsic
271
+	 * magnitudes are listed inside the function for now.
272
+	 *
273
+	 * @param float       $time The daynum the satellite is calculated for
274
+	 * @param Predict_QTH $qth  The observer location
275
+	 *
276
+	 * @return null on failure, float otherwise
277
+	 */
278
+	public function calculateApparentMagnitude($time, Predict_QTH $qth)
279
+	{
280
+		// Recorded intrinsic magnitudes and their respective
281
+		// illumination and distance from heavens-above.com
282
+		static $intrinsicMagnitudes = array(
283
+			'25544' => array(
284
+				'mag'      => -1.3,
285
+				'illum'    => .5,
286
+				'distance' => 1000,
287
+			)
288
+		);
289
+
290
+		// Return null if we don't have a record of the intrinsic mag
291
+		if (!isset($intrinsicMagnitudes[$this->tle->catnr])) {
292
+			return null;
293
+		}
294
+		$imag = $intrinsicMagnitudes[$this->tle->catnr];
295
+
296
+		// Convert the observer's geodetic info to radians and km so
297
+		// we can compare vectors
298
+		$observerGeo      = new Predict_Geodetic();
299
+		$observerGeo->lat = Predict_Math::Radians($qth->lat);
300
+		$observerGeo->lon = Predict_Math::Radians($qth->lon);
301
+		$observerGeo->alt = $qth->alt * 1000;
302
+
303
+		// Now determine the sun and observer positions
304
+		$observerPos      = new Predict_Vector();
305
+		$observerVel      = new Predict_Vector();
306
+		$solarVector      = new Predict_Vector();
307
+		Predict_Solar::Calculate_Solar_Position($time, $solarVector);
308
+		Predict_SGPObs::Calculate_User_PosVel($time, $observerGeo, $observerPos, $observerVel);
309
+
310
+		// Determine the solar phase and and thus the percent illumination
311
+		$observerSatPos = new Predict_Vector();
312
+		Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos);
313
+		$phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos));
314
+		$illum      = $phaseAngle / 180;
315
+
316
+		$illuminationChange            = $illum / $imag['illum'];
317
+		$inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2);
318
+		$changeInMagnitude             = log(
319
+			$illuminationChange * $inverseSquareOfDistanceChange,
320
+			self::POGSONS_RATIO
321
+		);
322
+
323
+		return $imag['mag'] - $changeInMagnitude;
324
+	}
325 325
 }
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -29,42 +29,42 @@  discard block
 block discarded – undo
29 29
     public $nickname = null;
30 30
     public $website  = null;
31 31
 
32
-    public $tle      = null;   /*!< Keplerian elements */
33
-    public $flags    = 0;      /*!< Flags for algo ctrl */
32
+    public $tle      = null; /*!< Keplerian elements */
33
+    public $flags    = 0; /*!< Flags for algo ctrl */
34 34
     public $sgps     = null;
35 35
     public $dps      = null;
36 36
     public $deep_arg = null;
37
-    public $pos      = null;   /*!< Raw position and range */
38
-    public $vel      = null;   /*!< Raw velocity */
37
+    public $pos      = null; /*!< Raw position and range */
38
+    public $vel      = null; /*!< Raw velocity */
39 39
 
40 40
     /*** FIXME: REMOVE */
41
-    public $bearing = null;   /*!< Az, El, range and vel */
42
-    public $astro   = null;   /*!< Ra and Decl */
41
+    public $bearing = null; /*!< Az, El, range and vel */
42
+    public $astro   = null; /*!< Ra and Decl */
43 43
     /*** END */
44 44
 
45 45
     /* time keeping fields */
46 46
     public $jul_epoch = null;
47 47
     public $jul_utc   = null;
48 48
     public $tsince    = null;
49
-    public $aos       = null;    /*!< Next AOS. */
50
-    public $los       = null;    /*!< Next LOS */
51
-
52
-    public $az         = null;   /*!< Azimuth [deg] */
53
-    public $el         = null;   /*!< Elevation [deg] */
54
-    public $range      = null;   /*!< Range [km] */
55
-    public $range_rate = null;   /*!< Range Rate [km/sec] */
56
-    public $ra         = null;   /*!< Right Ascension [deg] */
57
-    public $dec        = null;   /*!< Declination [deg] */
58
-    public $ssplat     = null;   /*!< SSP latitude [deg] */
59
-    public $ssplon     = null;   /*!< SSP longitude [deg] */
60
-    public $alt        = null;   /*!< altitude [km] */
61
-    public $velo       = null;   /*!< velocity [km/s] */
62
-    public $ma         = null;   /*!< mean anomaly */
63
-    public $footprint  = null;   /*!< footprint */
64
-    public $phase      = null;   /*!< orbit phase */
65
-    public $meanmo     = null;   /*!< mean motion kept in rev/day */
66
-    public $orbit      = null;   /*!< orbit number */
67
-    public $otype      = null;   /*!< orbit type. */
49
+    public $aos       = null; /*!< Next AOS. */
50
+    public $los       = null; /*!< Next LOS */
51
+
52
+    public $az         = null; /*!< Azimuth [deg] */
53
+    public $el         = null; /*!< Elevation [deg] */
54
+    public $range      = null; /*!< Range [km] */
55
+    public $range_rate = null; /*!< Range Rate [km/sec] */
56
+    public $ra         = null; /*!< Right Ascension [deg] */
57
+    public $dec        = null; /*!< Declination [deg] */
58
+    public $ssplat     = null; /*!< SSP latitude [deg] */
59
+    public $ssplon     = null; /*!< SSP longitude [deg] */
60
+    public $alt        = null; /*!< altitude [km] */
61
+    public $velo       = null; /*!< velocity [km/s] */
62
+    public $ma         = null; /*!< mean anomaly */
63
+    public $footprint  = null; /*!< footprint */
64
+    public $phase      = null; /*!< orbit phase */
65
+    public $meanmo     = null; /*!< mean motion kept in rev/day */
66
+    public $orbit      = null; /*!< orbit number */
67
+    public $otype      = null; /*!< orbit type. */
68 68
 
69 69
     public function __construct(Predict_TLE $tle)
70 70
     {
@@ -93,30 +93,30 @@  discard block
 block discarded – undo
93 93
         $this->tle->omegao *= Predict::de2ra;
94 94
         $this->tle->xmo    *= Predict::de2ra;
95 95
         $this->tle->xincl  *= Predict::de2ra;
96
-        $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda;
96
+        $temp = Predict::twopi/Predict::xmnpda/Predict::xmnpda;
97 97
 
98 98
         /* store mean motion before conversion */
99 99
         $this->meanmo       = $this->tle->xno;
100
-        $this->tle->xno     = $this->tle->xno * $temp * Predict::xmnpda;
100
+        $this->tle->xno     = $this->tle->xno*$temp*Predict::xmnpda;
101 101
         $this->tle->xndt2o *= $temp;
102
-        $this->tle->xndd6o  = $this->tle->xndd6o * $temp / Predict::xmnpda;
102
+        $this->tle->xndd6o  = $this->tle->xndd6o*$temp/Predict::xmnpda;
103 103
         $this->tle->bstar  /= Predict::ae;
104 104
 
105 105
         /* Period > 225 minutes is deep space */
106
-        $dd1 = Predict::xke / $this->tle->xno;
106
+        $dd1 = Predict::xke/$this->tle->xno;
107 107
         $dd2 = Predict::tothrd;
108 108
         $a1 = pow($dd1, $dd2);
109 109
         $r1 = cos($this->tle->xincl);
110
-        $dd1 = 1.0 - $this->tle->eo * $this->tle->eo;
111
-        $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5);
112
-        $del1 = $temp / ($a1 * $a1);
113
-        $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 *
114
-                                 ($del1 * 1.654320987654321 + 1.0)));
115
-        $delo = $temp / ($ao * $ao);
116
-        $xnodp = $this->tle->xno / ($delo + 1.0);
110
+        $dd1 = 1.0 - $this->tle->eo*$this->tle->eo;
111
+        $temp = Predict::ck2*1.5*($r1*$r1*3.0 - 1.0)/pow($dd1, 1.5);
112
+        $del1 = $temp/($a1*$a1);
113
+        $ao = $a1*(1.0 - $del1*(Predict::tothrd*0.5 + $del1*
114
+                                 ($del1*1.654320987654321 + 1.0)));
115
+        $delo = $temp/($ao*$ao);
116
+        $xnodp = $this->tle->xno/($delo + 1.0);
117 117
 
118 118
         /* Select a deep-space/near-earth ephemeris */
119
-        if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) {
119
+        if (Predict::twopi/$xnodp/Predict::xmnpda >= .15625) {
120 120
             $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
121 121
         } else {
122 122
             $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 
143 143
         /* initialise observer location */
144 144
         if ($qth != null) {
145
-            $obs_geodetic->lon = $qth->lon * Predict::de2ra;
146
-            $obs_geodetic->lat = $qth->lat * Predict::de2ra;
147
-            $obs_geodetic->alt = $qth->alt / 1000.0;
145
+            $obs_geodetic->lon = $qth->lon*Predict::de2ra;
146
+            $obs_geodetic->lat = $qth->lat*Predict::de2ra;
147
+            $obs_geodetic->alt = $qth->alt/1000.0;
148 148
             $obs_geodetic->theta = 0;
149 149
         }
150 150
         else {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
         /* execute computations */
158 158
         $sdpsgp = Predict_SGPSDP::getInstance($sat);
159
-        if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
159
+        if ($sat->flags&Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
160 160
             $sdpsgp->SDP4($sat, 0.0);
161 161
         } else {
162 162
             $sdpsgp->SGP4($sat, 0.0);
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
167 167
 
168 168
         /* get the velocity of the satellite */
169
-        $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
169
+        $sat->vel->w = sqrt($sat->vel->x*$sat->vel->x + $sat->vel->y*$sat->vel->y + $sat->vel->z*$sat->vel->z);
170 170
         $sat->velo = $sat->vel->w;
171 171
         Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
172 172
         Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic);
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
         $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
188 188
         $sat->alt = $sat_geodetic->alt;
189 189
         $sat->ma = Predict_Math::Degrees($sat->phase);
190
-        $sat->ma *= 256.0 / 360.0;
191
-        $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w);
190
+        $sat->ma *= 256.0/360.0;
191
+        $sat->footprint = 2.0*Predict::xkmper*acos(Predict::xkmper/$sat->pos->w);
192 192
         $age = 0.0;
193
-        $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi +
194
-                                   $age * $sat->tle->bstar * Predict::ae) * $age +
195
-                                  $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1;
193
+        $sat->orbit = floor(($sat->tle->xno*Predict::xmnpda/Predict::twopi +
194
+                                   $age*$sat->tle->bstar*Predict::ae)*$age +
195
+                                  $sat->tle->xmo/Predict::twopi) + $sat->tle->revnum - 1;
196 196
 
197 197
         /* orbit type */
198 198
         $sat->otype = $sat->get_orbit_type($sat);
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
              It is time dependent. Also sat->jul_utc is often zero
257 257
              when this function is called
258 258
         ***/
259
-        if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) {
259
+        if ((10.0*abs($sat->tle->xndt2o/(Predict::twopi/Predict::xmnpda/Predict::xmnpda))) == 0) {
260 260
     		return true;
261
-    	} elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) /
262
-                               (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) {
261
+    	} elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo)/
262
+                               (10.0*abs($sat->tle->xndt2o/(Predict::twopi/Predict::xmnpda/Predict::xmnpda)))) < $sat->jul_utc) {
263 263
               return true;
264 264
         } else {
265 265
               return false;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         $observerGeo      = new Predict_Geodetic();
299 299
         $observerGeo->lat = Predict_Math::Radians($qth->lat);
300 300
         $observerGeo->lon = Predict_Math::Radians($qth->lon);
301
-        $observerGeo->alt = $qth->alt * 1000;
301
+        $observerGeo->alt = $qth->alt*1000;
302 302
 
303 303
         // Now determine the sun and observer positions
304 304
         $observerPos      = new Predict_Vector();
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
         $observerSatPos = new Predict_Vector();
312 312
         Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos);
313 313
         $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos));
314
-        $illum      = $phaseAngle / 180;
314
+        $illum      = $phaseAngle/180;
315 315
 
316
-        $illuminationChange            = $illum / $imag['illum'];
317
-        $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2);
316
+        $illuminationChange            = $illum/$imag['illum'];
317
+        $inverseSquareOfDistanceChange = pow(($imag['distance']/$this->range), 2);
318 318
         $changeInMagnitude             = log(
319
-            $illuminationChange * $inverseSquareOfDistanceChange,
319
+            $illuminationChange*$inverseSquareOfDistanceChange,
320 320
             self::POGSONS_RATIO
321 321
         );
322 322
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -146,8 +146,7 @@
 block discarded – undo
146 146
             $obs_geodetic->lat = $qth->lat * Predict::de2ra;
147 147
             $obs_geodetic->alt = $qth->alt / 1000.0;
148 148
             $obs_geodetic->theta = 0;
149
-        }
150
-        else {
149
+        } else {
151 150
             $obs_geodetic->lon = 0.0;
152 151
             $obs_geodetic->lat = 0.0;
153 152
             $obs_geodetic->alt = 0.0;
Please login to merge, or discard this patch.