Completed
Push — master ( 3d964c...f49a24 )
by Yannick
33:17
created
date-statistics-airline-country.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,11 @@
 block discarded – undo
8 8
 $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
9 9
 
10 10
 $Spotter = new Spotter();
11
-if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
12
-else $spotter_array = array();
11
+if (isset($_GET['date'])) {
12
+	$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
13
+} else {
14
+	$spotter_array = array();
15
+}
13 16
 
14 17
 if (!empty($spotter_array))
15 18
 {
Please login to merge, or discard this patch.
accident-latest.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,12 @@
 block discarded – undo
38 38
 if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) {
39 39
 	include('table-output.php');
40 40
 	print '<div class="pagination">';
41
-	if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
42
-	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
41
+	if ($limit_previous_1 >= 0) {
42
+		print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
43
+	}
44
+	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) {
45
+		print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
46
+	}
43 47
 	print '</div>';
44 48
 }
45 49
 print '</div>';
Please login to merge, or discard this patch.
table-output.php 1 patch
Braces   +45 added lines, -17 removed lines patch added patch discarded remove patch
@@ -365,7 +365,9 @@  discard block
 block discarded – undo
365 365
 	if (isset($globalTimezone))
366 366
 	{
367 367
 		date_default_timezone_set($globalTimezone);
368
-	} else date_default_timezone_set('UTC');
368
+	} else {
369
+		date_default_timezone_set('UTC');
370
+	}
369 371
 	if ($showSpecial === true)
370 372
 	{
371 373
 		print '<tr class="special">'."\n";
@@ -384,8 +386,9 @@  discard block
 block discarded – undo
384 386
 			print '<td class="aircraft_thumbnail">'."\n";
385 387
 			
386 388
 			if ($spotter_item['image_source'] == 'planespotters') {
387
-				if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
388
-				else {
389
+				if ($spotter_item['image_source_website'] != '') {
390
+					$image_src = $spotter_item['image_source_website'];
391
+				} else {
389 392
 					$planespotter_url_array = explode("_", $spotter_item['image']);
390 393
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
391 394
                                         $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -398,7 +401,9 @@  discard block
 block discarded – undo
398 401
                         } else {
399 402
                     		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
400 403
                     		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
401
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
404
+                    		} else {
405
+                    			$image_thumbnail = $spotter_item['image_thumbnail'];
406
+                    		}
402 407
 				if (isset($spotter_item['airline_name'])) {
403 408
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
404 409
 				} else {
@@ -420,8 +425,9 @@  discard block
 block discarded – undo
420 425
 			print '<td class="aircraft_thumbnail">'."\n";
421 426
 			//print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
422 427
 			if ($spotter_item['image_source'] == 'planespotters') {
423
-				if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
424
-				else {
428
+				if ($spotter_item['image_source_website'] != '') {
429
+					$image_src = $spotter_item['image_source_website'];
430
+				} else {
425 431
 					$planespotter_url_array = explode("_", $spotter_array[0]['image']);
426 432
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
427 433
                                         $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -438,7 +444,9 @@  discard block
 block discarded – undo
438 444
 			} else {
439 445
                     		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
440 446
                     		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
441
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
447
+                    		} else {
448
+                    			$image_thumbnail = $spotter_item['image_thumbnail'];
449
+                    		}
442 450
 				if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
443 451
 					print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
444 452
 				} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -525,15 +533,21 @@  discard block
 block discarded – undo
525 533
 		if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
526 534
 			if ($spotter_item['departure_airport_time'] > 2460) {
527 535
 				$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
528
-			} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
536
+			} else {
537
+				$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
538
+			}
529 539
 			if ($spotter_item['real_departure_airport_time'] > 2460) {
530 540
 				$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
531
-			} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
541
+			} else {
542
+				$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
543
+			}
532 544
 			print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
533 545
 		} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
534 546
 			if ($spotter_item['real_departure_airport_time'] > 2460) {
535 547
 				$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
536
-			} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
548
+			} else {
549
+				$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
550
+			}
537 551
 			print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
538 552
 		} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
539 553
 			if ($spotter_item['departure_airport_time'] > 2460) {
@@ -555,7 +569,9 @@  discard block
 block discarded – undo
555 569
 					$longitude = $spotter_item['longitude'];
556 570
 				}
557 571
 				$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
558
-			} else $distance = '';
572
+			} else {
573
+				$distance = '';
574
+			}
559 575
 			if ($distance != '') {
560 576
 			    if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
561 577
 				    echo '<br/><i>'.round($distance*0.539957).' nm</i>';
@@ -580,7 +596,9 @@  discard block
 block discarded – undo
580 596
 		} else {
581 597
 			if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) {
582 598
 				print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
583
-				if (!isset($Spotter)) $Spotter = new Spotter();
599
+				if (!isset($Spotter)) {
600
+					$Spotter = new Spotter();
601
+				}
584 602
 				$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
585 603
 				print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
586 604
 				print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
@@ -596,20 +614,28 @@  discard block
 block discarded – undo
596 614
 		if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
597 615
 			if ($spotter_item['arrival_airport_time'] > 2460) {
598 616
 				$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
599
-			} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
617
+			} else {
618
+				$arrival_airport_time = $spotter_item['arrival_airport_time'];
619
+			}
600 620
 			if ($spotter_item['real_arrival_airport_time'] > 2460) {
601 621
 				$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
602
-			} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
622
+			} else {
623
+				$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
624
+			}
603 625
 			print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
604 626
 		} elseif (isset($spotter_item['real_arrival_airport_time'])) {
605 627
 			if ($spotter_item['real_arrival_airport_time'] > 2460) {
606 628
 				$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
607
-			} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
629
+			} else {
630
+				$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
631
+			}
608 632
 			print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
609 633
 		} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
610 634
 			if ($spotter_item['arrival_airport_time'] > 2460) {
611 635
 				$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
612
-			} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
636
+			} else {
637
+				$arrival_airport_time = $spotter_item['arrival_airport_time'];
638
+			}
613 639
 			print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
614 640
 		}
615 641
 		if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
@@ -622,7 +648,9 @@  discard block
 block discarded – undo
622 648
 					$longitude = $spotter_item['longitude'];
623 649
 				}
624 650
 				$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
625
-			} else $distance = '';
651
+			} else {
652
+				$distance = '';
653
+			}
626 654
 				if ($distance != '') {
627 655
 				    if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
628 656
 					    echo '<br/><i>'.round($distance*0.539957).' nm</i>';
Please login to merge, or discard this patch.
incident-latest.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,12 @@
 block discarded – undo
38 38
 if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) {
39 39
 	include('table-output.php');
40 40
 	print '<div class="pagination">';
41
-	if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
42
-	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
41
+	if ($limit_previous_1 >= 0) {
42
+		print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
43
+	}
44
+	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) {
45
+		print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
46
+	}
43 47
 	print '</div>';
44 48
 }
45 49
 print '</div>';
Please login to merge, or discard this patch.
require/class.METAR.php 1 patch
Braces   +94 added lines, -36 removed lines patch added patch discarded remove patch
@@ -59,8 +59,11 @@  discard block
 block discarded – undo
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
61 61
                 $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
62
+                if ($row['nb'] > 0) {
63
+                	return false;
64
+                } else {
65
+                	return true;
66
+                }
64 67
         }
65 68
 
66 69
         public static function insert_last_update() {
@@ -84,9 +87,14 @@  discard block
 block discarded – undo
84 87
     		//$pieces = explode(' ',$data);
85 88
     		$pieces = preg_split('/\s/',$data);
86 89
     		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
+    		if ($pieces[0] == 'METAR') {
91
+    			$pos++;
92
+    		} elseif ($pieces[0] == 'SPECI') {
93
+    			$pos++;
94
+    		}
95
+    		if (strlen($pieces[$pos]) != 4) {
96
+    			$pos++;
97
+    		}
90 98
     		$result = array();
91 99
     		$result['location'] = $pieces[$pos];
92 100
     		$pos++;
@@ -95,16 +103,26 @@  discard block
 block discarded – undo
95 103
     		$c = count($pieces);
96 104
     		for($pos++; $pos < $c; $pos++) {
97 105
     			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
106
+    			if ($piece == 'RMK') {
107
+    				break;
108
+    			}
109
+    			if ($piece == 'AUTO') {
110
+    				$result['auto'] = true;
111
+    			}
112
+    			if ($piece == 'COR') {
113
+    				$result['correction'] = true;
114
+    			}
101 115
     			// Wind Speed
102 116
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103 117
     				$result['wind']['direction'] = (float)$matches[1];
104 118
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
119
+    				if ($result['wind']['unit'] == 'KT') {
120
+    					$result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
121
+    				} elseif ($result['wind']['unit'] == 'KPH') {
122
+    					$result['wind']['speed'] = round(((float)$matches[2])*1000,2);
123
+    				} elseif ($result['wind']['unit'] == 'MPS') {
124
+    					$result['wind']['speed'] = round(((float)$matches[2]),2);
125
+    				}
108 126
 				$result['wind']['gust'] = (float)$matches[3];
109 127
 				$result['wind']['unit'] = $matches[4];
110 128
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
@@ -186,14 +204,23 @@  discard block
 block discarded – undo
186 204
     				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187 205
     				$type = $matches[1];
188 206
     				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
207
+    				if ($type == 'SKC') {
208
+    					$cloud['type'] = 'No cloud/Sky clear';
209
+    				} elseif ($type == 'CLR') {
210
+    					$cloud['type'] = 'No cloud below 12,000ft (3700m)';
211
+    				} elseif ($type == 'NSC') {
212
+    					$cloud['type'] = 'No significant cloud';
213
+    				} elseif ($type == 'FEW') {
214
+    					$cloud['type'] = 'Few';
215
+    				} elseif ($type == 'SCT') {
216
+    					$cloud['type'] = 'Scattered';
217
+    				} elseif ($type == 'BKN') {
218
+    					$cloud['type'] = 'Broken';
219
+    				} elseif ($type == 'OVC') {
220
+    					$cloud['type'] = 'Overcast/Full cloud coverage';
221
+    				} elseif ($type == 'VV') {
222
+    					$cloud['type'] = 'Vertical visibility';
223
+    				}
197 224
     				$cloud['type_code'] = $type;
198 225
     				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199 226
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
@@ -223,8 +250,11 @@  discard block
 block discarded – undo
223 250
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 251
     				//echo $piece;
225 252
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
253
+    				if (isset($matches[5])) {
254
+    					$range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
255
+    				} else {
256
+    					$range = array('exact' => (float)$matches[2], 'unit' => 'M');
257
+    				}
228 258
 				if (isset($matches[3])) {
229 259
 					$range = Array(
230 260
 					    'from' => (float)$matches[2],
@@ -257,8 +287,11 @@  discard block
 block discarded – undo
257 287
 				if (isset($matches[3])) {
258 288
 					$text[] = $this->texts[$matches[3]];
259 289
 				}
260
-				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261
-				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
290
+				if (!isset($result['weather'])) {
291
+					$result['weather'] = implode(' ', $text);
292
+				} else {
293
+					$result['weather'] = $result['weather'].' / '.implode(' ', $text);
294
+				}
262 295
     			}
263 296
     		}
264 297
     		return $result;
@@ -270,8 +303,11 @@  discard block
 block discarded – undo
270 303
     		if (isset($globalMETARcycle) && $globalMETARcycle) {
271 304
             		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272 305
                 } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
306
+            		if ($globalDBdriver == 'mysql') {
307
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
308
+            		} else {
309
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
310
+            		}
275 311
                 }
276 312
                 $query_values = array(':icao' => $icao);
277 313
                  try {
@@ -326,7 +362,9 @@  discard block
 block discarded – undo
326 362
         
327 363
         public function addMETARCycle() {
328 364
     		global $globalDebug, $globalIVAO;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
365
+    		if (isset($globalDebug) && $globalDebug) {
366
+    			echo "Downloading METAR cycle...";
367
+    		}
330 368
     		date_default_timezone_set("UTC");
331 369
     		$Common = new Common();
332 370
     		if (isset($globalIVAO) && $globalIVAO) {
@@ -339,7 +377,9 @@  discard block
 block discarded – undo
339 377
     			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340 378
     		}
341 379
     		if ($handle) {
342
-			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
380
+			if (isset($globalDebug) && $globalDebug) {
381
+				echo "Done - Updating DB...";
382
+			}
343 383
 			$date = '';
344 384
     			//foreach(explode("\n",$cycle) as $line) {
345 385
 	    		while(($line = fgets($handle,4096)) !== false) {
@@ -347,23 +387,33 @@  discard block
 block discarded – undo
347 387
 					$date = $line;
348 388
     				} elseif ($line != '') {
349 389
     				    //$this->parse($line);
350
-    				    if ($date == '') $date = date('Y/m/d H:m');
390
+    				    if ($date == '') {
391
+    				    	$date = date('Y/m/d H:m');
392
+    				    }
351 393
         			    $pos = 0;
352 394
         			    $pieces = preg_split('/\s/',$line);
353
-        			    if ($pieces[0] == 'METAR') $pos++;
354
-        			    if (strlen($pieces[$pos]) != 4) $pos++;
395
+        			    if ($pieces[0] == 'METAR') {
396
+        			    	$pos++;
397
+        			    }
398
+        			    if (strlen($pieces[$pos]) != 4) {
399
+        			    	$pos++;
400
+        			    }
355 401
 		        	    $location = $pieces[$pos];
356 402
         	        	    echo $this->addMETAR($location,$line,$date);
357 403
     				}
358 404
     			}
359 405
     			fclose($handle);
360 406
     		}
361
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
407
+    		if (isset($globalDebug) && $globalDebug) {
408
+    			echo "Done\n";
409
+    		}
362 410
         
363 411
         }
364 412
         public function downloadMETAR($icao) {
365 413
     		global $globalMETARurl;
366
-    		if ($globalMETARurl == '') return array();
414
+    		if ($globalMETARurl == '') {
415
+    			return array();
416
+    		}
367 417
     		date_default_timezone_set("UTC");
368 418
     		$Common = new Common();
369 419
     		$url = str_replace('{icao}',$icao,$globalMETARurl);
@@ -377,16 +427,24 @@  discard block
 block discarded – undo
377 427
     			if ($line != '') {
378 428
     			    //$this->parse($line);
379 429
     			    //echo $line;
380
-    			    if ($date == '') $date = date('Y/m/d H:m');
430
+    			    if ($date == '') {
431
+    			    	$date = date('Y/m/d H:m');
432
+    			    }
381 433
     			    $pos = 0;
382 434
     			    $pieces = preg_split('/\s/',$line);
383
-    			    if ($pieces[0] == 'METAR') $pos++;
384
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
435
+    			    if ($pieces[0] == 'METAR') {
436
+    			    	$pos++;
437
+    			    }
438
+    			    if (strlen($pieces[$pos]) != 4) {
439
+    			    	$pos++;
440
+    			    }
385 441
 	        	    $location = $pieces[$pos];
386 442
 	        	    if (strlen($location == 4)) {
387 443
 	        		$this->addMETAR($location,$line,$date);
388 444
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
389
-	        	    } else return array();
445
+	        	    } else {
446
+	        	    	return array();
447
+	        	    }
390 448
     			}
391 449
     			//echo $line."\n";
392 450
     		}
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Braces   +389 added lines, -135 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -77,7 +79,9 @@  discard block
 block discarded – undo
77 79
                 }
78 80
         }
79 81
 	public function getAllAirlineNames($filter_name = '') {
80
-		if ($filter_name == '') $filter_name = $this->filter_name;
82
+		if ($filter_name == '') {
83
+			$filter_name = $this->filter_name;
84
+		}
81 85
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82 86
                  try {
83 87
                         $sth = $this->db->prepare($query);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
                 return $all;
90 94
         }
91 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92
-		if ($filter_name == '') $filter_name = $this->filter_name;
96
+		if ($filter_name == '') {
97
+			$filter_name = $this->filter_name;
98
+		}
93 99
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 100
                  try {
95 101
                         $sth = $this->db->prepare($query);
@@ -101,7 +107,9 @@  discard block
 block discarded – undo
101 107
                 return $all;
102 108
         }
103 109
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104
-		if ($filter_name == '') $filter_name = $this->filter_name;
110
+		if ($filter_name == '') {
111
+			$filter_name = $this->filter_name;
112
+		}
105 113
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 114
                  try {
107 115
                         $sth = $this->db->prepare($query);
@@ -113,7 +121,9 @@  discard block
 block discarded – undo
113 121
                 return $all;
114 122
         }
115 123
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
124
+		if ($filter_name == '') {
125
+			$filter_name = $this->filter_name;
126
+		}
117 127
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 128
                  try {
119 129
                         $sth = $this->db->prepare($query);
@@ -128,9 +138,14 @@  discard block
 block discarded – undo
128 138
 
129 139
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
130 140
 		global $globalStatsFilters;
131
-		if ($filter_name == '') $filter_name = $this->filter_name;
132
-		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
133
-		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
141
+		if ($filter_name == '') {
142
+			$filter_name = $this->filter_name;
143
+		}
144
+		if ($limit) {
145
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
146
+		} else {
147
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
148
+		}
134 149
                  try {
135 150
                         $sth = $this->db->prepare($query);
136 151
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -150,9 +165,14 @@  discard block
 block discarded – undo
150 165
 	}
151 166
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
152 167
 		global $globalStatsFilters;
153
-		if ($filter_name == '') $filter_name = $this->filter_name;
154
-		if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
155
-		else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
168
+		if ($filter_name == '') {
169
+			$filter_name = $this->filter_name;
170
+		}
171
+		if ($limit) {
172
+			$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
173
+		} else {
174
+			$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
175
+		}
156 176
                  try {
157 177
                         $sth = $this->db->prepare($query);
158 178
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -172,9 +192,14 @@  discard block
 block discarded – undo
172 192
 	}
173 193
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
174 194
 		global $globalStatsFilters;
175
-		if ($filter_name == '') $filter_name = $this->filter_name;
176
-		if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
177
-		else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
195
+		if ($filter_name == '') {
196
+			$filter_name = $this->filter_name;
197
+		}
198
+		if ($limit) {
199
+			$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
200
+		} else {
201
+			$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
202
+		}
178 203
                  try {
179 204
                         $sth = $this->db->prepare($query);
180 205
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -195,9 +220,14 @@  discard block
 block discarded – undo
195 220
 
196 221
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
197 222
 		global $globalStatsFilters;
198
-		if ($filter_name == '') $filter_name = $this->filter_name;
199
-		if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
200
-		else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
223
+		if ($filter_name == '') {
224
+			$filter_name = $this->filter_name;
225
+		}
226
+		if ($limit) {
227
+			$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
228
+		} else {
229
+			$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
230
+		}
201 231
                  try {
202 232
                         $sth = $this->db->prepare($query);
203 233
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -217,9 +247,14 @@  discard block
 block discarded – undo
217 247
 	}
218 248
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
219 249
 		global $globalStatsFilters;
220
-		if ($filter_name == '') $filter_name = $this->filter_name;
221
-		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
222
-		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
250
+		if ($filter_name == '') {
251
+			$filter_name = $this->filter_name;
252
+		}
253
+		if ($limit) {
254
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
255
+		} else {
256
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
257
+		}
223 258
                  try {
224 259
                         $sth = $this->db->prepare($query);
225 260
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -240,9 +275,14 @@  discard block
 block discarded – undo
240 275
 
241 276
 	public function countAllAirlines($limit = true,$filter_name = '') {
242 277
 		global $globalStatsFilters;
243
-		if ($filter_name == '') $filter_name = $this->filter_name;
244
-		if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
245
-		else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
278
+		if ($filter_name == '') {
279
+			$filter_name = $this->filter_name;
280
+		}
281
+		if ($limit) {
282
+			$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
283
+		} else {
284
+			$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
285
+		}
246 286
                  try {
247 287
                         $sth = $this->db->prepare($query);
248 288
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -263,9 +303,14 @@  discard block
 block discarded – undo
263 303
 	}
264 304
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
265 305
 		global $globalStatsFilters;
266
-		if ($filter_name == '') $filter_name = $this->filter_name;
267
-		if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
268
-		else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
306
+		if ($filter_name == '') {
307
+			$filter_name = $this->filter_name;
308
+		}
309
+		if ($limit) {
310
+			$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
311
+		} else {
312
+			$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
313
+		}
269 314
                  try {
270 315
                         $sth = $this->db->prepare($query);
271 316
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -285,9 +330,14 @@  discard block
 block discarded – undo
285 330
 	}
286 331
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
287 332
 		global $globalStatsFilters;
288
-		if ($filter_name == '') $filter_name = $this->filter_name;
289
-		if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
290
-		else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
333
+		if ($filter_name == '') {
334
+			$filter_name = $this->filter_name;
335
+		}
336
+		if ($limit) {
337
+			$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
338
+		} else {
339
+			$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
340
+		}
291 341
 		 try {
292 342
 			$sth = $this->db->prepare($query);
293 343
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -307,10 +357,15 @@  discard block
 block discarded – undo
307 357
 	}
308 358
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
309 359
 		$Connection = new Connection();
310
-		if ($filter_name == '') $filter_name = $this->filter_name;
360
+		if ($filter_name == '') {
361
+			$filter_name = $this->filter_name;
362
+		}
311 363
 		if ($Connection->tableExists('countries')) {
312
-			if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
313
-			else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
364
+			if ($limit) {
365
+				$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
366
+			} else {
367
+				$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
368
+			}
314 369
 			 try {
315 370
 				$sth = $this->db->prepare($query);
316 371
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -331,9 +386,14 @@  discard block
 block discarded – undo
331 386
 	}
332 387
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
333 388
 		global $globalStatsFilters;
334
-		if ($filter_name == '') $filter_name = $this->filter_name;
335
-		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
336
-		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
389
+		if ($filter_name == '') {
390
+			$filter_name = $this->filter_name;
391
+		}
392
+		if ($limit) {
393
+			$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
394
+		} else {
395
+			$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
396
+		}
337 397
                  try {
338 398
                         $sth = $this->db->prepare($query);
339 399
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -353,9 +413,14 @@  discard block
 block discarded – undo
353 413
 	}
354 414
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
355 415
 		global $globalStatsFilters;
356
-		if ($filter_name == '') $filter_name = $this->filter_name;
357
-		if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
358
-		else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
416
+		if ($filter_name == '') {
417
+			$filter_name = $this->filter_name;
418
+		}
419
+		if ($limit) {
420
+			$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
421
+		} else {
422
+			$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
423
+		}
359 424
                  try {
360 425
                         $sth = $this->db->prepare($query);
361 426
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -375,9 +440,14 @@  discard block
 block discarded – undo
375 440
 	}
376 441
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
377 442
 		global $globalStatsFilters;
378
-		if ($filter_name == '') $filter_name = $this->filter_name;
379
-		if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
380
-		else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
443
+		if ($filter_name == '') {
444
+			$filter_name = $this->filter_name;
445
+		}
446
+		if ($limit) {
447
+			$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
448
+		} else {
449
+			$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
450
+		}
381 451
                  try {
382 452
                         $sth = $this->db->prepare($query);
383 453
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -403,7 +473,9 @@  discard block
 block discarded – undo
403 473
         			$icao = $value['airport_departure_icao'];
404 474
         			if (isset($all[$icao])) {
405 475
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
406
-        			} else $all[$icao] = $value;
476
+        			} else {
477
+        				$all[$icao] = $value;
478
+        			}
407 479
         		}
408 480
         		$count = array();
409 481
         		foreach ($all as $key => $row) {
@@ -415,9 +487,14 @@  discard block
 block discarded – undo
415 487
 	}
416 488
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
417 489
 		global $globalStatsFilters;
418
-		if ($filter_name == '') $filter_name = $this->filter_name;
419
-		if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
420
-		else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
490
+		if ($filter_name == '') {
491
+			$filter_name = $this->filter_name;
492
+		}
493
+		if ($limit) {
494
+			$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
495
+		} else {
496
+			$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
497
+		}
421 498
 		try {
422 499
 			$sth = $this->db->prepare($query);
423 500
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -443,7 +520,9 @@  discard block
 block discarded – undo
443 520
         			$icao = $value['airport_arrival_icao'];
444 521
         			if (isset($all[$icao])) {
445 522
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
446
-        			} else $all[$icao] = $value;
523
+        			} else {
524
+        				$all[$icao] = $value;
525
+        			}
447 526
         		}
448 527
         		$count = array();
449 528
         		foreach ($all as $key => $row) {
@@ -456,13 +535,21 @@  discard block
 block discarded – undo
456 535
 	}
457 536
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
458 537
 		global $globalDBdriver, $globalStatsFilters;
459
-		if ($filter_name == '') $filter_name = $this->filter_name;
538
+		if ($filter_name == '') {
539
+			$filter_name = $this->filter_name;
540
+		}
460 541
 		if ($globalDBdriver == 'mysql') {
461
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
462
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
542
+			if ($limit) {
543
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
544
+			} else {
545
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
546
+			}
463 547
 		} else {
464
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
465
-			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
548
+			if ($limit) {
549
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
550
+			} else {
551
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
552
+			}
466 553
 		}
467 554
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
468 555
                  try {
@@ -486,7 +573,9 @@  discard block
 block discarded – undo
486 573
 	
487 574
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
488 575
 		global $globalStatsFilters;
489
-		if ($filter_name == '') $filter_name = $this->filter_name;
576
+		if ($filter_name == '') {
577
+			$filter_name = $this->filter_name;
578
+		}
490 579
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
491 580
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
492 581
                  try {
@@ -508,7 +597,9 @@  discard block
 block discarded – undo
508 597
 	}
509 598
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
510 599
 		global $globalDBdriver, $globalStatsFilters;
511
-		if ($filter_name == '') $filter_name = $this->filter_name;
600
+		if ($filter_name == '') {
601
+			$filter_name = $this->filter_name;
602
+		}
512 603
 		if ($globalDBdriver == 'mysql') {
513 604
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
514 605
 		} else {
@@ -534,7 +625,9 @@  discard block
 block discarded – undo
534 625
 	}
535 626
 	public function countAllDates($stats_airline = '',$filter_name = '') {
536 627
 		global $globalStatsFilters;
537
-		if ($filter_name == '') $filter_name = $this->filter_name;
628
+		if ($filter_name == '') {
629
+			$filter_name = $this->filter_name;
630
+		}
538 631
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
539 632
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
540 633
                  try {
@@ -556,7 +649,9 @@  discard block
 block discarded – undo
556 649
 	}
557 650
 	public function countAllDatesByAirlines($filter_name = '') {
558 651
 		global $globalStatsFilters;
559
-		if ($filter_name == '') $filter_name = $this->filter_name;
652
+		if ($filter_name == '') {
653
+			$filter_name = $this->filter_name;
654
+		}
560 655
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
561 656
 		$query_data = array('filter_name' => $filter_name);
562 657
                  try {
@@ -578,7 +673,9 @@  discard block
 block discarded – undo
578 673
 	}
579 674
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
580 675
 		global $globalStatsFilters;
581
-		if ($filter_name == '') $filter_name = $this->filter_name;
676
+		if ($filter_name == '') {
677
+			$filter_name = $this->filter_name;
678
+		}
582 679
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
583 680
                  try {
584 681
                         $sth = $this->db->prepare($query);
@@ -599,7 +696,9 @@  discard block
 block discarded – undo
599 696
 	}
600 697
 	public function countAllMilitaryMonths($filter_name = '') {
601 698
 		global $globalStatsFilters;
602
-		if ($filter_name == '') $filter_name = $this->filter_name;
699
+		if ($filter_name == '') {
700
+			$filter_name = $this->filter_name;
701
+		}
603 702
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
604 703
                  try {
605 704
                         $sth = $this->db->prepare($query);
@@ -620,9 +719,14 @@  discard block
 block discarded – undo
620 719
 	}
621 720
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
622 721
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
623
-		if ($filter_name == '') $filter_name = $this->filter_name;
624
-		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
625
-		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
722
+		if ($filter_name == '') {
723
+			$filter_name = $this->filter_name;
724
+		}
725
+		if ($limit) {
726
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
727
+		} else {
728
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
729
+		}
626 730
 		if ($orderby == 'hour') {
627 731
 			/*
628 732
 			if ($globalDBdriver == 'mysql') {
@@ -631,7 +735,9 @@  discard block
 block discarded – undo
631 735
 			*/
632 736
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
633 737
 		}
634
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
738
+		if ($orderby == 'count') {
739
+			$query .= " ORDER BY hour_count DESC";
740
+		}
635 741
                  try {
636 742
                         $sth = $this->db->prepare($query);
637 743
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -652,7 +758,9 @@  discard block
 block discarded – undo
652 758
 	
653 759
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
654 760
 		global $globalStatsFilters;
655
-		if ($filter_name == '') $filter_name = $this->filter_name;
761
+		if ($filter_name == '') {
762
+			$filter_name = $this->filter_name;
763
+		}
656 764
 		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
657 765
 		if (empty($all)) {
658 766
 			$filters = array('airlines' => array($stats_airline));
@@ -666,7 +774,9 @@  discard block
 block discarded – undo
666 774
 	}
667 775
 	public function countOverallMilitaryFlights($filter_name = '') {
668 776
 		global $globalStatsFilters;
669
-		if ($filter_name == '') $filter_name = $this->filter_name;
777
+		if ($filter_name == '') {
778
+			$filter_name = $this->filter_name;
779
+		}
670 780
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
671 781
 		if (empty($all)) {
672 782
 		        $filters = array();
@@ -680,7 +790,9 @@  discard block
 block discarded – undo
680 790
 	}
681 791
 	public function countOverallArrival($stats_airline = '',$filter_name = '') {
682 792
 		global $globalStatsFilters;
683
-		if ($filter_name == '') $filter_name = $this->filter_name;
793
+		if ($filter_name == '') {
794
+			$filter_name = $this->filter_name;
795
+		}
684 796
 		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
685 797
 		if (empty($all)) {
686 798
 			$filters = array('airlines' => array($stats_airline));
@@ -694,7 +806,9 @@  discard block
 block discarded – undo
694 806
 	}
695 807
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
696 808
 		global $globalStatsFilters;
697
-		if ($filter_name == '') $filter_name = $this->filter_name;
809
+		if ($filter_name == '') {
810
+			$filter_name = $this->filter_name;
811
+		}
698 812
 		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
699 813
 		if (empty($all)) {
700 814
 			$filters = array('airlines' => array($stats_airline));
@@ -708,7 +822,9 @@  discard block
 block discarded – undo
708 822
 	}
709 823
 	public function countOverallAirlines($filter_name = '') {
710 824
 		global $globalStatsFilters;
711
-		if ($filter_name == '') $filter_name = $this->filter_name;
825
+		if ($filter_name == '') {
826
+			$filter_name = $this->filter_name;
827
+		}
712 828
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
713 829
                  try {
714 830
                         $sth = $this->db->prepare($query);
@@ -731,7 +847,9 @@  discard block
 block discarded – undo
731 847
 	}
732 848
 	public function countOverallOwners($stats_airline = '',$filter_name = '') {
733 849
 		global $globalStatsFilters;
734
-		if ($filter_name == '') $filter_name = $this->filter_name;
850
+		if ($filter_name == '') {
851
+			$filter_name = $this->filter_name;
852
+		}
735 853
 		/*
736 854
 		$query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";
737 855
                  try {
@@ -756,7 +874,9 @@  discard block
 block discarded – undo
756 874
 	}
757 875
 	public function countOverallPilots($stats_airline = '',$filter_name = '') {
758 876
 		global $globalStatsFilters;
759
-		if ($filter_name == '') $filter_name = $this->filter_name;
877
+		if ($filter_name == '') {
878
+			$filter_name = $this->filter_name;
879
+		}
760 880
 		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
761 881
 		if (empty($all)) {
762 882
 			$filters = array('airlines' => array($stats_airline));
@@ -770,7 +890,9 @@  discard block
 block discarded – undo
770 890
 	}
771 891
 
772 892
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
773
-		if ($filter_name == '') $filter_name = $this->filter_name;
893
+		if ($filter_name == '') {
894
+			$filter_name = $this->filter_name;
895
+		}
774 896
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
775 897
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
776 898
                  try {
@@ -783,7 +905,9 @@  discard block
 block discarded – undo
783 905
                 return $all;
784 906
 	}
785 907
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
786
-		if ($filter_name == '') $filter_name = $this->filter_name;
908
+		if ($filter_name == '') {
909
+			$filter_name = $this->filter_name;
910
+		}
787 911
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
788 912
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
789 913
                  try {
@@ -796,7 +920,9 @@  discard block
 block discarded – undo
796 920
                 return $all;
797 921
         }
798 922
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
799
-		if ($filter_name == '') $filter_name = $this->filter_name;
923
+		if ($filter_name == '') {
924
+			$filter_name = $this->filter_name;
925
+		}
800 926
     		global $globalArchiveMonths, $globalDBdriver;
801 927
     		if ($globalDBdriver == 'mysql') {
802 928
 	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -815,7 +941,9 @@  discard block
 block discarded – undo
815 941
         }
816 942
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
817 943
     		global $globalArchiveMonths, $globalDBdriver;
818
-		if ($filter_name == '') $filter_name = $this->filter_name;
944
+		if ($filter_name == '') {
945
+			$filter_name = $this->filter_name;
946
+		}
819 947
     		if ($globalDBdriver == 'mysql') {
820 948
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
821 949
 		} else {
@@ -833,7 +961,9 @@  discard block
 block discarded – undo
833 961
         }
834 962
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
835 963
     		global $globalArchiveMonths, $globalDBdriver;
836
-		if ($filter_name == '') $filter_name = $this->filter_name;
964
+		if ($filter_name == '') {
965
+			$filter_name = $this->filter_name;
966
+		}
837 967
     		if ($globalDBdriver == 'mysql') {
838 968
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
839 969
                 } else {
@@ -850,7 +980,9 @@  discard block
 block discarded – undo
850 980
         }
851 981
 	public function getStatsAirlineTotal($filter_name = '') {
852 982
     		global $globalArchiveMonths, $globalDBdriver;
853
-		if ($filter_name == '') $filter_name = $this->filter_name;
983
+		if ($filter_name == '') {
984
+			$filter_name = $this->filter_name;
985
+		}
854 986
     		if ($globalDBdriver == 'mysql') {
855 987
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
856 988
                 } else {
@@ -867,7 +999,9 @@  discard block
 block discarded – undo
867 999
         }
868 1000
 	public function getStatsOwnerTotal($filter_name = '') {
869 1001
     		global $globalArchiveMonths, $globalDBdriver;
870
-		if ($filter_name == '') $filter_name = $this->filter_name;
1002
+		if ($filter_name == '') {
1003
+			$filter_name = $this->filter_name;
1004
+		}
871 1005
     		if ($globalDBdriver == 'mysql') {
872 1006
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
873 1007
 		} else {
@@ -884,7 +1018,9 @@  discard block
 block discarded – undo
884 1018
         }
885 1019
 	public function getStatsPilotTotal($filter_name = '') {
886 1020
     		global $globalArchiveMonths, $globalDBdriver;
887
-		if ($filter_name == '') $filter_name = $this->filter_name;
1021
+		if ($filter_name == '') {
1022
+			$filter_name = $this->filter_name;
1023
+		}
888 1024
     		if ($globalDBdriver == 'mysql') {
889 1025
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
890 1026
             	} else {
@@ -902,7 +1038,9 @@  discard block
 block discarded – undo
902 1038
 
903 1039
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
904 1040
 		global $globalDBdriver;
905
-		if ($filter_name == '') $filter_name = $this->filter_name;
1041
+		if ($filter_name == '') {
1042
+			$filter_name = $this->filter_name;
1043
+		}
906 1044
 		if ($globalDBdriver == 'mysql') {
907 1045
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
908 1046
                 } else {
@@ -918,7 +1056,9 @@  discard block
 block discarded – undo
918 1056
         }
919 1057
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
920 1058
 		global $globalDBdriver;
921
-		if ($filter_name == '') $filter_name = $this->filter_name;
1059
+		if ($filter_name == '') {
1060
+			$filter_name = $this->filter_name;
1061
+		}
922 1062
 		if ($globalDBdriver == 'mysql') {
923 1063
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
924 1064
 		} else {
@@ -1401,47 +1541,69 @@  discard block
 block discarded – undo
1401 1541
 			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1402 1542
 		} else {
1403 1543
 		*/
1404
-			if ($globalDebug) echo 'Update stats !'."\n";
1405
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1544
+			if ($globalDebug) {
1545
+				echo 'Update stats !'."\n";
1546
+			}
1547
+			if ($globalDebug) {
1548
+				echo 'Count all aircraft types...'."\n";
1549
+			}
1406 1550
 			if (isset($last_update[0]['value'])) {
1407 1551
 				$last_update_day = $last_update[0]['value'];
1408
-			} else $last_update_day = '2012-12-12 12:12:12';
1552
+			} else {
1553
+				$last_update_day = '2012-12-12 12:12:12';
1554
+			}
1409 1555
 			$Spotter = new Spotter($this->db);
1410 1556
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1411 1557
 			foreach ($alldata as $number) {
1412 1558
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']);
1413 1559
 			}
1414
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1560
+			if ($globalDebug) {
1561
+				echo 'Count all airlines...'."\n";
1562
+			}
1415 1563
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1416 1564
 			foreach ($alldata as $number) {
1417 1565
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1418 1566
 			}
1419
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1567
+			if ($globalDebug) {
1568
+				echo 'Count all registrations...'."\n";
1569
+			}
1420 1570
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1421 1571
 			foreach ($alldata as $number) {
1422 1572
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1423 1573
 			}
1424
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1574
+			if ($globalDebug) {
1575
+				echo 'Count all callsigns...'."\n";
1576
+			}
1425 1577
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1426 1578
 			foreach ($alldata as $number) {
1427 1579
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1428 1580
 			}
1429
-			if ($globalDebug) echo 'Count all owners...'."\n";
1581
+			if ($globalDebug) {
1582
+				echo 'Count all owners...'."\n";
1583
+			}
1430 1584
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1431 1585
 			foreach ($alldata as $number) {
1432 1586
 				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1433 1587
 			}
1434
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1588
+			if ($globalDebug) {
1589
+				echo 'Count all pilots...'."\n";
1590
+			}
1435 1591
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1436 1592
 			foreach ($alldata as $number) {
1437 1593
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']);
1438 1594
 			}
1439 1595
 			
1440
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1596
+			if ($globalDebug) {
1597
+				echo 'Count all departure airports...'."\n";
1598
+			}
1441 1599
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1442
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1600
+			if ($globalDebug) {
1601
+				echo 'Count all detected departure airports...'."\n";
1602
+			}
1443 1603
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1444
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1604
+			if ($globalDebug) {
1605
+				echo 'Order departure airports...'."\n";
1606
+			}
1445 1607
 	        	$alldata = array();
1446 1608
 	        	
1447 1609
     			foreach ($pall as $value) {
@@ -1452,7 +1614,9 @@  discard block
 block discarded – undo
1452 1614
     				$icao = $value['airport_departure_icao'];
1453 1615
         			if (isset($alldata[$icao])) {
1454 1616
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1455
-        			} else $alldata[$icao] = $value;
1617
+        			} else {
1618
+        				$alldata[$icao] = $value;
1619
+        			}
1456 1620
 			}
1457 1621
     			$count = array();
1458 1622
     			foreach ($alldata as $key => $row) {
@@ -1462,11 +1626,17 @@  discard block
 block discarded – undo
1462 1626
 			foreach ($alldata as $number) {
1463 1627
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1464 1628
 			}
1465
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1629
+			if ($globalDebug) {
1630
+				echo 'Count all arrival airports...'."\n";
1631
+			}
1466 1632
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1467
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1633
+			if ($globalDebug) {
1634
+				echo 'Count all detected arrival airports...'."\n";
1635
+			}
1468 1636
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1469
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1637
+			if ($globalDebug) {
1638
+				echo 'Order arrival airports...'."\n";
1639
+			}
1470 1640
 	        	$alldata = array();
1471 1641
     			foreach ($pall as $value) {
1472 1642
 	        		$icao = $value['airport_arrival_icao'];
@@ -1476,7 +1646,9 @@  discard block
 block discarded – undo
1476 1646
     				$icao = $value['airport_arrival_icao'];
1477 1647
         			if (isset($alldata[$icao])) {
1478 1648
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1479
-	        		} else $alldata[$icao] = $value;
1649
+	        		} else {
1650
+	        			$alldata[$icao] = $value;
1651
+	        		}
1480 1652
     			}
1481 1653
         		$count = array();
1482 1654
         		foreach ($alldata as $key => $row) {
@@ -1487,7 +1659,9 @@  discard block
 block discarded – undo
1487 1659
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1488 1660
 			}
1489 1661
 			if ($Connection->tableExists('countries')) {
1490
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1662
+				if ($globalDebug) {
1663
+					echo 'Count all flights by countries...'."\n";
1664
+				}
1491 1665
 				$SpotterArchive = new SpotterArchive();
1492 1666
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1493 1667
 				foreach ($alldata as $number) {
@@ -1499,46 +1673,66 @@  discard block
 block discarded – undo
1499 1673
 			// Add by month using getstat if month finish...
1500 1674
 
1501 1675
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1502
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1676
+			if ($globalDebug) {
1677
+				echo 'Count all flights by months...'."\n";
1678
+			}
1503 1679
 			$Spotter = new Spotter($this->db);
1504 1680
 			$alldata = $Spotter->countAllMonths();
1505 1681
 			$lastyear = false;
1506 1682
 			foreach ($alldata as $number) {
1507
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1683
+				if ($number['year_name'] != date('Y')) {
1684
+					$lastyear = true;
1685
+				}
1508 1686
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1509 1687
 			}
1510
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1688
+			if ($globalDebug) {
1689
+				echo 'Count all military flights by months...'."\n";
1690
+			}
1511 1691
 			$alldata = $Spotter->countAllMilitaryMonths();
1512 1692
 			foreach ($alldata as $number) {
1513 1693
 				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1514 1694
 			}
1515
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1695
+			if ($globalDebug) {
1696
+				echo 'Count all owners by months...'."\n";
1697
+			}
1516 1698
 			$alldata = $Spotter->countAllMonthsOwners();
1517 1699
 			foreach ($alldata as $number) {
1518 1700
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1519 1701
 			}
1520
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1702
+			if ($globalDebug) {
1703
+				echo 'Count all pilots by months...'."\n";
1704
+			}
1521 1705
 			$alldata = $Spotter->countAllMonthsPilots();
1522 1706
 			foreach ($alldata as $number) {
1523 1707
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1524 1708
 			}
1525
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1709
+			if ($globalDebug) {
1710
+				echo 'Count all airlines by months...'."\n";
1711
+			}
1526 1712
 			$alldata = $Spotter->countAllMonthsAirlines();
1527 1713
 			foreach ($alldata as $number) {
1528 1714
 				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1529 1715
 			}
1530
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1716
+			if ($globalDebug) {
1717
+				echo 'Count all aircrafts by months...'."\n";
1718
+			}
1531 1719
 			$alldata = $Spotter->countAllMonthsAircrafts();
1532 1720
 			foreach ($alldata as $number) {
1533 1721
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1534 1722
 			}
1535
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1723
+			if ($globalDebug) {
1724
+				echo 'Count all real arrivals by months...'."\n";
1725
+			}
1536 1726
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1537 1727
 			foreach ($alldata as $number) {
1538 1728
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1539 1729
 			}
1540
-			if ($globalDebug) echo 'Airports data...'."\n";
1541
-			if ($globalDebug) echo '...Departure'."\n";
1730
+			if ($globalDebug) {
1731
+				echo 'Airports data...'."\n";
1732
+			}
1733
+			if ($globalDebug) {
1734
+				echo '...Departure'."\n";
1735
+			}
1542 1736
 			$this->deleteStatAirport('daily');
1543 1737
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1544 1738
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1658,37 +1852,53 @@  discard block
 block discarded – undo
1658 1852
 
1659 1853
 			// Count by airlines
1660 1854
 			echo '--- Stats by airlines ---'."\n";
1661
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1855
+			if ($globalDebug) {
1856
+				echo 'Count all aircraft types by airlines...'."\n";
1857
+			}
1662 1858
 			$Spotter = new Spotter($this->db);
1663 1859
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1664 1860
 			foreach ($alldata as $number) {
1665 1861
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']);
1666 1862
 			}
1667
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1863
+			if ($globalDebug) {
1864
+				echo 'Count all aircraft registrations by airlines...'."\n";
1865
+			}
1668 1866
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1669 1867
 			foreach ($alldata as $number) {
1670 1868
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']);
1671 1869
 			}
1672
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1870
+			if ($globalDebug) {
1871
+				echo 'Count all callsigns by airlines...'."\n";
1872
+			}
1673 1873
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1674 1874
 			foreach ($alldata as $number) {
1675 1875
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1676 1876
 			}
1677
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1877
+			if ($globalDebug) {
1878
+				echo 'Count all owners by airlines...'."\n";
1879
+			}
1678 1880
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1679 1881
 			foreach ($alldata as $number) {
1680 1882
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']);
1681 1883
 			}
1682
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1884
+			if ($globalDebug) {
1885
+				echo 'Count all pilots by airlines...'."\n";
1886
+			}
1683 1887
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1684 1888
 			foreach ($alldata as $number) {
1685 1889
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']);
1686 1890
 			}
1687
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1891
+			if ($globalDebug) {
1892
+				echo 'Count all departure airports by airlines...'."\n";
1893
+			}
1688 1894
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1689
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1895
+			if ($globalDebug) {
1896
+				echo 'Count all detected departure airports by airlines...'."\n";
1897
+			}
1690 1898
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1691
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1899
+			if ($globalDebug) {
1900
+				echo 'Order detected departure airports by airlines...'."\n";
1901
+			}
1692 1902
 	        	//$alldata = array();
1693 1903
     			foreach ($dall as $value) {
1694 1904
     				$icao = $value['airport_departure_icao'];
@@ -1709,11 +1919,17 @@  discard block
 block discarded – undo
1709 1919
 			foreach ($alldata as $number) {
1710 1920
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao']);
1711 1921
 			}
1712
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1922
+			if ($globalDebug) {
1923
+				echo 'Count all arrival airports by airlines...'."\n";
1924
+			}
1713 1925
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1714
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1926
+			if ($globalDebug) {
1927
+				echo 'Count all detected arrival airports by airlines...'."\n";
1928
+			}
1715 1929
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1716
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1930
+			if ($globalDebug) {
1931
+				echo 'Order arrival airports by airlines...'."\n";
1932
+			}
1717 1933
 	        	//$alldata = array();
1718 1934
     			foreach ($dall as $value) {
1719 1935
     				$icao = $value['airport_arrival_icao'];
@@ -1732,37 +1948,53 @@  discard block
 block discarded – undo
1732 1948
     			}
1733 1949
     			$alldata = $pall;
1734 1950
                         foreach ($alldata as $number) {
1735
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao']);
1951
+				if ($number['airline_icao'] != '') {
1952
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao']);
1953
+				}
1954
+			}
1955
+			if ($globalDebug) {
1956
+				echo 'Count all flights by months by airlines...'."\n";
1736 1957
 			}
1737
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1738 1958
 			$Spotter = new Spotter($this->db);
1739 1959
 			$alldata = $Spotter->countAllMonthsByAirlines();
1740 1960
 			$lastyear = false;
1741 1961
 			foreach ($alldata as $number) {
1742
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1962
+				if ($number['year_name'] != date('Y')) {
1963
+					$lastyear = true;
1964
+				}
1743 1965
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1744 1966
 			}
1745
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1967
+			if ($globalDebug) {
1968
+				echo 'Count all owners by months by airlines...'."\n";
1969
+			}
1746 1970
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1747 1971
 			foreach ($alldata as $number) {
1748 1972
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1749 1973
 			}
1750
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1974
+			if ($globalDebug) {
1975
+				echo 'Count all pilots by months by airlines...'."\n";
1976
+			}
1751 1977
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1752 1978
 			foreach ($alldata as $number) {
1753 1979
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1754 1980
 			}
1755
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1981
+			if ($globalDebug) {
1982
+				echo 'Count all aircrafts by months by airlines...'."\n";
1983
+			}
1756 1984
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1757 1985
 			foreach ($alldata as $number) {
1758 1986
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1759 1987
 			}
1760
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1988
+			if ($globalDebug) {
1989
+				echo 'Count all real arrivals by months by airlines...'."\n";
1990
+			}
1761 1991
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1762 1992
 			foreach ($alldata as $number) {
1763 1993
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1764 1994
 			}
1765
-			if ($globalDebug) echo '...Departure'."\n";
1995
+			if ($globalDebug) {
1996
+				echo '...Departure'."\n";
1997
+			}
1766 1998
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1767 1999
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1768 2000
     			foreach ($dall as $value) {
@@ -1785,7 +2017,9 @@  discard block
 block discarded – undo
1785 2017
 			foreach ($alldata as $number) {
1786 2018
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1787 2019
 			}
1788
-			if ($globalDebug) echo '...Arrival'."\n";
2020
+			if ($globalDebug) {
2021
+				echo '...Arrival'."\n";
2022
+			}
1789 2023
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1790 2024
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1791 2025
     			foreach ($dall as $value) {
@@ -1809,13 +2043,19 @@  discard block
 block discarded – undo
1809 2043
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1810 2044
 			}
1811 2045
 
1812
-			if ($globalDebug) echo 'Flights data...'."\n";
1813
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2046
+			if ($globalDebug) {
2047
+				echo 'Flights data...'."\n";
2048
+			}
2049
+			if ($globalDebug) {
2050
+				echo '-> countAllDatesLastMonth...'."\n";
2051
+			}
1814 2052
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1815 2053
 			foreach ($alldata as $number) {
1816 2054
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1817 2055
 			}
1818
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2056
+			if ($globalDebug) {
2057
+				echo '-> countAllDates...'."\n";
2058
+			}
1819 2059
 			//$previousdata = $this->countAllDatesByAirlines();
1820 2060
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1821 2061
 			$values = array();
@@ -1828,14 +2068,18 @@  discard block
 block discarded – undo
1828 2068
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1829 2069
 			}
1830 2070
 			
1831
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2071
+			if ($globalDebug) {
2072
+				echo '-> countAllHours...'."\n";
2073
+			}
1832 2074
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1833 2075
 			foreach ($alldata as $number) {
1834 2076
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1835 2077
 			}
1836 2078
 			
1837 2079
 
1838
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2080
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2081
+				$globalStatsFilters = array();
2082
+			}
1839 2083
 			foreach ($globalStatsFilters as $name => $filter) {
1840 2084
 				//$filter_name = $filter['name'];
1841 2085
 				$filter_name = $name;
@@ -1843,10 +2087,14 @@  discard block
 block discarded – undo
1843 2087
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1844 2088
 				if (isset($last_update[0]['value'])) {
1845 2089
 					$last_update_day = $last_update[0]['value'];
1846
-				} else $last_update_day = '2012-12-12 12:12:12';
2090
+				} else {
2091
+					$last_update_day = '2012-12-12 12:12:12';
2092
+				}
1847 2093
 
1848 2094
 				// Count by filter
1849
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2095
+				if ($globalDebug) {
2096
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2097
+				}
1850 2098
 				$Spotter = new Spotter($this->db);
1851 2099
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1852 2100
 				foreach ($alldata as $number) {
@@ -1883,7 +2131,9 @@  discard block
 block discarded – undo
1883 2131
 	    				$icao = $value['airport_departure_icao'];
1884 2132
         				if (isset($alldata[$icao])) {
1885 2133
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1886
-        				} else $alldata[$icao] = $value;
2134
+        				} else {
2135
+        					$alldata[$icao] = $value;
2136
+        				}
1887 2137
 				}
1888 2138
 	    			$count = array();
1889 2139
     				foreach ($alldata as $key => $row) {
@@ -1904,7 +2154,9 @@  discard block
 block discarded – undo
1904 2154
 	    				$icao = $value['airport_arrival_icao'];
1905 2155
         				if (isset($alldata[$icao])) {
1906 2156
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1907
-		        		} else $alldata[$icao] = $value;
2157
+		        		} else {
2158
+		        			$alldata[$icao] = $value;
2159
+		        		}
1908 2160
 	    			}
1909 2161
         			$count = array();
1910 2162
         			foreach ($alldata as $key => $row) {
@@ -1918,7 +2170,9 @@  discard block
 block discarded – undo
1918 2170
 				$alldata = $Spotter->countAllMonths($filter);
1919 2171
 				$lastyear = false;
1920 2172
 				foreach ($alldata as $number) {
1921
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2173
+					if ($number['year_name'] != date('Y')) {
2174
+						$lastyear = true;
2175
+					}
1922 2176
 					$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1923 2177
 				}
1924 2178
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.
scripts/update_db.php 1 patch
Braces   +22 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -29,14 +31,18 @@  discard block
 block discarded – undo
29 31
 			$update_db->update_notam();
30 32
 		}
31 33
 		$update_db->insert_last_notam_update();
32
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
34
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
35
+		echo "NOTAM are only updated once a day.\n";
36
+	}
33 37
 	if ($update_db->check_last_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
34 38
 		$update_db->update_all();
35 39
 	//	require_once(dirname(__FILE__).'/../require/class.Spotter.php');
36 40
 	//	$Spotter = new Spotter();
37 41
 	//	$Spotter->updateFieldsFromOtherTables();
38 42
 		$update_db->insert_last_update();
39
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
43
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
44
+		echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
45
+	}
40 46
 	if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) {
41 47
 		echo "Check if new airspace version exist...";
42 48
 		echo $update_db->update_airspace_fam();
@@ -51,7 +57,9 @@  discard block
 block discarded – undo
51 57
 			$update_db->delete_duplicateowner();
52 58
 		}
53 59
 		$update_db->insert_last_owner_update();
54
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
60
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
61
+		echo "Owner are only updated every 15 days.\n";
62
+	}
55 63
 
56 64
 	if (isset($globalAccidents) && $globalAccidents && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
57 65
 		require_once(dirname(__FILE__).'/../require/class.Accident.php');
@@ -60,7 +68,9 @@  discard block
 block discarded – undo
60 68
 		if ($Accident->check_last_accidents_update()) {
61 69
 			$Accident->download_update();
62 70
 			$Accident->insert_last_accidents_update();
63
-		} else echo "Accidents are updated once a day.\n";
71
+		} else {
72
+			echo "Accidents are updated once a day.\n";
73
+		}
64 74
 	}
65 75
 
66 76
 }
@@ -73,15 +83,19 @@  discard block
 block discarded – undo
73 83
 	if ($METAR->check_last_update()) {
74 84
 		$METAR->addMETARCycle();
75 85
 		$METAR->insert_last_update();
76
-	} else echo "METAR are only updated every 30 minutes.\n";
77
-}
86
+	} else {
87
+		echo "METAR are only updated every 30 minutes.\n";
88
+	}
89
+	}
78 90
 
79 91
 if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
80 92
 	echo "Updating schedules...";
81 93
 	//$update_db->update_oneworld();
82 94
 	$update_db->update_skyteam();
83 95
 	$update_db->insert_last_schedules_update();
84
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
96
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
97
+	echo "Schedules are only updated every 15 days.\n";
98
+}
85 99
 
86 100
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
87 101
 	echo "Updating statistics and archive old data...";
Please login to merge, or discard this patch.
accident.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
-if ($date == '') $date = date('Y-m-d');
3
+if ($date == '') {
4
+	$date = date('Y-m-d');
5
+}
4 6
 header('Location: '.$globalURL.'/accident/'.$date);
5 7
 ?>
6 8
\ No newline at end of file
Please login to merge, or discard this patch.
date.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
-if ($date == '') $date = date('Y-m-d');
3
+if ($date == '') {
4
+	$date = date('Y-m-d');
5
+}
4 6
 header('Location: '.$globalURL.'/date/'.$date);
5 7
 ?>
6 8
\ No newline at end of file
Please login to merge, or discard this patch.