Completed
Push — master ( 19763d...b52f48 )
by Yannick
05:40
created
statistics.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  discard block
 block discarded – undo
7 7
 $title = _("Statistics");
8 8
 
9 9
 if (!isset($filter_name)) $filter_name = '';
10
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
11 11
 if ($airline_icao == 'all') {
12 12
 	unset($_COOKIE['stats_airline_icao']);
13
-	setcookie('stats_airline_icao', '', time()-3600);
13
+	setcookie('stats_airline_icao', '', time() - 3600);
14 14
 	$airline_icao = '';
15 15
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
16 16
 	$airline_icao = $_COOKIE['stats_airline_icao'];
17 17
 } elseif ($airline_icao == '' && isset($globalFilter)) {
18 18
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
19 19
 }
20
-setcookie('stats_airline_icao',$airline_icao);
20
+setcookie('stats_airline_icao', $airline_icao);
21 21
 require_once('header.php');
22 22
 
23 23
 ?>
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		date_default_timezone_set('UTC');
38 38
 		$lastupdate = strtotime($last_update[0]['value']);
39 39
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
40
-		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
40
+		print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
41 41
 	}
42 42
     ?>
43 43
     </div>
@@ -46,30 +46,30 @@  discard block
 block discarded – undo
46 46
     ?>
47 47
     <?php include('statistics-sub-menu.php'); ?>
48 48
     <p class="global-stats">
49
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name)); ?></span> <?php echo _("Flights"); ?></span>
50
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
51
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name)); ?></span> <?php echo _("Arrivals seen"); ?></span>
52
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
49
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name)); ?></span> <?php echo _("Flights"); ?></span>
50
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
51
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name)); ?></span> <?php echo _("Arrivals seen"); ?></span>
52
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
53 53
 	<?php
54 54
 	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
55 55
 	?>
56
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name)); ?></span> <?php echo _("Pilots"); ?></span>
57
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
56
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name)); ?></span> <?php echo _("Pilots"); ?></span>
57
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
58 58
         <?php
59 59
     	    } else {
60 60
     	?>
61
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name)); ?></span> <?php echo _("Owners"); ?></span>
62
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
61
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name)); ?></span> <?php echo _("Owners"); ?></span>
62
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
63 63
     	<?php
64 64
     	    }
65 65
     	?>
66
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name)); ?></span> <?php echo _("Aircrafts types"); ?></span>
67
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
66
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name)); ?></span> <?php echo _("Aircrafts types"); ?></span>
67
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
68 68
         <?php
69 69
     		if ($airline_icao == '') {
70 70
     	?>
71 71
         <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name)); ?></span> <?php echo _("Airlines"); ?></span>
72
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
72
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
73 73
 	<?php
74 74
 		}
75 75
 	?>
@@ -77,18 +77,18 @@  discard block
 block discarded – undo
77 77
 		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
78 78
 	?>
79 79
         <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name)); ?></span> <?php echo _("Military"); ?></span>
80
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
80
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
81 81
 	<?php
82 82
 		}
83 83
 	?>
84 84
     </p>
85
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
85
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
86 86
     <div class="specific-stats">
87 87
         <div class="row column">
88 88
             <div class="col-md-6">
89 89
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
90 90
                  <?php
91
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name);
91
+                  $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name);
92 92
 		    if (count($aircraft_array) == 0) print _("No data available");
93 93
 		    else {
94 94
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                         var data = google.visualization.arrayToDataTable([
101 101
                             ["'._("Aircraft").'", "'._("# of times").'"], ';
102 102
                             $aircraft_data = '';
103
-                          foreach($aircraft_array as $aircraft_item)
103
+                          foreach ($aircraft_array as $aircraft_item)
104 104
                                     {
105 105
                                             $aircraft_data .= '[ "'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
106 106
                                     }
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
                     <a href="<?php print $globalURL; ?>/statistics/aircraft" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
128 128
                 </div>
129 129
             </div>
130
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
130
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
131 131
 <?php
132 132
 //    echo $airline_icao;
133 133
     if ($airline_icao == '' || $airline_icao == 'all') {
134
-	$airline_array = $Stats->countAllAirlines(true,$filter_name);
134
+	$airline_array = $Stats->countAllAirlines(true, $filter_name);
135 135
 	if (count($airline_array) > 0) {
136 136
             print '<div class="col-md-6">';
137 137
 	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                         var data = google.visualization.arrayToDataTable([
144 144
                             ["'._("Airline").'", "'._("# of times").'"], ';
145 145
 	    $airline_data = '';
146
-	    foreach($airline_array as $airline_item)
146
+	    foreach ($airline_array as $airline_item)
147 147
 	    {
148 148
 		$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
149 149
 	    }
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 	}
170 170
 ?>
171 171
         </div>
172
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
172
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
173 173
 <?php
174 174
     }
175 175
 ?>
176 176
         <div class="row column">
177 177
 <?php
178
-    $flightover_array = $Stats->countAllFlightOverCountries($airline_icao,$filter_name);
178
+    $flightover_array = $Stats->countAllFlightOverCountries($airline_icao, $filter_name);
179 179
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
180 180
 	if (empty($flightover_array)) {
181 181
 	    print '<div class="col-md-12">';
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 ?>
186 186
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
187 187
 <?php
188
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name);
188
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name);
189 189
 	if (count($pilot_array) == 0) print _("No data available");
190 190
 	else {
191 191
 	    print '<div id="chart7" class="chart" width="100%"></div>
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
                         var data = google.visualization.arrayToDataTable([
197 197
                             ["'._("Pilots").'", "'._("# of times").'"], ';
198 198
 	    $pilot_data = '';
199
-	    foreach($pilot_array as $pilot_item)
199
+	    foreach ($pilot_array as $pilot_item)
200 200
 	    {
201 201
 		$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
202 202
 	    }
@@ -224,14 +224,14 @@  discard block
 block discarded – undo
224 224
                 </div>
225 225
             </div>
226 226
         
227
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
227
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
228 228
 <?php
229 229
     } else {
230 230
 ?>
231 231
             <div class="col-md-6">
232 232
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
233 233
 <?php
234
-	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name);
234
+	$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name);
235 235
 	if (count($owner_array) == 0) print _("No data available");
236 236
 	else {
237 237
 	    print '<div id="chart7" class="chart" width="100%"></div>
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
                         var data = google.visualization.arrayToDataTable([
243 243
                             ["'._("Owner").'", "'._("# of times").'"], ';
244 244
                             $owner_data = '';
245
-	    foreach($owner_array as $owner_item)
245
+	    foreach ($owner_array as $owner_item)
246 246
 	    {
247 247
 		$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
248 248
 	    }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
                 </div>
271 271
             </div>
272 272
         
273
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
273
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
274 274
 <?php
275 275
     }
276 276
     if (!empty($flightover_array)) {
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                         var data = google.visualization.arrayToDataTable([
290 290
                             ["'._("Country").'", "'._("# of times").'"], ';
291 291
                             $flightover_data = '';
292
-	    foreach($flightover_array as $flightover_item)
292
+	    foreach ($flightover_array as $flightover_item)
293 293
 	    {
294 294
 		$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
295 295
 	    }
@@ -322,14 +322,14 @@  discard block
 block discarded – undo
322 322
     }
323 323
 ?>
324 324
         </div>
325
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
325
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
326 326
 
327 327
     	
328 328
         </div>
329 329
         <div class="row column">
330 330
             <div class="col-md-6">
331 331
 <?php
332
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name);
332
+    $airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name);
333 333
     if (count($airport_airport_array) > 0) {
334 334
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
335 335
 	print '<div id="chart3" class="chart" width="100%"></div>
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
                 var data = google.visualization.arrayToDataTable([ 
345 345
                     ["'._("Airport").'", "'._("# of times").'"],';
346 346
                     $airport_data = '';
347
-	foreach($airport_airport_array as $airport_item)
347
+	foreach ($airport_airport_array as $airport_item)
348 348
 	{
349 349
 	    $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
350 350
 	    $name = str_replace("'", "", $name);
@@ -371,11 +371,11 @@  discard block
 block discarded – undo
371 371
     }
372 372
 ?>
373 373
             </div>
374
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
374
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
375 375
 
376 376
             <div class="col-md-6">
377 377
 <?php
378
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name);
378
+    $airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name);
379 379
     if (count($airport_airport_array2) > 0) {
380 380
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
381 381
 	print '<div id="chart4" class="chart" width="100%"></div>
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
                 var data = google.visualization.arrayToDataTable([ 
391 391
                     ["'._("Airport").'", "'._("# of times").'"],';
392 392
 	$airport_data2 = '';
393
-	foreach($airport_airport_array2 as $airport_item2)
393
+	foreach ($airport_airport_array2 as $airport_item2)
394 394
 	{
395 395
 	    $name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
396
-	    $name2 = str_replace(array("'",'"'), '', $name2);
396
+	    $name2 = str_replace(array("'", '"'), '', $name2);
397 397
 	    $airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
398 398
 	}
399 399
 	$airport_data2 = substr($airport_data2, 0, -1);
@@ -417,13 +417,13 @@  discard block
 block discarded – undo
417 417
 ?>
418 418
             </div>
419 419
         </div>
420
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
420
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
421 421
 
422 422
         <div class="row column">
423 423
             <div class="col-md-6">
424 424
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
425 425
                 <?php
426
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
426
+                  $year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
427 427
 		    if (count($year_array) == 0) print _("No data available");
428 428
 		    else {
429 429
                   print '<div id="chart8" class="chart" width="100%"></div>
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
                         var data = google.visualization.arrayToDataTable([
435 435
                             ["'._("Month").'", "'._("# of Flights").'"], ';
436 436
                             $year_data = '';
437
-                          foreach($year_array as $year_item)
437
+                          foreach ($year_array as $year_item)
438 438
                                     {
439
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
439
+                                        $year_data .= '[ "'.date('F, Y', strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
440 440
                                     }
441 441
                                     $year_data = substr($year_data, 0, -1);
442 442
                                     print $year_data;
@@ -464,12 +464,12 @@  discard block
 block discarded – undo
464 464
                     <a href="<?php print $globalURL; ?>/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
465 465
                 </div>
466 466
             </div>
467
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
467
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
468 468
 
469 469
             <div class="col-md-6">
470 470
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
471 471
                 <?php
472
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
472
+                  $month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
473 473
 		    if (count($month_array) == 0) print _("No data available");
474 474
 		    else {
475 475
                   print '<div id="chart9" class="chart" width="100%"></div>
@@ -480,9 +480,9 @@  discard block
 block discarded – undo
480 480
                         var data = google.visualization.arrayToDataTable([
481 481
                             ["'._("Day").'", "'._("# of Flights").'"], ';
482 482
                             $month_data = '';
483
-                          foreach($month_array as $month_item)
483
+                          foreach ($month_array as $month_item)
484 484
                                     {
485
-                                        $month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
485
+                                        $month_data .= '[ "'.date('F j, Y', strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
486 486
                                     }
487 487
                                     $month_data = substr($month_data, 0, -1);
488 488
                                     print $month_data;
@@ -510,12 +510,12 @@  discard block
 block discarded – undo
510 510
                     <a href="<?php print $globalURL; ?>/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
511 511
                 </div>
512 512
             </div>
513
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
513
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
514 514
 
515 515
             <div class="col-md-6">
516 516
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
517 517
                 <?php
518
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
518
+                    $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
519 519
 		    if (empty($date_array)) print _("No data available");
520 520
 		    else {
521 521
                   print '<div id="chart5" class="chart" width="100%"></div>
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
                             ["'._("Date").'", "'._("# of Flights").'"], ';
528 528
                             $date_data = '';
529 529
                         
530
-                          foreach($date_array as $date_item)
530
+                          foreach ($date_array as $date_item)
531 531
                                     {
532 532
                                         $date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
533 533
                                     }
@@ -557,12 +557,12 @@  discard block
 block discarded – undo
557 557
                     <a href="<?php print $globalURL; ?>/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
558 558
                 </div>
559 559
             </div>
560
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
560
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
561 561
 
562 562
             <div class="col-md-6">
563 563
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
564 564
                 <?php
565
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
565
+                  $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
566 566
 		    if (empty($hour_array)) print _("No data available");
567 567
 		    else {
568 568
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
                         var data = google.visualization.arrayToDataTable([
575 575
                             ["'._("Hour").'", "'._("# of Flights").'"], ';
576 576
                             $hour_data = '';
577
-                          foreach($hour_array as $hour_item)
577
+                          foreach ($hour_array as $hour_item)
578 578
                                     {
579 579
                                         $hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
580 580
                                     }
@@ -604,21 +604,21 @@  discard block
 block discarded – undo
604 604
                     <a href="<?php print $globalURL; ?>/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
605 605
                 </div>
606 606
             </div>
607
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
607
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
608 608
         </div>
609 609
 <?php
610 610
     if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '') {
611 611
 ?>
612 612
         <div class="row column">
613 613
         	<?php
614
-        	    $polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
614
+        	    $polar = $Stats->getStatsSource(date('Y-m-d'), 'polar');
615 615
         	    if (!empty($polar)) {
616 616
             		print '<h2>'._("Coverage pattern").'</h2>';
617 617
         		foreach ($polar as $eachpolar) {
618 618
         		    unset($polar_data);
619 619
 	        	    $Spotter = new Spotter();
620 620
         		    $data = json_decode($eachpolar['source_data']);
621
-        		    foreach($data as $value => $key) {
621
+        		    foreach ($data as $value => $key) {
622 622
         			$direction = $Spotter->parseDirection(($value*22.5));
623 623
         			$distance = $key;
624 624
         			$unit = 'km';
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
         	?>
639 639
             <div class="col-md-6">
640 640
                 <h4><?php print $eachpolar['source_name']; ?></h4>
641
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
641
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
642 642
         	<script>
643 643
         	    (function() {
644 644
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 		      color: color,
663 663
 		      unit: '<?php echo $unit; ?>'
664 664
 		    };
665
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
665
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
666 666
 		    })();
667 667
 		</script>
668 668
             </div>
@@ -674,19 +674,19 @@  discard block
 block discarded – undo
674 674
         <div class="row column">
675 675
             <div class="col-md-6">
676 676
         	<?php
677
-        	    $msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
677
+        	    $msg = $Stats->getStatsSource(date('Y-m-d'), 'msg');
678 678
         	    if (!empty($msg)) {
679 679
             		print '<h2>'._("Messages received").'</h2>';
680 680
         		foreach ($msg as $eachmsg) {
681 681
         		    //$eachmsg = $msg[0];
682 682
         		    $data = $eachmsg['source_data'];
683
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
683
+        		    if ($data > 500) $max = (round(($data + 100)/100))*100;
684 684
         		    else $max = 500;
685 685
         	?>
686
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
686
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
687 687
         	<script>
688 688
 		      var g = new JustGage({
689
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
689
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
690 690
 			    value: <?php echo $data; ?>,
691 691
 			    min: 0,
692 692
 			    max: <?php print $max; ?>,
@@ -706,12 +706,12 @@  discard block
 block discarded – undo
706 706
         <div class="row column">
707 707
 
708 708
             <?php
709
-		$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
709
+		$hist = $Stats->getStatsSource(date('Y-m-d'), 'hist');
710 710
 		foreach ($hist as $hists) {
711 711
 			$hist_data = '';
712 712
 			$source = $hists['source_name'];
713 713
 			$hist_array = json_decode($hists['source_data']);
714
-			foreach($hist_array as $distance => $nb)
714
+			foreach ($hist_array as $distance => $nb)
715 715
 			{
716 716
 				$unit = 'km';
717 717
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -729,13 +729,13 @@  discard block
 block discarded – undo
729 729
 			$hist_data = substr($hist_data, 0, -1);
730 730
             ?>
731 731
             <div class="col-md-6">
732
-                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
732
+                <h2><?php echo sprintf(_("Flights Distance for %s"), $source); ?></h2>
733 733
                 <?php
734
-                  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
734
+                  print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div>
735 735
                     <script> 
736 736
                         google.load("visualization", "1", {packages:["corechart"]});
737
-                      google.setOnLoadCallback(drawCharthist_'.str_replace(' ','_',strtolower($source)).');
738
-                      function drawCharthist_'.str_replace(' ','_',strtolower($source)).'() {
737
+                      google.setOnLoadCallback(drawCharthist_'.str_replace(' ', '_', strtolower($source)).');
738
+                      function drawCharthist_'.str_replace(' ', '_', strtolower($source)).'() {
739 739
                         var data = google.visualization.arrayToDataTable([
740 740
                             ["'._("Distance").'", "'._("# of Flights").'"], ';
741 741
                             print $hist_data;
@@ -750,16 +750,16 @@  discard block
 block discarded – undo
750 750
                             colors: ["#1a3151"]
751 751
                         };
752 752
 
753
-                        var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ','_',strtolower($source)).'"));
753
+                        var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ', '_', strtolower($source)).'"));
754 754
                         chart.draw(data, options);
755 755
                       }
756 756
                       $(window).resize(function(){
757
-                              drawCharthist_'.str_replace(' ','_',strtolower($source)).'();
757
+                              drawCharthist_'.str_replace(' ', '_', strtolower($source)).'();
758 758
                             });
759 759
                   </script>';
760 760
         	?>
761 761
     	    </div>
762
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
762
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
763 763
         	<?php
764 764
                   }
765 765
                 ?>
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Spacing   +254 added lines, -254 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
 		fclose($fp);
25 25
 	}
26 26
 
27
-	public static function gunzip($in_file,$out_file_name = '') {
27
+	public static function gunzip($in_file, $out_file_name = '') {
28 28
 		//echo $in_file.' -> '.$out_file_name."\n";
29 29
 		$buffer_size = 4096; // read 4kb at a time
30 30
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
31 31
 		if ($in_file != '' && file_exists($in_file)) {
32 32
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
33
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
34
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
35 35
 			else {
36 36
 				echo 'gzopen not available';
37 37
 				die;
38 38
 			}
39 39
 			$out_file = fopen($out_file_name, 'wb'); 
40
-			while(!gzeof($file)) {
40
+			while (!gzeof($file)) {
41 41
 				fwrite($out_file, gzread($file, $buffer_size));
42 42
 			}  
43 43
 			fclose($out_file);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		try {
62 62
 			self::$db_sqlite = new PDO('sqlite:'.$database);
63 63
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
64
-		} catch(PDOException $e) {
64
+		} catch (PDOException $e) {
65 65
 			return "error : ".$e->getMessage();
66 66
 		}
67 67
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78 78
                         $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
79
+                } catch (PDOException $e) {
80 80
                         return "error : ".$e->getMessage();
81 81
                 }
82 82
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		try {
88 88
                         $sth = update_db::$db_sqlite->prepare($query);
89 89
                         $sth->execute();
90
-                } catch(PDOException $e) {
90
+                } catch (PDOException $e) {
91 91
                         return "error : ".$e->getMessage();
92 92
                 }
93 93
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99 99
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
102 102
 				$sth_dest->execute($query_dest_values);
103 103
             		}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120 120
                         $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
121
+                } catch (PDOException $e) {
122 122
                         return "error : ".$e->getMessage();
123 123
                 }
124 124
 
125 125
     		if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128
-		if ($fh = fopen($database_file,"r")) {
128
+		if ($fh = fopen($database_file, "r")) {
129 129
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 130
 			$Connection = new Connection();
131 131
 			$sth_dest = $Connection->db->prepare($query_dest);
132 132
 			if ($globalTransaction) $Connection->db->beginTransaction();
133 133
 			while (!feof($fh)) {
134
-				$line = fgetcsv($fh,9999,',');
134
+				$line = fgetcsv($fh, 9999, ',');
135 135
 				if ($line[0] != '') {
136 136
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
137 137
 						try {
138
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
138
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
139 139
 							$sth_dest->execute($query_dest_values);
140
-						} catch(PDOException $e) {
140
+						} catch (PDOException $e) {
141 141
 							if ($globalTransaction) $Connection->db->rollBack(); 
142 142
 							return "error : ".$e->getMessage();
143 143
 						}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161 161
                         $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
162
+                } catch (PDOException $e) {
163 163
                         return "error : ".$e->getMessage();
164 164
                 }
165 165
 
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
170
-		if ($fh = fopen($database_file,"r")) {
170
+		if ($fh = fopen($database_file, "r")) {
171 171
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
172 172
 			$Connection = new Connection();
173 173
 			$sth_dest = $Connection->db->prepare($query_dest);
174 174
 			try {
175 175
 				if ($globalTransaction) $Connection->db->beginTransaction();
176 176
 				while (!feof($fh)) {
177
-					$line = fgetcsv($fh,9999,',');
177
+					$line = fgetcsv($fh, 9999, ',');
178 178
 					if ($line[0] != '') {
179
-						$datebe = explode('  -  ',$line[2]);
179
+						$datebe = explode('  -  ', $line[2]);
180 180
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
181
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
181
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
182 182
 							$sth_dest->execute($query_dest_values);
183 183
 						}
184 184
 					}
185 185
 				}
186 186
 				if ($globalTransaction) $Connection->db->commit();
187
-			} catch(PDOException $e) {
187
+			} catch (PDOException $e) {
188 188
 				if ($globalTransaction) $Connection->db->rollBack(); 
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201 201
                         $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
202
+                } catch (PDOException $e) {
203 203
                         return "error : ".$e->getMessage();
204 204
                 }
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209 209
                         $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
210
+                } catch (PDOException $e) {
211 211
                         return "error : ".$e->getMessage();
212 212
                 }
213 213
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		try {
217 217
                         $sth = update_db::$db_sqlite->prepare($query);
218 218
                         $sth->execute();
219
-                } catch(PDOException $e) {
219
+                } catch (PDOException $e) {
220 220
                         return "error : ".$e->getMessage();
221 221
                 }
222 222
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
236
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
239
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
240 240
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242 242
             		}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244
-		} catch(PDOException $e) {
244
+		} catch (PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
246 246
 		}
247 247
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			$Connection = new Connection();
251 251
 			$sth = $Connection->db->prepare($query);
252 252
                         $sth->execute(array(':source' => $database_file));
253
-                } catch(PDOException $e) {
253
+                } catch (PDOException $e) {
254 254
                         return "error : ".$e->getMessage();
255 255
                 }
256 256
 		return '';
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
 			$Connection = new Connection();
266 266
 			$sth = $Connection->db->prepare($query);
267 267
                         $sth->execute(array(':source' => $database_file));
268
-                } catch(PDOException $e) {
268
+                } catch (PDOException $e) {
269 269
                         return "error : ".$e->getMessage();
270 270
                 }
271 271
 		
272
-		if ($fh = fopen($database_file,"r")) {
272
+		if ($fh = fopen($database_file, "r")) {
273 273
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
274 274
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
275 275
 		
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
 				if ($globalTransaction) $Connection->db->beginTransaction();
280 280
             			while (!feof($fh)) {
281 281
             				$values = array();
282
-            				$line = $Common->hex2str(fgets($fh,9999));
282
+            				$line = $Common->hex2str(fgets($fh, 9999));
283 283
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
284
-            				$values['ModeS'] = substr($line,0,6);
285
-            				$values['Registration'] = trim(substr($line,69,6));
286
-            				$aircraft_name = trim(substr($line,48,6));
284
+            				$values['ModeS'] = substr($line, 0, 6);
285
+            				$values['Registration'] = trim(substr($line, 69, 6));
286
+            				$aircraft_name = trim(substr($line, 48, 6));
287 287
             				// Check if we can find ICAO, else set it to GLID
288
-            				$aircraft_name_split = explode(' ',$aircraft_name);
288
+            				$aircraft_name_split = explode(' ', $aircraft_name);
289 289
             				$search_more = '';
290 290
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
291 291
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -297,20 +297,20 @@  discard block
 block discarded – undo
297 297
 	            				if (isset($result['icao']) && $result['icao'] != '') {
298 298
 	            				    $values['ICAOTypeCode'] = $result['icao'];
299 299
 	            				} 
300
-					} catch(PDOException $e) {
300
+					} catch (PDOException $e) {
301 301
 						return "error : ".$e->getMessage();
302 302
 					}
303 303
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
304 304
 					// Add data to db
305 305
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') {
306 306
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
307
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
307
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
308 308
 						//print_r($query_dest_values);
309 309
 						$sth_dest->execute($query_dest_values);
310 310
 					}
311 311
 				}
312 312
 				if ($globalTransaction) $Connection->db->commit();
313
-			} catch(PDOException $e) {
313
+			} catch (PDOException $e) {
314 314
 				return "error : ".$e->getMessage();
315 315
 			}
316 316
 		}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 			$Connection = new Connection();
321 321
 			$sth = $Connection->db->prepare($query);
322 322
                         $sth->execute(array(':source' => $database_file));
323
-                } catch(PDOException $e) {
323
+                } catch (PDOException $e) {
324 324
                         return "error : ".$e->getMessage();
325 325
                 }
326 326
 		return '';
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
 			$Connection = new Connection();
335 335
 			$sth = $Connection->db->prepare($query);
336 336
                         $sth->execute(array(':source' => $database_file));
337
-                } catch(PDOException $e) {
337
+                } catch (PDOException $e) {
338 338
                         return "error : ".$e->getMessage();
339 339
                 }
340 340
 		
341
-		if ($fh = fopen($database_file,"r")) {
341
+		if ($fh = fopen($database_file, "r")) {
342 342
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
343 343
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
344 344
 		
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
 			$sth_dest = $Connection->db->prepare($query_dest);
347 347
 			try {
348 348
 				if ($globalTransaction) $Connection->db->beginTransaction();
349
-				$tmp = fgetcsv($fh,9999,',',"'");
349
+				$tmp = fgetcsv($fh, 9999, ',', "'");
350 350
             			while (!feof($fh)) {
351
-            				$line = fgetcsv($fh,9999,',',"'");
351
+            				$line = fgetcsv($fh, 9999, ',', "'");
352 352
             				
353 353
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
354 354
 					//print_r($line);
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
             				$values['Registration'] = $line[3];
357 357
             				$aircraft_name = $line[2];
358 358
             				// Check if we can find ICAO, else set it to GLID
359
-            				$aircraft_name_split = explode(' ',$aircraft_name);
359
+            				$aircraft_name_split = explode(' ', $aircraft_name);
360 360
             				$search_more = '';
361 361
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
362 362
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -365,20 +365,20 @@  discard block
 block discarded – undo
365 365
                                     		$sth_search->execute();
366 366
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
367 367
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
368
-					} catch(PDOException $e) {
368
+					} catch (PDOException $e) {
369 369
 						return "error : ".$e->getMessage();
370 370
 					}
371 371
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
372 372
 					// Add data to db
373 373
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
374 374
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
375
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
375
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
376 376
 						//print_r($query_dest_values);
377 377
 						$sth_dest->execute($query_dest_values);
378 378
 					}
379 379
 				}
380 380
 				if ($globalTransaction) $Connection->db->commit();
381
-			} catch(PDOException $e) {
381
+			} catch (PDOException $e) {
382 382
 				return "error : ".$e->getMessage();
383 383
 			}
384 384
 		}
@@ -388,13 +388,13 @@  discard block
 block discarded – undo
388 388
 			$Connection = new Connection();
389 389
 			$sth = $Connection->db->prepare($query);
390 390
                         $sth->execute(array(':source' => $database_file));
391
-                } catch(PDOException $e) {
391
+                } catch (PDOException $e) {
392 392
                         return "error : ".$e->getMessage();
393 393
                 }
394 394
 		return '';
395 395
 	}
396 396
 
397
-	public static function retrieve_owner($database_file,$country = 'F') {
397
+	public static function retrieve_owner($database_file, $country = 'F') {
398 398
 		global $globalTransaction;
399 399
 		//$query = 'TRUNCATE TABLE aircraft_modes';
400 400
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 			$Connection = new Connection();
403 403
 			$sth = $Connection->db->prepare($query);
404 404
                         $sth->execute(array(':source' => $database_file));
405
-                } catch(PDOException $e) {
405
+                } catch (PDOException $e) {
406 406
                         return "error : ".$e->getMessage();
407 407
                 }
408 408
 		
409
-		if ($fh = fopen($database_file,"r")) {
409
+		if ($fh = fopen($database_file, "r")) {
410 410
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
411 411
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
412 412
 		
@@ -414,9 +414,9 @@  discard block
 block discarded – undo
414 414
 			$sth_dest = $Connection->db->prepare($query_dest);
415 415
 			try {
416 416
 				if ($globalTransaction) $Connection->db->beginTransaction();
417
-				$tmp = fgetcsv($fh,9999,',','"');
417
+				$tmp = fgetcsv($fh, 9999, ',', '"');
418 418
             			while (!feof($fh)) {
419
-            				$line = fgetcsv($fh,9999,',','"');
419
+            				$line = fgetcsv($fh, 9999, ',', '"');
420 420
             				$values = array();
421 421
             				//print_r($line);
422 422
             				if ($country == 'F') {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
             				    $values['base'] = $line[4];
425 425
             				    $values['owner'] = $line[5];
426 426
             				    if ($line[6] == '') $values['date_first_reg'] = null;
427
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
427
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
428 428
 					    $values['cancel'] = $line[7];
429 429
 					} elseif ($country == 'EI') {
430 430
 					    // TODO : add modeS & reg to aircraft_modes
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
             				    $values['base'] = $line[3];
433 433
             				    $values['owner'] = $line[2];
434 434
             				    if ($line[1] == '') $values['date_first_reg'] = null;
435
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
435
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
436 436
 					    $values['cancel'] = '';
437 437
 					} elseif ($country == 'HB') {
438 438
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             				    $values['base'] = null;
448 448
             				    $values['owner'] = $line[5];
449 449
             				    if ($line[18] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
450
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
451 451
 					    $values['cancel'] = '';
452 452
 					} elseif ($country == 'VH') {
453 453
 					    // TODO : add modeS & reg to aircraft_modes
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
             				    $values['base'] = null;
456 456
             				    $values['owner'] = $line[12];
457 457
             				    if ($line[28] == '') $values['date_first_reg'] = null;
458
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
458
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
459 459
 
460 460
 					    $values['cancel'] = $line[39];
461 461
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -475,28 +475,28 @@  discard block
 block discarded – undo
475 475
             				    $values['base'] = null;
476 476
             				    $values['owner'] = $line[8];
477 477
             				    if ($line[7] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
478
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
479 479
 					    $values['cancel'] = '';
480 480
 					} elseif ($country == 'PP') {
481 481
             				    $values['registration'] = $line[0];
482 482
             				    $values['base'] = null;
483 483
             				    $values['owner'] = $line[4];
484 484
             				    if ($line[6] == '') $values['date_first_reg'] = null;
485
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
485
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
486 486
 					    $values['cancel'] = $line[7];
487 487
 					} elseif ($country == 'E7') {
488 488
             				    $values['registration'] = $line[0];
489 489
             				    $values['base'] = null;
490 490
             				    $values['owner'] = $line[4];
491 491
             				    if ($line[5] == '') $values['date_first_reg'] = null;
492
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
492
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
493 493
 					    $values['cancel'] = '';
494 494
 					} elseif ($country == '8Q') {
495 495
             				    $values['registration'] = $line[0];
496 496
             				    $values['base'] = null;
497 497
             				    $values['owner'] = $line[3];
498 498
             				    if ($line[7] == '') $values['date_first_reg'] = null;
499
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
499
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
500 500
 					    $values['cancel'] = '';
501 501
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
502 502
             				    $values['registration'] = $line[0];
@@ -506,12 +506,12 @@  discard block
 block discarded – undo
506 506
 					    $values['cancel'] = '';
507 507
 					}
508 508
 					if ($values['cancel'] == '' && $values['registration'] != null) {
509
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
509
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
510 510
 						$sth_dest->execute($query_dest_values);
511 511
 					}
512 512
 				}
513 513
 				if ($globalTransaction) $Connection->db->commit();
514
-			} catch(PDOException $e) {
514
+			} catch (PDOException $e) {
515 515
 				return "error : ".$e->getMessage();
516 516
 			}
517 517
 		}
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 			$Connection = new Connection();
627 627
 			$sth = $Connection->db->prepare($query);
628 628
                         $sth->execute();
629
-                } catch(PDOException $e) {
629
+                } catch (PDOException $e) {
630 630
                         return "error : ".$e->getMessage();
631 631
                 }
632 632
 
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 			$Connection = new Connection();
637 637
 			$sth = $Connection->db->prepare($query);
638 638
                         $sth->execute();
639
-                } catch(PDOException $e) {
639
+                } catch (PDOException $e) {
640 640
                         return "error : ".$e->getMessage();
641 641
                 }
642 642
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 		if ($globalTransaction) $Connection->db->beginTransaction();
648 648
   
649 649
 		$i = 0;
650
-		while($row = sparql_fetch_array($result))
650
+		while ($row = sparql_fetch_array($result))
651 651
 		{
652 652
 			if ($i >= 1) {
653 653
 			//print_r($row);
@@ -667,31 +667,31 @@  discard block
 block discarded – undo
667 667
 				$row['image'] = '';
668 668
 				$row['image_thumb'] = '';
669 669
 			} else {
670
-				$image = str_replace(' ','_',$row['image']);
670
+				$image = str_replace(' ', '_', $row['image']);
671 671
 				$digest = md5($image);
672
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
673
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
674
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
675
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
672
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
673
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
674
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
675
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
676 676
 			}
677 677
 			
678
-			$country = explode('-',$row['country']);
678
+			$country = explode('-', $row['country']);
679 679
 			$row['country'] = $country[0];
680 680
 			
681 681
 			$row['type'] = trim($row['type']);
682
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
682
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
683 683
 				$row['type'] = 'Military';
684 684
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
685 685
 				$row['type'] = 'small_airport';
686 686
 			}
687 687
 			
688
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
689
-			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
688
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
689
+			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
690 690
 			//print_r($query_dest_values);
691 691
 			
692 692
 			try {
693 693
 				$sth_dest->execute($query_dest_values);
694
-			} catch(PDOException $e) {
694
+			} catch (PDOException $e) {
695 695
 				return "error : ".$e->getMessage();
696 696
 			}
697 697
 			}
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			$Connection = new Connection();
706 706
 			$sth = $Connection->db->prepare($query);
707 707
                         $sth->execute();
708
-                } catch(PDOException $e) {
708
+                } catch (PDOException $e) {
709 709
                         return "error : ".$e->getMessage();
710 710
                 }
711 711
 
@@ -713,12 +713,12 @@  discard block
 block discarded – undo
713 713
 		if ($globalDebug) echo "Insert Not available Airport...\n";
714 714
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
715 715
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
716
-		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
716
+		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => '');
717 717
 		try {
718 718
 			$Connection = new Connection();
719 719
 			$sth = $Connection->db->prepare($query);
720 720
                         $sth->execute($query_values);
721
-                } catch(PDOException $e) {
721
+                } catch (PDOException $e) {
722 722
                         return "error : ".$e->getMessage();
723 723
                 }
724 724
 		$i++;
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 		echo "Download data from ourairports.com...\n";
737 737
 		$delimiter = ',';
738 738
 		$out_file = $tmp_dir.'airports.csv';
739
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
739
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
740 740
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
741 741
 		echo "Add data from ourairports.com...\n";
742 742
 
@@ -747,32 +747,32 @@  discard block
 block discarded – undo
747 747
 			//$Connection->db->beginTransaction();
748 748
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
749 749
 			{
750
-				if(!$header) $header = $row;
750
+				if (!$header) $header = $row;
751 751
 				else {
752 752
 					$data = array();
753 753
 					$data = array_combine($header, $row);
754 754
 					try {
755 755
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
756 756
 						$sth->execute(array(':icao' => $data['gps_code']));
757
-					} catch(PDOException $e) {
757
+					} catch (PDOException $e) {
758 758
 						return "error : ".$e->getMessage();
759 759
 					}
760 760
 					if ($sth->fetchColumn() > 0) {
761 761
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
762 762
 						try {
763 763
 							$sth = $Connection->db->prepare($query);
764
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
765
-						} catch(PDOException $e) {
764
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
765
+						} catch (PDOException $e) {
766 766
 							return "error : ".$e->getMessage();
767 767
 						}
768 768
 					} else {
769 769
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
770 770
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
771
-						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
771
+						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
772 772
 						try {
773 773
 							$sth = $Connection->db->prepare($query);
774 774
 							$sth->execute($query_values);
775
-						} catch(PDOException $e) {
775
+						} catch (PDOException $e) {
776 776
 							return "error : ".$e->getMessage();
777 777
 						}
778 778
 						$i++;
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 
786 786
 		echo "Download data from another free database...\n";
787 787
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
788
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
788
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
789 789
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
790 790
 		update_db::unzip($out_file);
791 791
 		$header = NULL;
@@ -797,15 +797,15 @@  discard block
 block discarded – undo
797 797
 			//$Connection->db->beginTransaction();
798 798
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
799 799
 			{
800
-				if(!$header) $header = $row;
800
+				if (!$header) $header = $row;
801 801
 				else {
802 802
 					$data = $row;
803 803
 
804 804
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
805 805
 					try {
806 806
 						$sth = $Connection->db->prepare($query);
807
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
808
-					} catch(PDOException $e) {
807
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
808
+					} catch (PDOException $e) {
809 809
 						return "error : ".$e->getMessage();
810 810
 					}
811 811
 				}
@@ -819,15 +819,15 @@  discard block
 block discarded – undo
819 819
 		try {
820 820
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
821 821
 			$sth->execute();
822
-		} catch(PDOException $e) {
822
+		} catch (PDOException $e) {
823 823
 			return "error : ".$e->getMessage();
824 824
 		}
825 825
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
826 826
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
827 827
 			try {
828 828
 				$sth2 = $Connection->db->prepare($query2);
829
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
830
-			} catch(PDOException $e) {
829
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
830
+			} catch (PDOException $e) {
831 831
 				return "error : ".$e->getMessage();
832 832
 			}
833 833
 		}
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 			$Connection = new Connection();
852 852
 			$sth = $Connection->db->prepare($query);
853 853
                         $sth->execute(array(':source' => 'translation.csv'));
854
-                } catch(PDOException $e) {
854
+                } catch (PDOException $e) {
855 855
                         return "error : ".$e->getMessage();
856 856
                 }
857 857
 
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
869 869
 			{
870 870
 				$i++;
871
-				if($i > 12) {
871
+				if ($i > 12) {
872 872
 					$data = $row;
873 873
 					$operator = $data[2];
874 874
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
                                                 //echo substr($operator, 0, 2)."\n";;
877 877
                                                 if (count($airline_array) > 0) {
878 878
 							//print_r($airline_array);
879
-							$operator = $airline_array[0]['icao'].substr($operator,2);
879
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
880 880
                                                 }
881 881
                                         }
882 882
 					
@@ -884,14 +884,14 @@  discard block
 block discarded – undo
884 884
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
885 885
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
886 886
                                                 if (count($airline_array) > 0) {
887
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
887
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
888 888
                                             	}
889 889
                                         }
890 890
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
891 891
 					try {
892 892
 						$sth = $Connection->db->prepare($query);
893
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
894
-					} catch(PDOException $e) {
893
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
894
+					} catch (PDOException $e) {
895 895
 						return "error : ".$e->getMessage();
896 896
 					}
897 897
 				}
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 			$Connection = new Connection();
912 912
 			$sth = $Connection->db->prepare($query);
913 913
                         $sth->execute(array(':source' => 'website_fam'));
914
-                } catch(PDOException $e) {
914
+                } catch (PDOException $e) {
915 915
                         return "error : ".$e->getMessage();
916 916
                 }
917 917
 
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
932 932
 					try {
933 933
 						$sth = $Connection->db->prepare($query);
934
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
935
-					} catch(PDOException $e) {
934
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
935
+					} catch (PDOException $e) {
936 936
 						return "error : ".$e->getMessage();
937 937
 					}
938 938
 				}
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 			$Connection = new Connection();
952 952
 			$sth = $Connection->db->prepare($query);
953 953
                         $sth->execute(array(':source' => 'website_fam'));
954
-                } catch(PDOException $e) {
954
+                } catch (PDOException $e) {
955 955
                         return "error : ".$e->getMessage();
956 956
                 }
957 957
 
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
972 972
 					try {
973 973
 						$sth = $Connection->db->prepare($query);
974
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
975
-					} catch(PDOException $e) {
974
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
975
+					} catch (PDOException $e) {
976 976
 						return "error : ".$e->getMessage();
977 977
 					}
978 978
 				}
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 			$Connection = new Connection();
992 992
 			$sth = $Connection->db->prepare($query);
993 993
                         $sth->execute(array(':source' => 'website_fam'));
994
-                } catch(PDOException $e) {
994
+                } catch (PDOException $e) {
995 995
                         return "error : ".$e->getMessage();
996 996
                 }
997 997
 
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1012 1012
 					try {
1013 1013
 						$sth = $Connection->db->prepare($query);
1014
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1015
-					} catch(PDOException $e) {
1014
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1015
+					} catch (PDOException $e) {
1016 1016
 						return "error : ".$e->getMessage();
1017 1017
 					}
1018 1018
 				}
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 		return '';
1025 1025
         }
1026 1026
 
1027
-	public static function tle($filename,$tletype) {
1027
+	public static function tle($filename, $tletype) {
1028 1028
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1029 1029
 		global $tmp_dir, $globalTransaction;
1030 1030
 		//$Spotter = new Spotter();
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 			$Connection = new Connection();
1035 1035
 			$sth = $Connection->db->prepare($query);
1036 1036
                         $sth->execute(array(':source' => $filename));
1037
-                } catch(PDOException $e) {
1037
+                } catch (PDOException $e) {
1038 1038
                         return "error : ".$e->getMessage();
1039 1039
                 }
1040 1040
 		
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1060 1060
 					try {
1061 1061
 						$sth = $Connection->db->prepare($query);
1062
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1063
-					} catch(PDOException $e) {
1062
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1063
+					} catch (PDOException $e) {
1064 1064
 						return "error : ".$e->getMessage();
1065 1065
 					}
1066 1066
 
@@ -1080,28 +1080,28 @@  discard block
 block discarded – undo
1080 1080
         */
1081 1081
         private static function table2array($data) {
1082 1082
                 $html = str_get_html($data);
1083
-                $tabledata=array();
1084
-                foreach($html->find('tr') as $element)
1083
+                $tabledata = array();
1084
+                foreach ($html->find('tr') as $element)
1085 1085
                 {
1086 1086
                         $td = array();
1087
-                        foreach( $element->find('th') as $row)
1087
+                        foreach ($element->find('th') as $row)
1088 1088
                         {
1089 1089
                                 $td [] = trim($row->plaintext);
1090 1090
                         }
1091
-                        $td=array_filter($td);
1091
+                        $td = array_filter($td);
1092 1092
                         $tabledata[] = $td;
1093 1093
 
1094 1094
                         $td = array();
1095 1095
                         $tdi = array();
1096
-                        foreach( $element->find('td') as $row)
1096
+                        foreach ($element->find('td') as $row)
1097 1097
                         {
1098 1098
                                 $td [] = trim($row->plaintext);
1099 1099
                                 $tdi [] = trim($row->innertext);
1100 1100
                         }
1101
-                        $td=array_filter($td);
1102
-                        $tdi=array_filter($tdi);
1101
+                        $td = array_filter($td);
1102
+                        $tdi = array_filter($tdi);
1103 1103
                     //    $tabledata[]=array_merge($td,$tdi);
1104
-                        $tabledata[]=$td;
1104
+                        $tabledata[] = $td;
1105 1105
                 }
1106 1106
                 return(array_filter($tabledata));
1107 1107
         }
@@ -1174,13 +1174,13 @@  discard block
 block discarded – undo
1174 1174
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1175 1175
 			{
1176 1176
 				$i++;
1177
-				if($i > 3 && count($row) > 2) {
1177
+				if ($i > 3 && count($row) > 2) {
1178 1178
 					$data = array_values(array_filter($row));
1179 1179
 					$cntdata = count($data);
1180 1180
 					if ($cntdata > 10) {
1181 1181
 						$value = $data[9];
1182 1182
 						
1183
-						for ($i =10;$i < $cntdata;$i++) {
1183
+						for ($i = 10; $i < $cntdata; $i++) {
1184 1184
 							$value .= ' '.$data[$i];
1185 1185
 						}
1186 1186
 						$data[9] = $value;
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1191 1191
 						try {
1192 1192
 							$sth = $Connection->db->prepare($query);
1193
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1194
-						} catch(PDOException $e) {
1193
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1194
+						} catch (PDOException $e) {
1195 1195
 							return "error : ".$e->getMessage();
1196 1196
 						}
1197 1197
 					}
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
 			$Connection = new Connection();
1213 1213
 			$sth = $Connection->db->prepare($query);
1214 1214
                         $sth->execute();
1215
-                } catch(PDOException $e) {
1215
+                } catch (PDOException $e) {
1216 1216
                         return "error : ".$e->getMessage();
1217 1217
                 }
1218 1218
 
@@ -1224,12 +1224,12 @@  discard block
 block discarded – undo
1224 1224
 			if ($globalTransaction) $Connection->db->beginTransaction();
1225 1225
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1226 1226
 			{
1227
-				if(count($row) > 1) {
1227
+				if (count($row) > 1) {
1228 1228
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1229 1229
 					try {
1230 1230
 						$sth = $Connection->db->prepare($query);
1231
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1232
-					} catch(PDOException $e) {
1231
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1232
+					} catch (PDOException $e) {
1233 1233
 						return "error : ".$e->getMessage();
1234 1234
 					}
1235 1235
 				}
@@ -1249,21 +1249,21 @@  discard block
 block discarded – undo
1249 1249
 			try {
1250 1250
 				$sth = $Connection->db->prepare($query);
1251 1251
                     		$sth->execute();
1252
-	                } catch(PDOException $e) {
1252
+	                } catch (PDOException $e) {
1253 1253
 				return "error : ".$e->getMessage();
1254 1254
 	                }
1255 1255
 	        }
1256 1256
 
1257 1257
 
1258
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1258
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1259 1259
 		else {
1260
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1260
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1261 1261
 			$query = "CREATE EXTENSION postgis";
1262
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1262
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1263 1263
 			try {
1264 1264
 				$sth = $Connection->db->prepare($query);
1265 1265
 				$sth->execute();
1266
-			} catch(PDOException $e) {
1266
+			} catch (PDOException $e) {
1267 1267
 				return "error : ".$e->getMessage();
1268 1268
 			}
1269 1269
 		}
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		include_once('class.create_db.php');
1277 1277
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1278 1278
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1279
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1279
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1280 1280
 		$error = '';
1281 1281
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1282 1282
 			if ($globalDebug) echo "Gunzip...";
@@ -1308,14 +1308,14 @@  discard block
 block discarded – undo
1308 1308
 			try {
1309 1309
 				$sth = $Connection->db->prepare($query);
1310 1310
             	        	$sth->execute();
1311
-	                } catch(PDOException $e) {
1311
+	                } catch (PDOException $e) {
1312 1312
     	                	echo "error : ".$e->getMessage();
1313 1313
 	                }
1314 1314
 		}
1315 1315
 		if ($globalDBdriver == 'mysql') {
1316
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1316
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1317 1317
 		} else {
1318
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1318
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1319 1319
 		}
1320 1320
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1321 1321
 		return $error;
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1329 1329
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1330 1330
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1331
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1331
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
1332 1332
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1333 1333
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1334 1334
 		return $error;
@@ -1348,7 +1348,7 @@  discard block
 block discarded – undo
1348 1348
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1349 1349
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1350 1350
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1351
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1351
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1352 1352
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1353 1353
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1354 1354
 		if ($error != '') {
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
 		global $tmp_dir, $globalDebug;
1362 1362
 		$error = '';
1363 1363
 		if ($globalDebug) echo "Routes : Download...";
1364
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1364
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1365 1365
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1366 1366
 			if ($globalDebug) echo "Gunzip...";
1367 1367
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 		global $tmp_dir, $globalDebug;
1378 1378
 		$error = '';
1379 1379
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1380
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1380
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1381 1381
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1382 1382
 			if ($globalDebug) echo "Gunzip...";
1383 1383
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
 		global $tmp_dir, $globalDebug;
1394 1394
 		$error = '';
1395 1395
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1396
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1396
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1397 1397
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1398 1398
 			if ($globalDebug) echo "Gunzip...";
1399 1399
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
 */
1422 1422
 		if ($globalDebug) echo "Modes : Download...";
1423 1423
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1424
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1424
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1425 1425
 
1426 1426
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1427 1427
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
 	public static function update_ModeS_flarm() {
1442 1442
 		global $tmp_dir, $globalDebug;
1443 1443
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1444
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1444
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1445 1445
 		if (file_exists($tmp_dir.'data.fln')) {
1446 1446
 			if ($globalDebug) echo "Add to DB...";
1447 1447
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 	public static function update_ModeS_ogn() {
1456 1456
 		global $tmp_dir, $globalDebug;
1457 1457
 		if ($globalDebug) echo "Modes OGN: Download...";
1458
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1458
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1459 1459
 		if (file_exists($tmp_dir.'ogn.csv')) {
1460 1460
 			if ($globalDebug) echo "Add to DB...";
1461 1461
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1470,173 +1470,173 @@  discard block
 block discarded – undo
1470 1470
 		global $tmp_dir, $globalDebug;
1471 1471
 		
1472 1472
 		if ($globalDebug) echo "Owner France: Download...";
1473
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1473
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1474 1474
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1475 1475
 			if ($globalDebug) echo "Add to DB...";
1476
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1476
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1477 1477
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1478 1478
 		if ($error != '') {
1479 1479
 			return $error;
1480 1480
 		} elseif ($globalDebug) echo "Done\n";
1481 1481
 		
1482 1482
 		if ($globalDebug) echo "Owner Ireland: Download...";
1483
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1483
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1484 1484
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1485 1485
 			if ($globalDebug) echo "Add to DB...";
1486
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1486
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1487 1487
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1488 1488
 		if ($error != '') {
1489 1489
 			return $error;
1490 1490
 		} elseif ($globalDebug) echo "Done\n";
1491 1491
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1492
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1492
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1493 1493
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1494 1494
 			if ($globalDebug) echo "Add to DB...";
1495
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1495
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1496 1496
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1497 1497
 		if ($error != '') {
1498 1498
 			return $error;
1499 1499
 		} elseif ($globalDebug) echo "Done\n";
1500 1500
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1501
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1501
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1502 1502
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1503 1503
 			if ($globalDebug) echo "Add to DB...";
1504
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1504
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1505 1505
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1506 1506
 		if ($error != '') {
1507 1507
 			return $error;
1508 1508
 		} elseif ($globalDebug) echo "Done\n";
1509 1509
 		if ($globalDebug) echo "Owner Australia: Download...";
1510
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1510
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1511 1511
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1512 1512
 			if ($globalDebug) echo "Add to DB...";
1513
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1513
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1514 1514
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1515 1515
 		if ($error != '') {
1516 1516
 			return $error;
1517 1517
 		} elseif ($globalDebug) echo "Done\n";
1518 1518
 		if ($globalDebug) echo "Owner Austria: Download...";
1519
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1519
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1520 1520
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1521 1521
 			if ($globalDebug) echo "Add to DB...";
1522
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1522
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1523 1523
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1524 1524
 		if ($error != '') {
1525 1525
 			return $error;
1526 1526
 		} elseif ($globalDebug) echo "Done\n";
1527 1527
 		if ($globalDebug) echo "Owner Chile: Download...";
1528
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1528
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1529 1529
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1530 1530
 			if ($globalDebug) echo "Add to DB...";
1531
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1531
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1532 1532
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1533 1533
 		if ($error != '') {
1534 1534
 			return $error;
1535 1535
 		} elseif ($globalDebug) echo "Done\n";
1536 1536
 		if ($globalDebug) echo "Owner Colombia: Download...";
1537
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1537
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1538 1538
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1539 1539
 			if ($globalDebug) echo "Add to DB...";
1540
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1540
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1541 1541
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1542 1542
 		if ($error != '') {
1543 1543
 			return $error;
1544 1544
 		} elseif ($globalDebug) echo "Done\n";
1545 1545
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1546
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1546
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1547 1547
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1548 1548
 			if ($globalDebug) echo "Add to DB...";
1549
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1549
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1550 1550
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1551 1551
 		if ($error != '') {
1552 1552
 			return $error;
1553 1553
 		} elseif ($globalDebug) echo "Done\n";
1554 1554
 		if ($globalDebug) echo "Owner Brazil: Download...";
1555
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1555
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1556 1556
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1557 1557
 			if ($globalDebug) echo "Add to DB...";
1558
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1558
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1559 1559
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1560 1560
 		if ($error != '') {
1561 1561
 			return $error;
1562 1562
 		} elseif ($globalDebug) echo "Done\n";
1563 1563
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1564
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1564
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1565 1565
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1566 1566
 			if ($globalDebug) echo "Add to DB...";
1567
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1567
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1568 1568
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1569 1569
 		if ($error != '') {
1570 1570
 			return $error;
1571 1571
 		} elseif ($globalDebug) echo "Done\n";
1572 1572
 		if ($globalDebug) echo "Owner Croatia: Download...";
1573
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1573
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1574 1574
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1575 1575
 			if ($globalDebug) echo "Add to DB...";
1576
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1576
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1577 1577
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1578 1578
 		if ($error != '') {
1579 1579
 			return $error;
1580 1580
 		} elseif ($globalDebug) echo "Done\n";
1581 1581
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1582
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1582
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1583 1583
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1584 1584
 			if ($globalDebug) echo "Add to DB...";
1585
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1585
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1586 1586
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1587 1587
 		if ($error != '') {
1588 1588
 			return $error;
1589 1589
 		} elseif ($globalDebug) echo "Done\n";
1590 1590
 		if ($globalDebug) echo "Owner Maldives: Download...";
1591
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1591
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1592 1592
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1593 1593
 			if ($globalDebug) echo "Add to DB...";
1594
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1594
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1595 1595
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1596 1596
 		if ($error != '') {
1597 1597
 			return $error;
1598 1598
 		} elseif ($globalDebug) echo "Done\n";
1599 1599
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1600
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1600
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1601 1601
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1602 1602
 			if ($globalDebug) echo "Add to DB...";
1603
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1603
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1604 1604
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1605 1605
 		if ($error != '') {
1606 1606
 			return $error;
1607 1607
 		} elseif ($globalDebug) echo "Done\n";
1608 1608
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1609
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1609
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1610 1610
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1611 1611
 			if ($globalDebug) echo "Add to DB...";
1612
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1612
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1613 1613
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1614 1614
 		if ($error != '') {
1615 1615
 			return $error;
1616 1616
 		} elseif ($globalDebug) echo "Done\n";
1617 1617
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1618
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1618
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1619 1619
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1620 1620
 			if ($globalDebug) echo "Add to DB...";
1621
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1621
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1622 1622
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1623 1623
 		if ($error != '') {
1624 1624
 			return $error;
1625 1625
 		} elseif ($globalDebug) echo "Done\n";
1626 1626
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1627
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1627
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1628 1628
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1629 1629
 			if ($globalDebug) echo "Add to DB...";
1630
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1630
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1631 1631
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1632 1632
 		if ($error != '') {
1633 1633
 			return $error;
1634 1634
 		} elseif ($globalDebug) echo "Done\n";
1635 1635
 		if ($globalDebug) echo "Owner Iceland: Download...";
1636
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1636
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1637 1637
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1638 1638
 			if ($globalDebug) echo "Add to DB...";
1639
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1639
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1640 1640
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1641 1641
 		if ($error != '') {
1642 1642
 			return $error;
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
 		global $tmp_dir, $globalDebug;
1649 1649
 		$error = '';
1650 1650
 		if ($globalDebug) echo "Translation : Download...";
1651
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1651
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1652 1652
 		if (file_exists($tmp_dir.'translation.zip')) {
1653 1653
 			if ($globalDebug) echo "Unzip...";
1654 1654
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
 	public static function update_translation_fam() {
1665 1665
 		global $tmp_dir, $globalDebug;
1666 1666
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1667
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1667
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1668 1668
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1669 1669
 			if ($globalDebug) echo "Gunzip...";
1670 1670
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
 	public static function update_ModeS_fam() {
1680 1680
 		global $tmp_dir, $globalDebug;
1681 1681
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1682
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1682
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1683 1683
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1684 1684
 			if ($globalDebug) echo "Gunzip...";
1685 1685
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1694,7 +1694,7 @@  discard block
 block discarded – undo
1694 1694
 	public static function update_routes_fam() {
1695 1695
 		global $tmp_dir, $globalDebug;
1696 1696
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
1697
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1697
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
1698 1698
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1699 1699
 			if ($globalDebug) echo "Gunzip...";
1700 1700
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -1713,18 +1713,18 @@  discard block
 block discarded – undo
1713 1713
 		$error = '';
1714 1714
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
1715 1715
 		if ($globalDBdriver == 'mysql') {
1716
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1716
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1717 1717
 		} else {
1718
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1718
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1719 1719
 		}
1720 1720
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
1721
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1721
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1722 1722
 			$airspace_md5 = $airspace_md5_file[0];
1723 1723
 			if (!update_db::check_airspace_version($airspace_md5)) {
1724 1724
 				if ($globalDBdriver == 'mysql') {
1725
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
1725
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
1726 1726
 				} else {
1727
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1727
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
1728 1728
 				}
1729 1729
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1730 1730
 					if ($globalDebug) echo "Gunzip...";
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
 						try {
1737 1737
 							$sth = $Connection->db->prepare($query);
1738 1738
     	    	    					$sth->execute();
1739
-			            		} catch(PDOException $e) {
1739
+			            		} catch (PDOException $e) {
1740 1740
 							return "error : ".$e->getMessage();
1741 1741
 		            			}
1742 1742
 		    			}
@@ -1754,15 +1754,15 @@  discard block
 block discarded – undo
1754 1754
 	public static function update_tle() {
1755 1755
 		global $tmp_dir, $globalDebug;
1756 1756
 		if ($globalDebug) echo "Download TLE : Download...";
1757
-		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
1758
-		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
1759
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1757
+		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt',
1758
+		'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt',
1759
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
1760 1760
 		foreach ($alltle as $filename) {
1761 1761
 			if ($globalDebug) echo "downloading ".$filename.'...';
1762
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1762
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
1763 1763
 			if (file_exists($tmp_dir.$filename)) {
1764 1764
 				if ($globalDebug) echo "Add to DB ".$filename."...";
1765
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1765
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
1766 1766
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
1767 1767
 			if ($error != '') {
1768 1768
 				echo $error."\n";
@@ -1775,32 +1775,32 @@  discard block
 block discarded – undo
1775 1775
 		global $tmp_dir, $globalDebug;
1776 1776
 		$error = '';
1777 1777
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
1778
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1778
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
1779 1779
 		if (file_exists($tmp_dir.'models.md5sum')) {
1780 1780
 			if ($globalDebug) echo "Check files...\n";
1781 1781
 			$newmodelsdb = array();
1782
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1783
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1782
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
1783
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1784 1784
 					$model = trim($row[2]);
1785 1785
 					$newmodelsdb[$model] = trim($row[0]);
1786 1786
 				}
1787 1787
 			}
1788 1788
 			$modelsdb = array();
1789 1789
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
1790
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
1791
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1790
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
1791
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1792 1792
 						$model = trim($row[2]);
1793 1793
 						$modelsdb[$model] = trim($row[0]);
1794 1794
 					}
1795 1795
 				}
1796 1796
 			}
1797
-			$diff = array_diff($newmodelsdb,$modelsdb);
1797
+			$diff = array_diff($newmodelsdb, $modelsdb);
1798 1798
 			foreach ($diff as $key => $value) {
1799 1799
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
1800
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1800
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
1801 1801
 				
1802 1802
 			}
1803
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1803
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
1804 1804
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
1805 1805
 		if ($error != '') {
1806 1806
 			return $error;
@@ -1812,32 +1812,32 @@  discard block
 block discarded – undo
1812 1812
 		global $tmp_dir, $globalDebug;
1813 1813
 		$error = '';
1814 1814
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
1815
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1815
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
1816 1816
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1817 1817
 			if ($globalDebug) echo "Check files...\n";
1818 1818
 			$newmodelsdb = array();
1819
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1820
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1819
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
1820
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1821 1821
 					$model = trim($row[2]);
1822 1822
 					$newmodelsdb[$model] = trim($row[0]);
1823 1823
 				}
1824 1824
 			}
1825 1825
 			$modelsdb = array();
1826 1826
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
1827
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
1828
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1827
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
1828
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1829 1829
 						$model = trim($row[2]);
1830 1830
 						$modelsdb[$model] = trim($row[0]);
1831 1831
 					}
1832 1832
 				}
1833 1833
 			}
1834
-			$diff = array_diff($newmodelsdb,$modelsdb);
1834
+			$diff = array_diff($newmodelsdb, $modelsdb);
1835 1835
 			foreach ($diff as $key => $value) {
1836 1836
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
1837
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
1837
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
1838 1838
 				
1839 1839
 			}
1840
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
1840
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
1841 1841
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
1842 1842
 		if ($error != '') {
1843 1843
 			return $error;
@@ -1860,8 +1860,8 @@  discard block
 block discarded – undo
1860 1860
 		*/
1861 1861
 		if (file_exists($tmp_dir.'aircrafts.html')) {
1862 1862
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1863
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
1864
-		    $result = fread($fh,100000000);
1863
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
1864
+		    $result = fread($fh, 100000000);
1865 1865
 		    //echo $result;
1866 1866
 		    //var_dump(str_get_html($result));
1867 1867
 		    //print_r(self::table2array($result));
@@ -1879,23 +1879,23 @@  discard block
 block discarded – undo
1879 1879
 			$Connection = new Connection();
1880 1880
 			$sth = $Connection->db->prepare($query);
1881 1881
                         $sth->execute();
1882
-                } catch(PDOException $e) {
1882
+                } catch (PDOException $e) {
1883 1883
                         return "error : ".$e->getMessage();
1884 1884
                 }
1885 1885
 
1886 1886
 		$error = '';
1887 1887
 		if ($globalDebug) echo "Notam : Download...";
1888
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
1888
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
1889 1889
 		if (file_exists($tmp_dir.'notam.rss')) {
1890
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
1890
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
1891 1891
 			foreach ($notams['channel']['item'] as $notam) {
1892
-				$title = explode(':',$notam['title']);
1892
+				$title = explode(':', $notam['title']);
1893 1893
 				$data['ref'] = trim($title[0]);
1894 1894
 				unset($title[0]);
1895
-				$data['title'] = trim(implode(':',$title));
1896
-				$description = strip_tags($notam['description'],'<pre>');
1897
-				preg_match(':^(.*?)<pre>:',$description,$match);
1898
-				$q = explode('/',$match[1]);
1895
+				$data['title'] = trim(implode(':', $title));
1896
+				$description = strip_tags($notam['description'], '<pre>');
1897
+				preg_match(':^(.*?)<pre>:', $description, $match);
1898
+				$q = explode('/', $match[1]);
1899 1899
 				$data['fir'] = $q[0];
1900 1900
 				$data['code'] = $q[1];
1901 1901
 				$ifrvfr = $q[2];
@@ -1911,30 +1911,30 @@  discard block
 block discarded – undo
1911 1911
 				$data['lower_limit'] = $q[5];
1912 1912
 				$data['upper_limit'] = $q[6];
1913 1913
 				$latlonrad = $q[7];
1914
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
1915
-				$latitude = $Common->convertDec($las,'latitude');
1916
-				$longitude = $Common->convertDec($lns,'longitude');
1914
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
1915
+				$latitude = $Common->convertDec($las, 'latitude');
1916
+				$longitude = $Common->convertDec($lns, 'longitude');
1917 1917
 				if ($lac == 'S') $latitude = '-'.$latitude;
1918 1918
 				if ($lnc == 'W') $longitude = '-'.$longitude;
1919 1919
 				$data['center_latitude'] = $latitude;
1920 1920
 				$data['center_longitude'] = $longitude;
1921 1921
 				$data['radius'] = intval($radius);
1922 1922
 				
1923
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
1923
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
1924 1924
 				$data['text'] = $match[1];
1925
-				preg_match(':</pre>(.*?)$:',$description,$match);
1925
+				preg_match(':</pre>(.*?)$:', $description, $match);
1926 1926
 				$fromto = $match[1];
1927
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
1927
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
1928 1928
 				$fromall = trim($match[1]);
1929
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
1929
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
1930 1930
 				$from = trim($match[1]);
1931
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
1932
-				preg_match('#TO:(.*?)$#',$fromto,$match);
1931
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
1932
+				preg_match('#TO:(.*?)$#', $fromto, $match);
1933 1933
 				$toall = trim($match[1]);
1934
-				if (!preg_match(':Permanent:',$toall)) {
1935
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
1934
+				if (!preg_match(':Permanent:', $toall)) {
1935
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
1936 1936
 					$to = trim($match[1]);
1937
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
1937
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
1938 1938
 					$data['permanent'] = 0;
1939 1939
 				} else {
1940 1940
 				    $data['date_end'] = NULL;
@@ -1942,7 +1942,7 @@  discard block
 block discarded – undo
1942 1942
 				}
1943 1943
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
1944 1944
 				$NOTAM = new NOTAM();
1945
-				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1945
+				$NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1946 1946
 				unset($data);
1947 1947
 			} 
1948 1948
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -1965,16 +1965,16 @@  discard block
 block discarded – undo
1965 1965
 				$Connection = new Connection();
1966 1966
 				$sth = $Connection->db->prepare($query);
1967 1967
 				$sth->execute();
1968
-			} catch(PDOException $e) {
1968
+			} catch (PDOException $e) {
1969 1969
 				return "error : ".$e->getMessage();
1970 1970
 			}
1971 1971
 		}
1972 1972
 		$Common = new Common();
1973 1973
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
1974
-		$airspace_json = json_decode($airspace_lst,true);
1974
+		$airspace_json = json_decode($airspace_lst, true);
1975 1975
 		foreach ($airspace_json['records'] as $airspace) {
1976 1976
 			if ($globalDebug) echo $airspace['name']."...\n";
1977
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
1977
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
1978 1978
 			if (file_exists($tmp_dir.$airspace['name'])) {
1979 1979
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
1980 1980
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
 			$Connection = new Connection();
1999 1999
 			$sth = $Connection->db->prepare($query);
2000 2000
                         $sth->execute();
2001
-                } catch(PDOException $e) {
2001
+                } catch (PDOException $e) {
2002 2002
                         return "error : ".$e->getMessage();
2003 2003
                 }
2004 2004
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2013,7 +2013,7 @@  discard block
 block discarded – undo
2013 2013
 			$Connection = new Connection();
2014 2014
 			$sth = $Connection->db->prepare($query);
2015 2015
                         $sth->execute();
2016
-                } catch(PDOException $e) {
2016
+                } catch (PDOException $e) {
2017 2017
                         return "error : ".$e->getMessage();
2018 2018
                 }
2019 2019
 	}
@@ -2024,7 +2024,7 @@  discard block
 block discarded – undo
2024 2024
 			$Connection = new Connection();
2025 2025
 			$sth = $Connection->db->prepare($query);
2026 2026
                         $sth->execute(array(':version' => $version));
2027
-                } catch(PDOException $e) {
2027
+                } catch (PDOException $e) {
2028 2028
                         return "error : ".$e->getMessage();
2029 2029
                 }
2030 2030
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2040,7 +2040,7 @@  discard block
 block discarded – undo
2040 2040
 			$Connection = new Connection();
2041 2041
 			$sth = $Connection->db->prepare($query);
2042 2042
                         $sth->execute(array(':version' => $version));
2043
-                } catch(PDOException $e) {
2043
+                } catch (PDOException $e) {
2044 2044
                         return "error : ".$e->getMessage();
2045 2045
                 }
2046 2046
 	}
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
 			$Connection = new Connection();
2057 2057
 			$sth = $Connection->db->prepare($query);
2058 2058
                         $sth->execute();
2059
-                } catch(PDOException $e) {
2059
+                } catch (PDOException $e) {
2060 2060
                         return "error : ".$e->getMessage();
2061 2061
                 }
2062 2062
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2071,7 +2071,7 @@  discard block
 block discarded – undo
2071 2071
 			$Connection = new Connection();
2072 2072
 			$sth = $Connection->db->prepare($query);
2073 2073
                         $sth->execute();
2074
-                } catch(PDOException $e) {
2074
+                } catch (PDOException $e) {
2075 2075
                         return "error : ".$e->getMessage();
2076 2076
                 }
2077 2077
 	}
@@ -2086,7 +2086,7 @@  discard block
 block discarded – undo
2086 2086
 			$Connection = new Connection();
2087 2087
 			$sth = $Connection->db->prepare($query);
2088 2088
                         $sth->execute();
2089
-                } catch(PDOException $e) {
2089
+                } catch (PDOException $e) {
2090 2090
                         return "error : ".$e->getMessage();
2091 2091
                 }
2092 2092
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2101,7 +2101,7 @@  discard block
 block discarded – undo
2101 2101
 			$Connection = new Connection();
2102 2102
 			$sth = $Connection->db->prepare($query);
2103 2103
                         $sth->execute();
2104
-                } catch(PDOException $e) {
2104
+                } catch (PDOException $e) {
2105 2105
                         return "error : ".$e->getMessage();
2106 2106
                 }
2107 2107
 	}
@@ -2117,7 +2117,7 @@  discard block
 block discarded – undo
2117 2117
 			$Connection = new Connection();
2118 2118
 			$sth = $Connection->db->prepare($query);
2119 2119
                         $sth->execute();
2120
-                } catch(PDOException $e) {
2120
+                } catch (PDOException $e) {
2121 2121
                         return "error : ".$e->getMessage();
2122 2122
                 }
2123 2123
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2132,7 +2132,7 @@  discard block
 block discarded – undo
2132 2132
 			$Connection = new Connection();
2133 2133
 			$sth = $Connection->db->prepare($query);
2134 2134
                         $sth->execute();
2135
-                } catch(PDOException $e) {
2135
+                } catch (PDOException $e) {
2136 2136
                         return "error : ".$e->getMessage();
2137 2137
                 }
2138 2138
 	}
@@ -2147,7 +2147,7 @@  discard block
 block discarded – undo
2147 2147
 			$Connection = new Connection();
2148 2148
 			$sth = $Connection->db->prepare($query);
2149 2149
                         $sth->execute();
2150
-                } catch(PDOException $e) {
2150
+                } catch (PDOException $e) {
2151 2151
                         return "error : ".$e->getMessage();
2152 2152
                 }
2153 2153
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2162,7 +2162,7 @@  discard block
 block discarded – undo
2162 2162
 			$Connection = new Connection();
2163 2163
 			$sth = $Connection->db->prepare($query);
2164 2164
                         $sth->execute();
2165
-                } catch(PDOException $e) {
2165
+                } catch (PDOException $e) {
2166 2166
                         return "error : ".$e->getMessage();
2167 2167
                 }
2168 2168
 	}
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
 			$Connection = new Connection();
2178 2178
 			$sth = $Connection->db->prepare($query);
2179 2179
                         $sth->execute();
2180
-                } catch(PDOException $e) {
2180
+                } catch (PDOException $e) {
2181 2181
                         return "error : ".$e->getMessage();
2182 2182
                 }
2183 2183
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
 			$Connection = new Connection();
2193 2193
 			$sth = $Connection->db->prepare($query);
2194 2194
                         $sth->execute();
2195
-                } catch(PDOException $e) {
2195
+                } catch (PDOException $e) {
2196 2196
                         return "error : ".$e->getMessage();
2197 2197
                 }
2198 2198
 	}
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
 			$Connection = new Connection();
2208 2208
 			$sth = $Connection->db->prepare($query);
2209 2209
                         $sth->execute();
2210
-                } catch(PDOException $e) {
2210
+                } catch (PDOException $e) {
2211 2211
                         return "error : ".$e->getMessage();
2212 2212
                 }
2213 2213
 	}
Please login to merge, or discard this patch.