Completed
Push — master ( 553331...19ae00 )
by Yannick
07:35
created
pilot-detailed.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@  discard block
 block discarded – undo
6 6
 //require_once('require/class.SpotterLive.php');
7 7
 require_once('require/class.SpotterArchive.php');
8 8
 
9
-if (!isset($_GET['pilot'])){
9
+if (!isset($_GET['pilot'])) {
10 10
 	header('Location: '.$globalURL.'/');
11 11
 } else {
12 12
 	$Spotter = new Spotter();
13 13
 	$SpotterArchive = new SpotterArchive();
14 14
 	$Translation = new Translation();
15 15
 	//calculuation for the pagination
16
-	if(!isset($_GET['limit']))
16
+	if (!isset($_GET['limit']))
17 17
 	{
18 18
 		$limit_start = 0;
19 19
 		$limit_end = 25;
@@ -34,29 +34,29 @@  discard block
 block discarded – undo
34 34
 	
35 35
 	$page_url = $globalURL.'/pilot/'.$_GET['pilot'];
36 36
 	
37
-	$pilot = filter_input(INPUT_GET,'pilot',FILTER_SANITIZE_STRING);
38
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
39
-	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
40
-	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
37
+	$pilot = filter_input(INPUT_GET, 'pilot', FILTER_SANITIZE_STRING);
38
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
39
+	$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
40
+	$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
41 41
 	$filter = array();
42
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
43
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
42
+	if ($year != '') $filter = array_merge($filter, array('year' => $year));
43
+	if ($month != '') $filter = array_merge($filter, array('month' => $month));
44 44
 	if ($sort != '') 
45 45
 	{
46
-		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
46
+		$spotter_array = $Spotter->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, $sort, $filter);
47 47
 		if (empty($spotter_array)) {
48
-			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
48
+			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, $sort, $filter);
49 49
 		}
50 50
 	} else {
51
-		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference,'',$filter);
51
+		$spotter_array = $Spotter->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, '', $filter);
52 52
 		if (empty($spotter_array)) {
53
-			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference,'',$filter);
53
+			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, '', $filter);
54 54
 		}
55 55
 	}
56 56
 
57 57
 	if (!empty($spotter_array))
58 58
 	{
59
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
59
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['pilot_name']);
60 60
 		$ident = $spotter_array[0]['ident'];
61 61
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
62 62
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -117,23 +117,23 @@  discard block
 block discarded – undo
117 117
 			$Stats = new Stats();
118 118
 			$flights = $Stats->getStatsPilot($pilot);
119 119
 		} else $flights = 0;
120
-		if ($flight == 0) $flights = $Spotter->countFlightsByPilot($pilot,$filter);
120
+		if ($flight == 0) $flights = $Spotter->countFlightsByPilot($pilot, $filter);
121 121
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
122
-		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot,$filter));
122
+		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot, $filter));
123 123
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
124
-		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByPilot($pilot,$filter));
124
+		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByPilot($pilot, $filter));
125 125
 		print '<div><span class="label">'._("Aircrafts").'</span>'.$aircraft_registration.'</div>';
126
-		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByPilot($pilot,$filter));
126
+		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByPilot($pilot, $filter));
127 127
 		print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
128
-		$airlines = count($Spotter->countAllAirlinesByPilot($pilot,$filter));
128
+		$airlines = count($Spotter->countAllAirlinesByPilot($pilot, $filter));
129 129
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
130
-		$duration = $Spotter->getFlightDurationByPilot($pilot,$filter);
130
+		$duration = $Spotter->getFlightDurationByPilot($pilot, $filter);
131 131
 		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
132 132
 		print '</div>';
133 133
 	
134 134
 		include('owner-sub-menu.php');
135 135
 		print '<div class="table column">';
136
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the pilot <strong>%s</strong>."),$spotter_array[0]['pilot_name']).'</p>';
136
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the pilot <strong>%s</strong>."), $spotter_array[0]['pilot_name']).'</p>';
137 137
 
138 138
 		include('table-output.php'); 
139 139
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,8 +39,12 @@  discard block
 block discarded – undo
39 39
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
40 40
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
41 41
 	$filter = array();
42
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
43
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
42
+	if ($year != '') {
43
+		$filter = array_merge($filter,array('year' => $year));
44
+	}
45
+	if ($month != '') {
46
+		$filter = array_merge($filter,array('month' => $month));
47
+	}
44 48
 	if ($sort != '') 
45 49
 	{
46 50
 		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -58,8 +62,12 @@  discard block
 block discarded – undo
58 62
 	{
59 63
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
60 64
 		$ident = $spotter_array[0]['ident'];
61
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
62
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
65
+		if (isset($spotter_array[0]['latitude'])) {
66
+			$latitude = $spotter_array[0]['latitude'];
67
+		}
68
+		if (isset($spotter_array[0]['longitude'])) {
69
+			$longitude = $spotter_array[0]['longitude'];
70
+		}
63 71
 		require_once('header.php');
64 72
 		/*
65 73
 		if (isset($globalArchive) && $globalArchive) {
@@ -112,12 +120,18 @@  discard block
 block discarded – undo
112 120
 		*/
113 121
 		print '<div class="info column">';
114 122
 		print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>';
115
-		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
123
+		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') {
124
+			print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
125
+		}
116 126
 		if ($year == '' && $month == '') {
117 127
 			$Stats = new Stats();
118 128
 			$flights = $Stats->getStatsPilot($pilot);
119
-		} else $flights = 0;
120
-		if ($flight == 0) $flights = $Spotter->countFlightsByPilot($pilot,$filter);
129
+		} else {
130
+			$flights = 0;
131
+		}
132
+		if ($flight == 0) {
133
+			$flights = $Spotter->countFlightsByPilot($pilot,$filter);
134
+		}
121 135
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
122 136
 		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot,$filter));
123 137
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
@@ -128,7 +142,9 @@  discard block
 block discarded – undo
128 142
 		$airlines = count($Spotter->countAllAirlinesByPilot($pilot,$filter));
129 143
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
130 144
 		$duration = $Spotter->getFlightDurationByPilot($pilot,$filter);
131
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
145
+		if ($duration != '0') {
146
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
147
+		}
132 148
 		print '</div>';
133 149
 	
134 150
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.
owner-detailed.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 //require_once('require/class.SpotterLive.php');
8 8
 require_once('require/class.SpotterArchive.php');
9 9
 
10
-if (!isset($_GET['owner'])){
10
+if (!isset($_GET['owner'])) {
11 11
 	header('Location: '.$globalURL.'');
12 12
 } else {
13 13
 	$Spotter = new Spotter();
14 14
 	$SpotterArchive = new SpotterArchive();
15 15
 	//$Translation = new Translation();
16 16
 	//calculuation for the pagination
17
-	if(!isset($_GET['limit']))
17
+	if (!isset($_GET['limit']))
18 18
 	{
19 19
 		$limit_start = 0;
20 20
 		$limit_end = 25;
@@ -35,29 +35,29 @@  discard block
 block discarded – undo
35 35
 	
36 36
 	$page_url = $globalURL.'/owner/'.$_GET['owner'];
37 37
 	
38
-	$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
39
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
40
-	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
41
-	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
38
+	$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
39
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
40
+	$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
41
+	$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
42 42
 	$filter = array();
43
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
44
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
43
+	if ($year != '') $filter = array_merge($filter, array('year' => $year));
44
+	if ($month != '') $filter = array_merge($filter, array('month' => $month));
45 45
 	if ($sort != '') 
46 46
 	{
47
-		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
47
+		$spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
48 48
 		if (empty($spotter_array)) {
49
-			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
49
+			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
50 50
 		}
51 51
 	} else {
52
-		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter);
52
+		$spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter);
53 53
 		if (empty($spotter_array)) {
54
-			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter);
54
+			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter);
55 55
 		}
56 56
 	}
57 57
 
58 58
 	if (!empty($spotter_array))
59 59
 	{
60
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
60
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['aircraft_owner']);
61 61
 		//$ident = $spotter_array[0]['ident'];
62 62
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
63 63
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -117,23 +117,23 @@  discard block
 block discarded – undo
117 117
 		$Stats = new Stats();
118 118
 		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
119 119
 		else $flights = 0;
120
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
120
+		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner, $filter);
121 121
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
122
-		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
122
+		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner, $filter));
123 123
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
124
-		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner,$filter));
124
+		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner, $filter));
125 125
 		print '<div><span class="label">'._("Aircrafts").'</span>'.$aircraft_registration.'</div>';
126
-		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner,$filter));
126
+		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner, $filter));
127 127
 		print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
128
-		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
128
+		$airlines = count($Spotter->countAllAirlinesByOwner($owner, $filter));
129 129
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
130
-		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
130
+		$duration = $Spotter->getFlightDurationByOwner($owner, $filter);
131 131
 		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
132 132
 		print '</div>';
133 133
 	
134 134
 		include('owner-sub-menu.php');
135 135
 		print '<div class="table column">';
136
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
136
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
137 137
 
138 138
 		include('table-output.php'); 
139 139
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,8 +40,12 @@  discard block
 block discarded – undo
40 40
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
41 41
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
42 42
 	$filter = array();
43
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
44
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
43
+	if ($year != '') {
44
+		$filter = array_merge($filter,array('year' => $year));
45
+	}
46
+	if ($month != '') {
47
+		$filter = array_merge($filter,array('month' => $month));
48
+	}
45 49
 	if ($sort != '') 
46 50
 	{
47 51
 		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -59,8 +63,12 @@  discard block
 block discarded – undo
59 63
 	{
60 64
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
61 65
 		//$ident = $spotter_array[0]['ident'];
62
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
63
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
66
+		if (isset($spotter_array[0]['latitude'])) {
67
+			$latitude = $spotter_array[0]['latitude'];
68
+		}
69
+		if (isset($spotter_array[0]['longitude'])) {
70
+			$longitude = $spotter_array[0]['longitude'];
71
+		}
64 72
 		require_once('header.php');
65 73
 		/*
66 74
 		if (isset($globalArchive) && $globalArchive) {
@@ -115,9 +123,14 @@  discard block
 block discarded – undo
115 123
 		print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
116 124
 		//print '<div><span class="label">'._("Owner").'</span>'.$spotter_array[0]['aircraft_owner'].'</div>';
117 125
 		$Stats = new Stats();
118
-		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
119
-		else $flights = 0;
120
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
126
+		if ($year == '' && $month == '') {
127
+			$flights = $Stats->getStatsOwner($owner);
128
+		} else {
129
+			$flights = 0;
130
+		}
131
+		if ($flights == 0) {
132
+			$flights = $Spotter->countFlightsByOwner($owner,$filter);
133
+		}
121 134
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
122 135
 		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
123 136
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
@@ -128,7 +141,9 @@  discard block
 block discarded – undo
128 141
 		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
129 142
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
130 143
 		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
131
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
144
+		if ($duration != '0') {
145
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
146
+		}
132 147
 		print '</div>';
133 148
 	
134 149
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.
require/class.APRS.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -84,6 +84,10 @@
 block discarded – undo
84 84
 	'y' => 'Yagi At QTH');
85 85
 	
86 86
 
87
+    /**
88
+     * @param integer $n
89
+     * @param integer $s
90
+     */
87 91
     private function urshift($n, $s) {
88 92
 	return ($n >= 0) ? ($n >> $s) :
89 93
     	    (($n & 0x7fffffff) >> $s) | 
Please login to merge, or discard this patch.
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class aprs {
3
-    protected $symbols = array('!' => 'Police',
3
+	protected $symbols = array('!' => 'Police',
4 4
 	'#' => 'DIGI',
5 5
 	'$' => 'Phone',
6 6
 	'%' => 'DX Cluster',
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
 	'y' => 'Yagi At QTH');
85 85
 	
86 86
 
87
-    private function urshift($n, $s) {
87
+	private function urshift($n, $s) {
88 88
 	return ($n >= 0) ? ($n >> $s) :
89
-    	    (($n & 0x7fffffff) >> $s) | 
90
-        	(0x40000000 >> ($s - 1));
91
-    }
89
+			(($n & 0x7fffffff) >> $s) | 
90
+			(0x40000000 >> ($s - 1));
91
+	}
92 92
 
93
-    public function parse($input) {
93
+	public function parse($input) {
94 94
 	global $globalDebug;
95 95
 	$debug = false;
96 96
 	$result = array();
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	
103 103
 	/* Check that end was found and body has at least one byte. */
104 104
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
105
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
106
-	    return false;
105
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
106
+		return false;
107 107
 	}
108 108
 	
109 109
 	/* Save header and body. */
@@ -116,23 +116,23 @@  discard block
 block discarded – undo
116 116
 	/* Parse source, target and path. */
117 117
 	//FLRDF0A52>APRS,qAS,LSTB
118 118
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
119
-	    $ident = $matches[1];
120
-	    $all_elements = $matches[2];
121
-	    if ($debug) echo 'ident : '.$ident."\n";
122
-	    $result['ident'] = $ident;
119
+		$ident = $matches[1];
120
+		$all_elements = $matches[2];
121
+		if ($debug) echo 'ident : '.$ident."\n";
122
+		$result['ident'] = $ident;
123 123
 	} else return false;
124 124
 	$elements = explode(',',$all_elements);
125 125
 	$source = end($elements);
126 126
 	$result['source'] = $source;
127 127
 	foreach ($elements as $element) {
128
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
129
-	        //echo "ok";
130
-	        //if ($element == 'TCPIP*') return false;
131
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
128
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
129
+			//echo "ok";
130
+			//if ($element == 'TCPIP*') return false;
131
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
132 132
 		echo 'element : '.$element."\n";
133 133
 		return false;
134
-	    }
135
-	    /*
134
+		}
135
+		/*
136 136
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
137 137
 		//echo "ok";
138 138
 	    } else {
@@ -145,49 +145,49 @@  discard block
 block discarded – undo
145 145
 	$body_parse = substr($body,1);
146 146
 	//echo 'Body : '.$body."\n";
147 147
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
148
-	    $body_parse = substr($body_parse,10);
149
-	    $find = true;
150
-	    //echo $body_parse."\n";
148
+		$body_parse = substr($body_parse,10);
149
+		$find = true;
150
+		//echo $body_parse."\n";
151 151
 	}
152 152
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
153
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
154
-	    $find = true;
155
-	    //echo $body_parse."\n";
153
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
154
+		$find = true;
155
+		//echo $body_parse."\n";
156 156
 	}
157 157
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
158
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
159
-	    $find = true;
160
-	    //echo $body_parse."\n";
158
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
159
+		$find = true;
160
+		//echo $body_parse."\n";
161 161
 	}
162 162
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
163
-	    $find = true;
164
-	    //print_r($matches);
165
-	    $timestamp = $matches[0];
166
-	    if ($matches[4] == 'h') {
163
+		$find = true;
164
+		//print_r($matches);
165
+		$timestamp = $matches[0];
166
+		if ($matches[4] == 'h') {
167 167
 		$timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]);
168 168
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
169 169
 		/*
170 170
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
171 171
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
172 172
 		*/
173
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
173
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
174 174
 		// This work or not ?
175 175
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
176
-	    }
177
-	    $body_parse = substr($body_parse,7);
178
-	    $result['timestamp'] = $timestamp;
179
-	    //echo date('Ymd H:i:s',$timestamp);
176
+		}
177
+		$body_parse = substr($body_parse,7);
178
+		$result['timestamp'] = $timestamp;
179
+		//echo date('Ymd H:i:s',$timestamp);
180 180
 	}
181 181
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
182
-	    $find = true;
183
-	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
184
-	    $body_parse = substr($body_parse,8);
185
-	    $result['timestamp'] = $timestamp;
186
-	    //echo date('Ymd H:i:s',$timestamp);
182
+		$find = true;
183
+		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
184
+		$body_parse = substr($body_parse,8);
185
+		$result['timestamp'] = $timestamp;
186
+		//echo date('Ymd H:i:s',$timestamp);
187 187
 	}
188 188
 	//if (strlen($body_parse) > 19) {
189
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
190
-	    $find = true;
189
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
190
+		$find = true;
191 191
 		// 4658.70N/00707.78Ez
192 192
 		//print_r(str_split($body_parse));
193 193
 		
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		$lon = intval($lon_deg);
205 205
 		if ($lat > 89 || $lon > 179) return false;
206 206
 	    
207
-	    /*
207
+		/*
208 208
 	    $tmp_5b = str_replace('.','',$lat_min);
209 209
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
210 210
 	        print_r($matches);
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 		$result['longitude'] = $longitude;
219 219
 		$body_parse = substr($body_parse,18);
220 220
 		$body_parse_len = strlen($body_parse);
221
-	    }
222
-	    $body_parse_len = strlen($body_parse);
223
-	    if ($body_parse_len > 0) {
221
+		}
222
+		$body_parse_len = strlen($body_parse);
223
+		if ($body_parse_len > 0) {
224 224
 		/*
225 225
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
226 226
 			$body_split = str_split($body);
@@ -247,61 +247,61 @@  discard block
 block discarded – undo
247 247
 			$result['symbol_code'] = $symbol_code;
248 248
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
249 249
 			if ($symbol_code != '_') {
250
-		    //$body_parse = substr($body_parse,1);
251
-		    //$body_parse = trim($body_parse);
252
-		    //$body_parse_len = strlen($body_parse);
253
-		    if ($body_parse_len >= 7) {
250
+			//$body_parse = substr($body_parse,1);
251
+			//$body_parse = trim($body_parse);
252
+			//$body_parse_len = strlen($body_parse);
253
+			if ($body_parse_len >= 7) {
254 254
 			
255
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
256
-		    	    $course = substr($body_parse,0,3);
257
-		    	    $tmp_s = intval($course);
258
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
259
-		    	    $speed = substr($body_parse,4,3);
260
-		    	    $result['speed'] = round($speed*1.852);
261
-		    	    $body_parse = substr($body_parse,7);
262
-		        }
263
-		        // Check PHGR, PHG, RNG
264
-		    } 
265
-		    /*
255
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
256
+					$course = substr($body_parse,0,3);
257
+					$tmp_s = intval($course);
258
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
259
+					$speed = substr($body_parse,4,3);
260
+					$result['speed'] = round($speed*1.852);
261
+					$body_parse = substr($body_parse,7);
262
+				}
263
+				// Check PHGR, PHG, RNG
264
+			} 
265
+			/*
266 266
 		    else if ($body_parse_len > 0) {
267 267
 			$rest = $body_parse;
268 268
 		    }
269 269
 		    */
270
-		    if (strlen($body_parse) > 0) {
271
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
272
-		            $altitude = intval($matches[1]);
273
-		            //$result['altitude'] = round($altitude*0.3048);
274
-		            $result['altitude'] = $altitude;
275
-		            $body_parse = trim(substr($body_parse,strlen($matches[0])));
276
-		        }
277
-		    }
270
+			if (strlen($body_parse) > 0) {
271
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
272
+					$altitude = intval($matches[1]);
273
+					//$result['altitude'] = round($altitude*0.3048);
274
+					$result['altitude'] = $altitude;
275
+					$body_parse = trim(substr($body_parse,strlen($matches[0])));
276
+				}
277
+			}
278 278
 		    
279
-		    // Telemetry
280
-		    /*
279
+			// Telemetry
280
+			/*
281 281
 		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
282 282
 		        // Nothing yet...
283 283
 		    }
284 284
 		    */
285
-		    // DAO
286
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
287
-			    $dao = $matches[1];
288
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
285
+			// DAO
286
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
287
+				$dao = $matches[1];
288
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
289 289
 				$dao_split = str_split($dao);
290
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
291
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
290
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
291
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
292 292
 			    
293 293
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
294 294
 				else $result['latitude'] += $lat_off;
295 295
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
296 296
 				else $result['longitude'] += $lon_off;
297
-			    }
298
-		            $body_parse = substr($body_parse,6);
299
-		    }
297
+				}
298
+					$body_parse = substr($body_parse,6);
299
+			}
300 300
 		    
301
-		    // OGN comment
301
+			// OGN comment
302 302
 		   // echo "Before OGN : ".$body_parse."\n";
303
-		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
304
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
303
+			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
304
+			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
305 305
 			$id = $matches[1];
306 306
 			//$mode = substr($id,0,2);
307 307
 			$address = substr($id,2);
@@ -331,51 +331,51 @@  discard block
 block discarded – undo
331 331
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
332 332
 			$result['stealth'] = $stealth;
333 333
 			$result['address'] = $address;
334
-		    }
334
+			}
335 335
 		    
336
-		    //Comment
337
-		    $result['comment'] = trim($body_parse);
336
+			//Comment
337
+			$result['comment'] = trim($body_parse);
338 338
 		} else {
339
-		    // parse weather
340
-		    //$body_parse = substr($body_parse,1);
341
-		    //$body_parse_len = strlen($body_parse);
339
+			// parse weather
340
+			//$body_parse = substr($body_parse,1);
341
+			//$body_parse_len = strlen($body_parse);
342 342
 
343
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
344
-			    $result['wind_dir'] = intval($matches[1]);
345
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
346
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
347
-			    $result['temp'] = round(5/9*(($matches[4])-32),1);
348
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
349
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
343
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
344
+				$result['wind_dir'] = intval($matches[1]);
345
+				$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
346
+				$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
347
+				$result['temp'] = round(5/9*(($matches[4])-32),1);
348
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
349
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
350 350
 			$result['wind_dir'] = intval($matches[1]);
351 351
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
352 352
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
353 353
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
354
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
355
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
354
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
355
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
356 356
 			$result['wind_dir'] = intval($matches[1]);
357 357
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
358 358
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
359
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
360
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
359
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
360
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
361 361
 			$result['wind_dir'] = intval($matches[1]);
362 362
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
363 363
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
364
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
365
-		    }
366
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
364
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
365
+			}
366
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
367 367
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
368
-		    }
368
+			}
369 369
 		}
370 370
 		} else $result['comment'] = trim($body_parse);
371 371
 
372
-	    }
372
+		}
373 373
 	//}
374 374
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
375 375
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
376 376
 	//print_r($result);
377 377
 	return $result;
378
-    }
378
+	}
379 379
 }
380 380
 /*
381 381
 $aprs = new aprs();
Please login to merge, or discard this patch.
Spacing   +62 added lines, -63 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@  discard block
 block discarded – undo
85 85
 	
86 86
 
87 87
     private function urshift($n, $s) {
88
-	return ($n >= 0) ? ($n >> $s) :
89
-    	    (($n & 0x7fffffff) >> $s) | 
88
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
90 89
         	(0x40000000 >> ($s - 1));
91 90
     }
92 91
 
@@ -98,7 +97,7 @@  discard block
 block discarded – undo
98 97
 	//$split_input = str_split($input);
99 98
 
100 99
 	/* Find the end of header checking for NULL bytes while doing it. */
101
-	$splitpos = strpos($input,':');
100
+	$splitpos = strpos($input, ':');
102 101
 	
103 102
 	/* Check that end was found and body has at least one byte. */
104 103
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -107,28 +106,28 @@  discard block
 block discarded – undo
107 106
 	}
108 107
 	
109 108
 	/* Save header and body. */
110
-	$body = substr($input,$splitpos+1,$input_len);
109
+	$body = substr($input, $splitpos + 1, $input_len);
111 110
 	$body_len = strlen($body);
112
-	$header = substr($input,0,$splitpos);
111
+	$header = substr($input, 0, $splitpos);
113 112
 	//$header_len = strlen($header);
114 113
 	if ($debug) echo 'header : '.$header."\n";
115 114
 	
116 115
 	/* Parse source, target and path. */
117 116
 	//FLRDF0A52>APRS,qAS,LSTB
118
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
117
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
119 118
 	    $ident = $matches[1];
120 119
 	    $all_elements = $matches[2];
121 120
 	    if ($debug) echo 'ident : '.$ident."\n";
122 121
 	    $result['ident'] = $ident;
123 122
 	} else return false;
124
-	$elements = explode(',',$all_elements);
123
+	$elements = explode(',', $all_elements);
125 124
 	$source = end($elements);
126 125
 	$result['source'] = $source;
127 126
 	foreach ($elements as $element) {
128
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
127
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
129 128
 	        //echo "ok";
130 129
 	        //if ($element == 'TCPIP*') return false;
131
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
130
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
132 131
 		echo 'element : '.$element."\n";
133 132
 		return false;
134 133
 	    }
@@ -142,24 +141,24 @@  discard block
 block discarded – undo
142 141
 	}
143 142
 	// Check for Timestamp
144 143
 	$find = false;
145
-	$body_parse = substr($body,1);
144
+	$body_parse = substr($body, 1);
146 145
 	//echo 'Body : '.$body."\n";
147
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
148
-	    $body_parse = substr($body_parse,10);
146
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
147
+	    $body_parse = substr($body_parse, 10);
149 148
 	    $find = true;
150 149
 	    //echo $body_parse."\n";
151 150
 	}
152
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
153
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
151
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
152
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
154 153
 	    $find = true;
155 154
 	    //echo $body_parse."\n";
156 155
 	}
157
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
158
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
156
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
157
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
159 158
 	    $find = true;
160 159
 	    //echo $body_parse."\n";
161 160
 	}
162
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
161
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
163 162
 	    $find = true;
164 163
 	    //print_r($matches);
165 164
 	    $timestamp = $matches[0];
@@ -174,19 +173,19 @@  discard block
 block discarded – undo
174 173
 		// This work or not ?
175 174
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
176 175
 	    }
177
-	    $body_parse = substr($body_parse,7);
176
+	    $body_parse = substr($body_parse, 7);
178 177
 	    $result['timestamp'] = $timestamp;
179 178
 	    //echo date('Ymd H:i:s',$timestamp);
180 179
 	}
181
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
180
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
182 181
 	    $find = true;
183 182
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
184
-	    $body_parse = substr($body_parse,8);
183
+	    $body_parse = substr($body_parse, 8);
185 184
 	    $result['timestamp'] = $timestamp;
186 185
 	    //echo date('Ymd H:i:s',$timestamp);
187 186
 	}
188 187
 	//if (strlen($body_parse) > 19) {
189
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
188
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
190 189
 	    $find = true;
191 190
 		// 4658.70N/00707.78Ez
192 191
 		//print_r(str_split($body_parse));
@@ -212,11 +211,11 @@  discard block
 block discarded – undo
212 211
 	    */
213 212
 		$latitude = $lat + floatval($lat_min)/60;
214 213
 		$longitude = $lon + floatval($lon_min)/60;
215
-		if ($sind == 'S') $latitude = 0-$latitude;
216
-		if ($wind == 'W') $longitude = 0-$longitude;
214
+		if ($sind == 'S') $latitude = 0 - $latitude;
215
+		if ($wind == 'W') $longitude = 0 - $longitude;
217 216
 		$result['latitude'] = $latitude;
218 217
 		$result['longitude'] = $longitude;
219
-		$body_parse = substr($body_parse,18);
218
+		$body_parse = substr($body_parse, 18);
220 219
 		$body_parse_len = strlen($body_parse);
221 220
 	    }
222 221
 	    $body_parse_len = strlen($body_parse);
@@ -240,7 +239,7 @@  discard block
 block discarded – undo
240 239
 		if ($find) {
241 240
 			$body_split = str_split($body_parse);
242 241
 			$symbol_code = $body_split[0];
243
-			$body_parse = substr($body_parse,1);
242
+			$body_parse = substr($body_parse, 1);
244 243
 			$body_parse_len = strlen($body_parse);
245 244
 		//}
246 245
 		//echo $body_parse;
@@ -252,13 +251,13 @@  discard block
 block discarded – undo
252 251
 		    //$body_parse_len = strlen($body_parse);
253 252
 		    if ($body_parse_len >= 7) {
254 253
 			
255
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
256
-		    	    $course = substr($body_parse,0,3);
254
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
255
+		    	    $course = substr($body_parse, 0, 3);
257 256
 		    	    $tmp_s = intval($course);
258 257
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
259
-		    	    $speed = substr($body_parse,4,3);
258
+		    	    $speed = substr($body_parse, 4, 3);
260 259
 		    	    $result['speed'] = round($speed*1.852);
261
-		    	    $body_parse = substr($body_parse,7);
260
+		    	    $body_parse = substr($body_parse, 7);
262 261
 		        }
263 262
 		        // Check PHGR, PHG, RNG
264 263
 		    } 
@@ -268,11 +267,11 @@  discard block
 block discarded – undo
268 267
 		    }
269 268
 		    */
270 269
 		    if (strlen($body_parse) > 0) {
271
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
270
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
272 271
 		            $altitude = intval($matches[1]);
273 272
 		            //$result['altitude'] = round($altitude*0.3048);
274 273
 		            $result['altitude'] = $altitude;
275
-		            $body_parse = trim(substr($body_parse,strlen($matches[0])));
274
+		            $body_parse = trim(substr($body_parse, strlen($matches[0])));
276 275
 		        }
277 276
 		    }
278 277
 		    
@@ -283,35 +282,35 @@  discard block
 block discarded – undo
283 282
 		    }
284 283
 		    */
285 284
 		    // DAO
286
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
285
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
287 286
 			    $dao = $matches[1];
288
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
287
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
289 288
 				$dao_split = str_split($dao);
290
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
291
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
289
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
290
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
292 291
 			    
293 292
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
294 293
 				else $result['latitude'] += $lat_off;
295 294
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
296 295
 				else $result['longitude'] += $lon_off;
297 296
 			    }
298
-		            $body_parse = substr($body_parse,6);
297
+		            $body_parse = substr($body_parse, 6);
299 298
 		    }
300 299
 		    
301 300
 		    // OGN comment
302 301
 		   // echo "Before OGN : ".$body_parse."\n";
303 302
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
304
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
303
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
305 304
 			$id = $matches[1];
306 305
 			//$mode = substr($id,0,2);
307
-			$address = substr($id,2);
306
+			$address = substr($id, 2);
308 307
 			//print_r($matches);
309
-			$addressType = (intval(substr($id,0,2),16))&3;
308
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
310 309
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
311 310
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
312 311
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
313 312
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
314
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
313
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
315 314
 			$result['aircrafttype_code'] = $aircraftType;
316 315
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
317 316
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -328,7 +327,7 @@  discard block
 block discarded – undo
328 327
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
329 328
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
330 329
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
331
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
330
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
332 331
 			$result['stealth'] = $stealth;
333 332
 			$result['address'] = $address;
334 333
 		    }
@@ -340,39 +339,39 @@  discard block
 block discarded – undo
340 339
 		    //$body_parse = substr($body_parse,1);
341 340
 		    //$body_parse_len = strlen($body_parse);
342 341
 
343
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
342
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
344 343
 			    $result['wind_dir'] = intval($matches[1]);
345
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
346
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
347
-			    $result['temp'] = round(5/9*(($matches[4])-32),1);
348
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
349
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
344
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
345
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
346
+			    $result['temp'] = round(5/9*(($matches[4]) - 32), 1);
347
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
348
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
350 349
 			$result['wind_dir'] = intval($matches[1]);
351
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
352
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
353
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
354
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
355
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
350
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
351
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
352
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
353
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
354
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
356 355
 			$result['wind_dir'] = intval($matches[1]);
357
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
358
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
359
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
360
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
356
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
357
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
358
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
359
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
361 360
 			$result['wind_dir'] = intval($matches[1]);
362
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
363
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
364
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
361
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
362
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
363
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
365 364
 		    }
366
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
367
-			$result['temp'] = round(5/9*(($matches[1])-32),1);
365
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) {
366
+			$result['temp'] = round(5/9*(($matches[1]) - 32), 1);
368 367
 		    }
369 368
 		}
370 369
 		} else $result['comment'] = trim($body_parse);
371 370
 
372 371
 	    }
373 372
 	//}
374
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
375
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
373
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
374
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
376 375
 	//print_r($result);
377 376
 	return $result;
378 377
     }
Please login to merge, or discard this patch.
Braces   +86 added lines, -35 removed lines patch added patch discarded remove patch
@@ -102,7 +102,9 @@  discard block
 block discarded – undo
102 102
 	
103 103
 	/* Check that end was found and body has at least one byte. */
104 104
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
105
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
105
+	    if ($globalDebug) {
106
+	    	echo '!!! APRS invalid : '.$input."\n";
107
+	    }
106 108
 	    return false;
107 109
 	}
108 110
 	
@@ -111,16 +113,22 @@  discard block
 block discarded – undo
111 113
 	$body_len = strlen($body);
112 114
 	$header = substr($input,0,$splitpos);
113 115
 	//$header_len = strlen($header);
114
-	if ($debug) echo 'header : '.$header."\n";
116
+	if ($debug) {
117
+		echo 'header : '.$header."\n";
118
+	}
115 119
 	
116 120
 	/* Parse source, target and path. */
117 121
 	//FLRDF0A52>APRS,qAS,LSTB
118 122
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
119 123
 	    $ident = $matches[1];
120 124
 	    $all_elements = $matches[2];
121
-	    if ($debug) echo 'ident : '.$ident."\n";
125
+	    if ($debug) {
126
+	    	echo 'ident : '.$ident."\n";
127
+	    }
122 128
 	    $result['ident'] = $ident;
123
-	} else return false;
129
+	} else {
130
+		return false;
131
+	}
124 132
 	$elements = explode(',',$all_elements);
125 133
 	$source = end($elements);
126 134
 	$result['source'] = $source;
@@ -202,7 +210,9 @@  discard block
 block discarded – undo
202 210
 		//$symbol_table = $matches[4];
203 211
 		$lat = intval($lat_deg);
204 212
 		$lon = intval($lon_deg);
205
-		if ($lat > 89 || $lon > 179) return false;
213
+		if ($lat > 89 || $lon > 179) {
214
+			return false;
215
+		}
206 216
 	    
207 217
 	    /*
208 218
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -212,8 +222,12 @@  discard block
 block discarded – undo
212 222
 	    */
213 223
 		$latitude = $lat + floatval($lat_min)/60;
214 224
 		$longitude = $lon + floatval($lon_min)/60;
215
-		if ($sind == 'S') $latitude = 0-$latitude;
216
-		if ($wind == 'W') $longitude = 0-$longitude;
225
+		if ($sind == 'S') {
226
+			$latitude = 0-$latitude;
227
+		}
228
+		if ($wind == 'W') {
229
+			$longitude = 0-$longitude;
230
+		}
217 231
 		$result['latitude'] = $latitude;
218 232
 		$result['longitude'] = $longitude;
219 233
 		$body_parse = substr($body_parse,18);
@@ -245,7 +259,9 @@  discard block
 block discarded – undo
245 259
 		//}
246 260
 		//echo $body_parse;
247 261
 			$result['symbol_code'] = $symbol_code;
248
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
262
+			if (isset($this->symbols[$symbol_code])) {
263
+				$result['symbol'] = $this->symbols[$symbol_code];
264
+			}
249 265
 			if ($symbol_code != '_') {
250 266
 		    //$body_parse = substr($body_parse,1);
251 267
 		    //$body_parse = trim($body_parse);
@@ -255,7 +271,9 @@  discard block
 block discarded – undo
255 271
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
256 272
 		    	    $course = substr($body_parse,0,3);
257 273
 		    	    $tmp_s = intval($course);
258
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
274
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
275
+		    	    	$result['heading'] = intval($course);
276
+		    	    }
259 277
 		    	    $speed = substr($body_parse,4,3);
260 278
 		    	    $result['speed'] = round($speed*1.852);
261 279
 		    	    $body_parse = substr($body_parse,7);
@@ -290,10 +308,16 @@  discard block
 block discarded – undo
290 308
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
291 309
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
292 310
 			    
293
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
294
-				else $result['latitude'] += $lat_off;
295
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
296
-				else $result['longitude'] += $lon_off;
311
+				if ($result['latitude'] < 0) {
312
+					$result['latitude'] -= $lat_off;
313
+				} else {
314
+					$result['latitude'] += $lat_off;
315
+				}
316
+				if ($result['longitude'] < 0) {
317
+					$result['longitude'] -= $lon_off;
318
+				} else {
319
+					$result['longitude'] += $lon_off;
320
+				}
297 321
 			    }
298 322
 		            $body_parse = substr($body_parse,6);
299 323
 		    }
@@ -307,27 +331,48 @@  discard block
 block discarded – undo
307 331
 			$address = substr($id,2);
308 332
 			//print_r($matches);
309 333
 			$addressType = (intval(substr($id,0,2),16))&3;
310
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
311
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
312
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
313
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
334
+			if ($addressType == 0) {
335
+				$result['addresstype'] = "RANDOM";
336
+			} elseif ($addressType == 1) {
337
+				$result['addresstype'] = "ICAO";
338
+			} elseif ($addressType == 2) {
339
+				$result['addresstype'] = "FLARM";
340
+			} elseif ($addressType == 3) {
341
+				$result['addresstype'] = "OGN";
342
+			}
314 343
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
315 344
 			$result['aircrafttype_code'] = $aircraftType;
316
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
317
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
318
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
319
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
320
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
321
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
322
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
323
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
324
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
325
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
326
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
327
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
328
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
329
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
330
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
345
+			if ($aircraftType == 0) {
346
+				$result['aircrafttype'] = "UNKNOWN";
347
+			} elseif ($aircraftType == 1) {
348
+				$result['aircrafttype'] = "GLIDER";
349
+			} elseif ($aircraftType == 2) {
350
+				$result['aircrafttype'] = "TOW_PLANE";
351
+			} elseif ($aircraftType == 3) {
352
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
353
+			} elseif ($aircraftType == 4) {
354
+				$result['aircrafttype'] = "PARACHUTE";
355
+			} elseif ($aircraftType == 5) {
356
+				$result['aircrafttype'] = "DROP_PLANE";
357
+			} elseif ($aircraftType == 6) {
358
+				$result['aircrafttype'] = "HANG_GLIDER";
359
+			} elseif ($aircraftType == 7) {
360
+				$result['aircrafttype'] = "PARA_GLIDER";
361
+			} elseif ($aircraftType == 8) {
362
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
363
+			} elseif ($aircraftType == 9) {
364
+				$result['aircrafttype'] = "JET_AIRCRAFT";
365
+			} elseif ($aircraftType == 10) {
366
+				$result['aircrafttype'] = "UFO";
367
+			} elseif ($aircraftType == 11) {
368
+				$result['aircrafttype'] = "BALLOON";
369
+			} elseif ($aircraftType == 12) {
370
+				$result['aircrafttype'] = "AIRSHIP";
371
+			} elseif ($aircraftType == 13) {
372
+				$result['aircrafttype'] = "UAV";
373
+			} elseif ($aircraftType == 15) {
374
+				$result['aircrafttype'] = "STATIC_OBJECT";
375
+			}
331 376
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
332 377
 			$result['stealth'] = $stealth;
333 378
 			$result['address'] = $address;
@@ -367,12 +412,18 @@  discard block
 block discarded – undo
367 412
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
368 413
 		    }
369 414
 		}
370
-		} else $result['comment'] = trim($body_parse);
415
+		} else {
416
+			$result['comment'] = trim($body_parse);
417
+		}
371 418
 
372 419
 	    }
373 420
 	//}
374
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
375
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
421
+	if (isset($result['latitude'])) {
422
+		$result['latitude'] = round($result['latitude'],4);
423
+	}
424
+	if (isset($result['longitude'])) {
425
+		$result['longitude'] = round($result['longitude'],4);
426
+	}
376 427
 	//print_r($result);
377 428
 	return $result;
378 429
     }
Please login to merge, or discard this patch.
install/class.update_schema.php 3 patches
Indentation   +603 added lines, -603 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
15
+				$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+			} catch(PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19
-    	    }
20
-    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
-    	    }
19
+			}
20
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
+			$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
183
+					$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+				} catch(PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
+				$query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
251
+					$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+				} catch(PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
277
+			$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+				} catch(PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
381
-    		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
381
+			$Connection = new Connection();
382
+			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412
-    		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
412
+			$Connection = new Connection();
413
+			$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
416
+			$sth->execute();
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+				} catch(PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443
-            	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
-            	    }
446
-                } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
443
+					} else {
444
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
+					}
446
+				} else {
447
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
497
-    		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
497
+			$Connection = new Connection();
498
+			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
+				$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+				} catch(PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505
-    			}
505
+				}
506 506
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
-    			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
+				$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
664
+				$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
674
+				$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 682
 		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
684
+				$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
694
+				$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 			} catch(PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179
-                }
1179
+				}
1180 1180
 		if (!$Connection->checkColumnName('aircraft','mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 			} catch(PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253
-                }
1253
+				}
1254 1254
 		if (!$Connection->indexExists('accidents','registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 			} catch(PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263
-                }
1263
+				}
1264 1264
 		if (!$Connection->indexExists('accidents','rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			} catch(PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273
-                }
1273
+				}
1274 1274
 
1275 1275
 		$query = "UPDATE config SET value = '31' WHERE name = 'schema_version'";
1276 1276
 		try {
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 			} catch(PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565
-                }
1565
+				}
1566 1566
 		$query = "UPDATE config SET value = '36' WHERE name = 'schema_version'";
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
@@ -1574,169 +1574,169 @@  discard block
 block discarded – undo
1574 1574
 	}
1575 1575
 
1576 1576
 
1577
-    	public static function check_version($update = false) {
1578
-    	    global $globalDBname;
1579
-    	    $version = 0;
1580
-    	    $Connection = new Connection();
1581
-    	    if ($Connection->tableExists('aircraft')) {
1582
-    		if (!$Connection->tableExists('config')) {
1583
-    		    $version = '1';
1584
-    		    if ($update) return self::update_from_1();
1585
-    		    else return $version;
1577
+		public static function check_version($update = false) {
1578
+			global $globalDBname;
1579
+			$version = 0;
1580
+			$Connection = new Connection();
1581
+			if ($Connection->tableExists('aircraft')) {
1582
+			if (!$Connection->tableExists('config')) {
1583
+				$version = '1';
1584
+				if ($update) return self::update_from_1();
1585
+				else return $version;
1586 1586
 		} else {
1587
-    		    $Connection = new Connection();
1588
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1589
-		    try {
1590
-            		$sth = $Connection->db->prepare($query);
1591
-		        $sth->execute();
1592
-		    } catch(PDOException $e) {
1587
+				$Connection = new Connection();
1588
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1589
+			try {
1590
+					$sth = $Connection->db->prepare($query);
1591
+				$sth->execute();
1592
+			} catch(PDOException $e) {
1593 1593
 			return "error : ".$e->getMessage()."\n";
1594
-    		    }
1595
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
1596
-    		    if ($update) {
1597
-    			if ($result['value'] == '2') {
1598
-    			    $error = self::update_from_2();
1599
-    			    if ($error != '') return $error;
1600
-    			    else return self::check_version(true);
1601
-    			} elseif ($result['value'] == '3') {
1602
-    			    $error = self::update_from_3();
1603
-    			    if ($error != '') return $error;
1604
-    			    else return self::check_version(true);
1605
-    			} elseif ($result['value'] == '4') {
1606
-    			    $error = self::update_from_4();
1607
-    			    if ($error != '') return $error;
1608
-    			    else return self::check_version(true);
1609
-    			} elseif ($result['value'] == '5') {
1610
-    			    $error = self::update_from_5();
1611
-    			    if ($error != '') return $error;
1612
-    			    else return self::check_version(true);
1613
-    			} elseif ($result['value'] == '6') {
1614
-    			    $error = self::update_from_6();
1615
-    			    if ($error != '') return $error;
1616
-    			    else return self::check_version(true);
1617
-    			} elseif ($result['value'] == '7') {
1618
-    			    $error = self::update_from_7();
1619
-    			    if ($error != '') return $error;
1620
-    			    else return self::check_version(true);
1621
-    			} elseif ($result['value'] == '8') {
1622
-    			    $error = self::update_from_8();
1623
-    			    if ($error != '') return $error;
1624
-    			    else return self::check_version(true);
1625
-    			} elseif ($result['value'] == '9') {
1626
-    			    $error = self::update_from_9();
1627
-    			    if ($error != '') return $error;
1628
-    			    else return self::check_version(true);
1629
-    			} elseif ($result['value'] == '10') {
1630
-    			    $error = self::update_from_10();
1631
-    			    if ($error != '') return $error;
1632
-    			    else return self::check_version(true);
1633
-    			} elseif ($result['value'] == '11') {
1634
-    			    $error = self::update_from_11();
1635
-    			    if ($error != '') return $error;
1636
-    			    else return self::check_version(true);
1637
-    			} elseif ($result['value'] == '12') {
1638
-    			    $error = self::update_from_12();
1639
-    			    if ($error != '') return $error;
1640
-    			    else return self::check_version(true);
1641
-    			} elseif ($result['value'] == '13') {
1642
-    			    $error = self::update_from_13();
1643
-    			    if ($error != '') return $error;
1644
-    			    else return self::check_version(true);
1645
-    			} elseif ($result['value'] == '14') {
1646
-    			    $error = self::update_from_14();
1647
-    			    if ($error != '') return $error;
1648
-    			    else return self::check_version(true);
1649
-    			} elseif ($result['value'] == '15') {
1650
-    			    $error = self::update_from_15();
1651
-    			    if ($error != '') return $error;
1652
-    			    else return self::check_version(true);
1653
-    			} elseif ($result['value'] == '16') {
1654
-    			    $error = self::update_from_16();
1655
-    			    if ($error != '') return $error;
1656
-    			    else return self::check_version(true);
1657
-    			} elseif ($result['value'] == '17') {
1658
-    			    $error = self::update_from_17();
1659
-    			    if ($error != '') return $error;
1660
-    			    else return self::check_version(true);
1661
-    			} elseif ($result['value'] == '18') {
1662
-    			    $error = self::update_from_18();
1663
-    			    if ($error != '') return $error;
1664
-    			    else return self::check_version(true);
1665
-    			} elseif ($result['value'] == '19') {
1666
-    			    $error = self::update_from_19();
1667
-    			    if ($error != '') return $error;
1668
-    			    else return self::check_version(true);
1669
-    			} elseif ($result['value'] == '20') {
1670
-    			    $error = self::update_from_20();
1671
-    			    if ($error != '') return $error;
1672
-    			    else return self::check_version(true);
1673
-    			} elseif ($result['value'] == '21') {
1674
-    			    $error = self::update_from_21();
1675
-    			    if ($error != '') return $error;
1676
-    			    else return self::check_version(true);
1677
-    			} elseif ($result['value'] == '22') {
1678
-    			    $error = self::update_from_22();
1679
-    			    if ($error != '') return $error;
1680
-    			    else return self::check_version(true);
1681
-    			} elseif ($result['value'] == '23') {
1682
-    			    $error = self::update_from_23();
1683
-    			    if ($error != '') return $error;
1684
-    			    else return self::check_version(true);
1685
-    			} elseif ($result['value'] == '24') {
1686
-    			    $error = self::update_from_24();
1687
-    			    if ($error != '') return $error;
1688
-    			    else return self::check_version(true);
1689
-    			} elseif ($result['value'] == '25') {
1690
-    			    $error = self::update_from_25();
1691
-    			    if ($error != '') return $error;
1692
-    			    else return self::check_version(true);
1693
-    			} elseif ($result['value'] == '26') {
1694
-    			    $error = self::update_from_26();
1695
-    			    if ($error != '') return $error;
1696
-    			    else return self::check_version(true);
1697
-    			} elseif ($result['value'] == '27') {
1698
-    			    $error = self::update_from_27();
1699
-    			    if ($error != '') return $error;
1700
-    			    else return self::check_version(true);
1701
-    			} elseif ($result['value'] == '28') {
1702
-    			    $error = self::update_from_28();
1703
-    			    if ($error != '') return $error;
1704
-    			    else return self::check_version(true);
1705
-    			} elseif ($result['value'] == '29') {
1706
-    			    $error = self::update_from_29();
1707
-    			    if ($error != '') return $error;
1708
-    			    else return self::check_version(true);
1709
-    			} elseif ($result['value'] == '30') {
1710
-    			    $error = self::update_from_30();
1711
-    			    if ($error != '') return $error;
1712
-    			    else return self::check_version(true);
1713
-    			} elseif ($result['value'] == '31') {
1714
-    			    $error = self::update_from_31();
1715
-    			    if ($error != '') return $error;
1716
-    			    else return self::check_version(true);
1717
-    			} elseif ($result['value'] == '32') {
1718
-    			    $error = self::update_from_32();
1719
-    			    if ($error != '') return $error;
1720
-    			    else return self::check_version(true);
1721
-    			} elseif ($result['value'] == '33') {
1722
-    			    $error = self::update_from_33();
1723
-    			    if ($error != '') return $error;
1724
-    			    else return self::check_version(true);
1725
-    			} elseif ($result['value'] == '34') {
1726
-    			    $error = self::update_from_34();
1727
-    			    if ($error != '') return $error;
1728
-    			    else return self::check_version(true);
1729
-    			} elseif ($result['value'] == '35') {
1730
-    			    $error = self::update_from_35();
1731
-    			    if ($error != '') return $error;
1732
-    			    else return self::check_version(true);
1733
-    			} else return '';
1734
-    		    }
1735
-    		    else return $result['value'];
1594
+				}
1595
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
1596
+				if ($update) {
1597
+				if ($result['value'] == '2') {
1598
+					$error = self::update_from_2();
1599
+					if ($error != '') return $error;
1600
+					else return self::check_version(true);
1601
+				} elseif ($result['value'] == '3') {
1602
+					$error = self::update_from_3();
1603
+					if ($error != '') return $error;
1604
+					else return self::check_version(true);
1605
+				} elseif ($result['value'] == '4') {
1606
+					$error = self::update_from_4();
1607
+					if ($error != '') return $error;
1608
+					else return self::check_version(true);
1609
+				} elseif ($result['value'] == '5') {
1610
+					$error = self::update_from_5();
1611
+					if ($error != '') return $error;
1612
+					else return self::check_version(true);
1613
+				} elseif ($result['value'] == '6') {
1614
+					$error = self::update_from_6();
1615
+					if ($error != '') return $error;
1616
+					else return self::check_version(true);
1617
+				} elseif ($result['value'] == '7') {
1618
+					$error = self::update_from_7();
1619
+					if ($error != '') return $error;
1620
+					else return self::check_version(true);
1621
+				} elseif ($result['value'] == '8') {
1622
+					$error = self::update_from_8();
1623
+					if ($error != '') return $error;
1624
+					else return self::check_version(true);
1625
+				} elseif ($result['value'] == '9') {
1626
+					$error = self::update_from_9();
1627
+					if ($error != '') return $error;
1628
+					else return self::check_version(true);
1629
+				} elseif ($result['value'] == '10') {
1630
+					$error = self::update_from_10();
1631
+					if ($error != '') return $error;
1632
+					else return self::check_version(true);
1633
+				} elseif ($result['value'] == '11') {
1634
+					$error = self::update_from_11();
1635
+					if ($error != '') return $error;
1636
+					else return self::check_version(true);
1637
+				} elseif ($result['value'] == '12') {
1638
+					$error = self::update_from_12();
1639
+					if ($error != '') return $error;
1640
+					else return self::check_version(true);
1641
+				} elseif ($result['value'] == '13') {
1642
+					$error = self::update_from_13();
1643
+					if ($error != '') return $error;
1644
+					else return self::check_version(true);
1645
+				} elseif ($result['value'] == '14') {
1646
+					$error = self::update_from_14();
1647
+					if ($error != '') return $error;
1648
+					else return self::check_version(true);
1649
+				} elseif ($result['value'] == '15') {
1650
+					$error = self::update_from_15();
1651
+					if ($error != '') return $error;
1652
+					else return self::check_version(true);
1653
+				} elseif ($result['value'] == '16') {
1654
+					$error = self::update_from_16();
1655
+					if ($error != '') return $error;
1656
+					else return self::check_version(true);
1657
+				} elseif ($result['value'] == '17') {
1658
+					$error = self::update_from_17();
1659
+					if ($error != '') return $error;
1660
+					else return self::check_version(true);
1661
+				} elseif ($result['value'] == '18') {
1662
+					$error = self::update_from_18();
1663
+					if ($error != '') return $error;
1664
+					else return self::check_version(true);
1665
+				} elseif ($result['value'] == '19') {
1666
+					$error = self::update_from_19();
1667
+					if ($error != '') return $error;
1668
+					else return self::check_version(true);
1669
+				} elseif ($result['value'] == '20') {
1670
+					$error = self::update_from_20();
1671
+					if ($error != '') return $error;
1672
+					else return self::check_version(true);
1673
+				} elseif ($result['value'] == '21') {
1674
+					$error = self::update_from_21();
1675
+					if ($error != '') return $error;
1676
+					else return self::check_version(true);
1677
+				} elseif ($result['value'] == '22') {
1678
+					$error = self::update_from_22();
1679
+					if ($error != '') return $error;
1680
+					else return self::check_version(true);
1681
+				} elseif ($result['value'] == '23') {
1682
+					$error = self::update_from_23();
1683
+					if ($error != '') return $error;
1684
+					else return self::check_version(true);
1685
+				} elseif ($result['value'] == '24') {
1686
+					$error = self::update_from_24();
1687
+					if ($error != '') return $error;
1688
+					else return self::check_version(true);
1689
+				} elseif ($result['value'] == '25') {
1690
+					$error = self::update_from_25();
1691
+					if ($error != '') return $error;
1692
+					else return self::check_version(true);
1693
+				} elseif ($result['value'] == '26') {
1694
+					$error = self::update_from_26();
1695
+					if ($error != '') return $error;
1696
+					else return self::check_version(true);
1697
+				} elseif ($result['value'] == '27') {
1698
+					$error = self::update_from_27();
1699
+					if ($error != '') return $error;
1700
+					else return self::check_version(true);
1701
+				} elseif ($result['value'] == '28') {
1702
+					$error = self::update_from_28();
1703
+					if ($error != '') return $error;
1704
+					else return self::check_version(true);
1705
+				} elseif ($result['value'] == '29') {
1706
+					$error = self::update_from_29();
1707
+					if ($error != '') return $error;
1708
+					else return self::check_version(true);
1709
+				} elseif ($result['value'] == '30') {
1710
+					$error = self::update_from_30();
1711
+					if ($error != '') return $error;
1712
+					else return self::check_version(true);
1713
+				} elseif ($result['value'] == '31') {
1714
+					$error = self::update_from_31();
1715
+					if ($error != '') return $error;
1716
+					else return self::check_version(true);
1717
+				} elseif ($result['value'] == '32') {
1718
+					$error = self::update_from_32();
1719
+					if ($error != '') return $error;
1720
+					else return self::check_version(true);
1721
+				} elseif ($result['value'] == '33') {
1722
+					$error = self::update_from_33();
1723
+					if ($error != '') return $error;
1724
+					else return self::check_version(true);
1725
+				} elseif ($result['value'] == '34') {
1726
+					$error = self::update_from_34();
1727
+					if ($error != '') return $error;
1728
+					else return self::check_version(true);
1729
+				} elseif ($result['value'] == '35') {
1730
+					$error = self::update_from_35();
1731
+					if ($error != '') return $error;
1732
+					else return self::check_version(true);
1733
+				} else return '';
1734
+				}
1735
+				else return $result['value'];
1736 1736
 		}
1737 1737
 		
1738
-	    } else return $version;
1739
-    	}
1738
+		} else return $version;
1739
+		}
1740 1740
     	
1741 1741
 }
1742 1742
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
Spacing   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -815,17 +815,17 @@  discard block
 block discarded – undo
815 815
 			try {
816 816
 				$sth = $Connection->db->prepare($query);
817 817
 				$sth->execute();
818
-			} catch(PDOException $e) {
818
+			} catch (PDOException $e) {
819 819
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
820 820
 			}
821 821
 		}
822
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
822
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824 824
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828
-			} catch(PDOException $e) {
828
+			} catch (PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830 830
     			}
831 831
     		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		try {
835 835
 			$sth = $Connection->db->prepare($query);
836 836
 			$sth->execute();
837
-		} catch(PDOException $e) {
837
+		} catch (PDOException $e) {
838 838
 			return "error (update schema_version) : ".$e->getMessage()."\n";
839 839
 		}
840 840
 		return $error;
@@ -850,23 +850,23 @@  discard block
 block discarded – undo
850 850
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 851
 		}
852 852
 		if ($error != '') return 'Import airlines.sql : '.$error;
853
-		if (!$Connection->checkColumnName('airlines','forsource')) {
853
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
854 854
 			// Add forsource to airlines
855 855
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
856 856
 			try {
857 857
 				$sth = $Connection->db->prepare($query);
858 858
 				$sth->execute();
859
-			} catch(PDOException $e) {
859
+			} catch (PDOException $e) {
860 860
 				return "error (add forsource column) : ".$e->getMessage()."\n";
861 861
 			}
862 862
 		}
863
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
863
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
864 864
 			// Add forsource to airlines
865 865
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
866 866
 			try {
867 867
 				$sth = $Connection->db->prepare($query);
868 868
 				$sth->execute();
869
-			} catch(PDOException $e) {
869
+			} catch (PDOException $e) {
870 870
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
871 871
 			}
872 872
 			// Add unique key
@@ -878,17 +878,17 @@  discard block
 block discarded – undo
878 878
 			try {
879 879
 				$sth = $Connection->db->prepare($query);
880 880
 				$sth->execute();
881
-			} catch(PDOException $e) {
881
+			} catch (PDOException $e) {
882 882
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
883 883
 			}
884 884
 		}
885
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
885
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
886 886
 			// Add forsource to airlines
887 887
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
888 888
 			try {
889 889
 				$sth = $Connection->db->prepare($query);
890 890
 				$sth->execute();
891
-			} catch(PDOException $e) {
891
+			} catch (PDOException $e) {
892 892
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
893 893
 			}
894 894
 			// Add unique key
@@ -900,17 +900,17 @@  discard block
 block discarded – undo
900 900
 			try {
901 901
 				$sth = $Connection->db->prepare($query);
902 902
 				$sth->execute();
903
-			} catch(PDOException $e) {
903
+			} catch (PDOException $e) {
904 904
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
905 905
 			}
906 906
 		}
907
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
907
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
908 908
 			// Add forsource to airlines
909 909
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
910 910
 			try {
911 911
 				$sth = $Connection->db->prepare($query);
912 912
 				$sth->execute();
913
-			} catch(PDOException $e) {
913
+			} catch (PDOException $e) {
914 914
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
915 915
 			}
916 916
 			// Add unique key
@@ -922,36 +922,36 @@  discard block
 block discarded – undo
922 922
 			try {
923 923
 				$sth = $Connection->db->prepare($query);
924 924
 				$sth->execute();
925
-			} catch(PDOException $e) {
925
+			} catch (PDOException $e) {
926 926
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
927 927
 			}
928 928
 		}
929
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
929
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
930 930
 			// Add forsource to airlines
931 931
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
932 932
 			try {
933 933
 				$sth = $Connection->db->prepare($query);
934 934
 				$sth->execute();
935
-			} catch(PDOException $e) {
935
+			} catch (PDOException $e) {
936 936
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
937 937
 			}
938 938
 		}
939
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
939
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
940 940
 			// Add forsource to airlines
941 941
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
942 942
 			try {
943 943
 				$sth = $Connection->db->prepare($query);
944 944
 				$sth->execute();
945
-			} catch(PDOException $e) {
945
+			} catch (PDOException $e) {
946 946
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
947 947
 			}
948
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
948
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
949 949
 				// Add unique key
950 950
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
951 951
 				try {
952 952
 					$sth = $Connection->db->prepare($query);
953 953
 					$sth->execute();
954
-				} catch(PDOException $e) {
954
+				} catch (PDOException $e) {
955 955
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
956 956
 				}
957 957
 			} else {
@@ -964,18 +964,18 @@  discard block
 block discarded – undo
964 964
 				try {
965 965
 					$sth = $Connection->db->prepare($query);
966 966
 					$sth->execute();
967
-				} catch(PDOException $e) {
967
+				} catch (PDOException $e) {
968 968
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
969 969
 				}
970 970
 			}
971 971
 		}
972
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
972
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
973 973
 			// Add forsource to airlines
974 974
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
975 975
 			try {
976 976
 				$sth = $Connection->db->prepare($query);
977 977
 				$sth->execute();
978
-			} catch(PDOException $e) {
978
+			} catch (PDOException $e) {
979 979
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
980 980
 			}
981 981
 			// Add unique key
@@ -987,17 +987,17 @@  discard block
 block discarded – undo
987 987
 			try {
988 988
 				$sth = $Connection->db->prepare($query);
989 989
 				$sth->execute();
990
-			} catch(PDOException $e) {
990
+			} catch (PDOException $e) {
991 991
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
992 992
 			}
993 993
 		}
994
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
994
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
995 995
 			// Add forsource to airlines
996 996
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
997 997
 			try {
998 998
 				$sth = $Connection->db->prepare($query);
999 999
 				$sth->execute();
1000
-			} catch(PDOException $e) {
1000
+			} catch (PDOException $e) {
1001 1001
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1002 1002
 			}
1003 1003
 			// Add unique key
@@ -1009,17 +1009,17 @@  discard block
 block discarded – undo
1009 1009
 			try {
1010 1010
 				$sth = $Connection->db->prepare($query);
1011 1011
 				$sth->execute();
1012
-			} catch(PDOException $e) {
1012
+			} catch (PDOException $e) {
1013 1013
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1014 1014
 			}
1015 1015
 		}
1016
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1016
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1017 1017
 			// Add forsource to airlines
1018 1018
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1019 1019
 			try {
1020 1020
 				$sth = $Connection->db->prepare($query);
1021 1021
 				$sth->execute();
1022
-			} catch(PDOException $e) {
1022
+			} catch (PDOException $e) {
1023 1023
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1024 1024
 			}
1025 1025
 			// Add unique key
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 			try {
1032 1032
 				$sth = $Connection->db->prepare($query);
1033 1033
 				$sth->execute();
1034
-			} catch(PDOException $e) {
1034
+			} catch (PDOException $e) {
1035 1035
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1036 1036
 			}
1037 1037
 		}
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		try {
1041 1041
 			$sth = $Connection->db->prepare($query);
1042 1042
 			$sth->execute();
1043
-		} catch(PDOException $e) {
1043
+		} catch (PDOException $e) {
1044 1044
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1045 1045
 		}
1046 1046
 		return $error;
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 		global $globalDBdriver;
1051 1051
 		$Connection = new Connection();
1052 1052
 		$error = '';
1053
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1053
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1054 1054
 			// Add forsource to airlines
1055 1055
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1056 1056
 			try {
1057 1057
 				$sth = $Connection->db->prepare($query);
1058 1058
 				$sth->execute();
1059
-			} catch(PDOException $e) {
1059
+			} catch (PDOException $e) {
1060 1060
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1061 1061
 			}
1062 1062
 			// Add unique key
@@ -1068,17 +1068,17 @@  discard block
 block discarded – undo
1068 1068
 			try {
1069 1069
 				$sth = $Connection->db->prepare($query);
1070 1070
 				$sth->execute();
1071
-			} catch(PDOException $e) {
1071
+			} catch (PDOException $e) {
1072 1072
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1073 1073
 			}
1074 1074
 		}
1075
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1075
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1076 1076
 			// Add forsource to airlines
1077 1077
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1078 1078
 			try {
1079 1079
 				$sth = $Connection->db->prepare($query);
1080 1080
 				$sth->execute();
1081
-			} catch(PDOException $e) {
1081
+			} catch (PDOException $e) {
1082 1082
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1083 1083
 			}
1084 1084
 			// Add unique key
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			try {
1091 1091
 				$sth = $Connection->db->prepare($query);
1092 1092
 				$sth->execute();
1093
-			} catch(PDOException $e) {
1093
+			} catch (PDOException $e) {
1094 1094
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1095 1095
 			}
1096 1096
 		}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		try {
1099 1099
 			$sth = $Connection->db->prepare($query);
1100 1100
 			$sth->execute();
1101
-		} catch(PDOException $e) {
1101
+		} catch (PDOException $e) {
1102 1102
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1103 1103
 		}
1104 1104
 		return $error;
@@ -1108,12 +1108,12 @@  discard block
 block discarded – undo
1108 1108
 		global $globalDBdriver;
1109 1109
 		$Connection = new Connection();
1110 1110
 		$error = '';
1111
-		if (!$Connection->checkColumnName('atc','format_source')) {
1111
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1112 1112
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1113 1113
 			try {
1114 1114
 				$sth = $Connection->db->prepare($query);
1115 1115
 				$sth->execute();
1116
-			} catch(PDOException $e) {
1116
+			} catch (PDOException $e) {
1117 1117
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1118 1118
 			}
1119 1119
 		}
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		try {
1122 1122
 			$sth = $Connection->db->prepare($query);
1123 1123
 			$sth->execute();
1124
-		} catch(PDOException $e) {
1124
+		} catch (PDOException $e) {
1125 1125
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1126 1126
 		}
1127 1127
 		return $error;
@@ -1131,13 +1131,13 @@  discard block
 block discarded – undo
1131 1131
 		global $globalDBdriver;
1132 1132
 		$Connection = new Connection();
1133 1133
 		$error = '';
1134
-		if (!$Connection->checkColumnName('stats_pilot','format_source')) {
1134
+		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) {
1135 1135
 			// Add forsource to airlines
1136 1136
 			$query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''";
1137 1137
 			try {
1138 1138
 				$sth = $Connection->db->prepare($query);
1139 1139
 				$sth->execute();
1140
-			} catch(PDOException $e) {
1140
+			} catch (PDOException $e) {
1141 1141
 				return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n";
1142 1142
 			}
1143 1143
 			// Add unique key
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 			try {
1150 1150
 				$sth = $Connection->db->prepare($query);
1151 1151
 				$sth->execute();
1152
-			} catch(PDOException $e) {
1152
+			} catch (PDOException $e) {
1153 1153
 				return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n";
1154 1154
 			}
1155 1155
 		}
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 		try {
1158 1158
 			$sth = $Connection->db->prepare($query);
1159 1159
 			$sth->execute();
1160
-		} catch(PDOException $e) {
1160
+		} catch (PDOException $e) {
1161 1161
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1162 1162
 		}
1163 1163
 		return $error;
@@ -1167,23 +1167,23 @@  discard block
 block discarded – undo
1167 1167
 		global $globalDBdriver;
1168 1168
 		$Connection = new Connection();
1169 1169
 		$error = '';
1170
-		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) {
1170
+		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) {
1171 1171
 			// Add unique key
1172 1172
 			$query = "alter table spotter_live add index(latitude,longitude)";
1173 1173
 			try {
1174 1174
 				$sth = $Connection->db->prepare($query);
1175 1175
 				$sth->execute();
1176
-			} catch(PDOException $e) {
1176
+			} catch (PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179 1179
                 }
1180
-		if (!$Connection->checkColumnName('aircraft','mfr')) {
1180
+		if (!$Connection->checkColumnName('aircraft', 'mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
1183 1183
 			try {
1184 1184
 				$sth = $Connection->db->prepare($query);
1185 1185
 				$sth->execute();
1186
-			} catch(PDOException $e) {
1186
+			} catch (PDOException $e) {
1187 1187
 				return "error (add mfr column in aircraft) : ".$e->getMessage()."\n";
1188 1188
 			}
1189 1189
 		}
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 		try {
1200 1200
 			$sth = $Connection->db->prepare($query);
1201 1201
 			$sth->execute();
1202
-		} catch(PDOException $e) {
1202
+		} catch (PDOException $e) {
1203 1203
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1204 1204
 		}
1205 1205
 		return $error;
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
 		global $globalDBdriver;
1210 1210
 		$Connection = new Connection();
1211 1211
 		$error = '';
1212
-		if ($Connection->checkColumnName('aircraft','mfr')) {
1212
+		if ($Connection->checkColumnName('aircraft', 'mfr')) {
1213 1213
 			// drop mfr to aircraft
1214 1214
 			$query = "ALTER TABLE aircraft DROP COLUMN mfr";
1215 1215
 			try {
1216 1216
 				$sth = $Connection->db->prepare($query);
1217 1217
 				$sth->execute();
1218
-			} catch(PDOException $e) {
1218
+			} catch (PDOException $e) {
1219 1219
 				return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n";
1220 1220
 			}
1221 1221
 		}
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 		try {
1232 1232
 			$sth = $Connection->db->prepare($query);
1233 1233
 			$sth->execute();
1234
-		} catch(PDOException $e) {
1234
+		} catch (PDOException $e) {
1235 1235
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1236 1236
 		}
1237 1237
 		return $error;
@@ -1241,33 +1241,33 @@  discard block
 block discarded – undo
1241 1241
 		global $globalDBdriver;
1242 1242
 		$Connection = new Connection();
1243 1243
 		$error = '';
1244
-		if (!$Connection->indexExists('notam','ref_idx')) {
1244
+		if (!$Connection->indexExists('notam', 'ref_idx')) {
1245 1245
 			// Add index key
1246 1246
 			$query = "create index ref_idx on notam (ref)";
1247 1247
 			try {
1248 1248
 				$sth = $Connection->db->prepare($query);
1249 1249
 				$sth->execute();
1250
-			} catch(PDOException $e) {
1250
+			} catch (PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253 1253
                 }
1254
-		if (!$Connection->indexExists('accidents','registration_idx')) {
1254
+		if (!$Connection->indexExists('accidents', 'registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
1257 1257
 			try {
1258 1258
 				$sth = $Connection->db->prepare($query);
1259 1259
 				$sth->execute();
1260
-			} catch(PDOException $e) {
1260
+			} catch (PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263 1263
                 }
1264
-		if (!$Connection->indexExists('accidents','rdts')) {
1264
+		if (!$Connection->indexExists('accidents', 'rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
1267 1267
 			try {
1268 1268
 				$sth = $Connection->db->prepare($query);
1269 1269
 				$sth->execute();
1270
-			} catch(PDOException $e) {
1270
+			} catch (PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273 1273
                 }
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		try {
1277 1277
 			$sth = $Connection->db->prepare($query);
1278 1278
 			$sth->execute();
1279
-		} catch(PDOException $e) {
1279
+		} catch (PDOException $e) {
1280 1280
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1281 1281
 		}
1282 1282
 		return $error;
@@ -1286,23 +1286,23 @@  discard block
 block discarded – undo
1286 1286
 		global $globalDBdriver;
1287 1287
 		$Connection = new Connection();
1288 1288
 		$error = '';
1289
-		if (!$Connection->checkColumnName('accidents','airline_name')) {
1289
+		if (!$Connection->checkColumnName('accidents', 'airline_name')) {
1290 1290
 			// Add airline_name to accidents
1291 1291
 			$query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL";
1292 1292
 			try {
1293 1293
 				$sth = $Connection->db->prepare($query);
1294 1294
 				$sth->execute();
1295
-			} catch(PDOException $e) {
1295
+			} catch (PDOException $e) {
1296 1296
 				return "error (add airline_name column in accidents) : ".$e->getMessage()."\n";
1297 1297
 			}
1298 1298
 		}
1299
-		if (!$Connection->checkColumnName('accidents','airline_icao')) {
1299
+		if (!$Connection->checkColumnName('accidents', 'airline_icao')) {
1300 1300
 			// Add airline_icao to accidents
1301 1301
 			$query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL";
1302 1302
 			try {
1303 1303
 				$sth = $Connection->db->prepare($query);
1304 1304
 				$sth->execute();
1305
-			} catch(PDOException $e) {
1305
+			} catch (PDOException $e) {
1306 1306
 				return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n";
1307 1307
 			}
1308 1308
 		}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		try {
1311 1311
 			$sth = $Connection->db->prepare($query);
1312 1312
 			$sth->execute();
1313
-		} catch(PDOException $e) {
1313
+		} catch (PDOException $e) {
1314 1314
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1315 1315
 		}
1316 1316
 		return $error;
@@ -1320,13 +1320,13 @@  discard block
 block discarded – undo
1320 1320
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1321 1321
 		$Connection = new Connection();
1322 1322
 		$error = '';
1323
-		if (!$Connection->checkColumnName('airlines','alliance')) {
1323
+		if (!$Connection->checkColumnName('airlines', 'alliance')) {
1324 1324
 			// Add alliance to airlines
1325 1325
 			$query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL";
1326 1326
 			try {
1327 1327
 				$sth = $Connection->db->prepare($query);
1328 1328
 				$sth->execute();
1329
-			} catch(PDOException $e) {
1329
+			} catch (PDOException $e) {
1330 1330
 				return "error (add alliance column in airlines) : ".$e->getMessage()."\n";
1331 1331
 			}
1332 1332
 		}
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 		try {
1354 1354
 			$sth = $Connection->db->prepare($query);
1355 1355
 			$sth->execute();
1356
-		} catch(PDOException $e) {
1356
+		} catch (PDOException $e) {
1357 1357
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1358 1358
 		}
1359 1359
 		return $error;
@@ -1363,13 +1363,13 @@  discard block
 block discarded – undo
1363 1363
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1364 1364
 		$Connection = new Connection();
1365 1365
 		$error = '';
1366
-		if (!$Connection->checkColumnName('airlines','ban_eu')) {
1366
+		if (!$Connection->checkColumnName('airlines', 'ban_eu')) {
1367 1367
 			// Add ban_eu to airlines
1368 1368
 			$query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'";
1369 1369
 			try {
1370 1370
 				$sth = $Connection->db->prepare($query);
1371 1371
 				$sth->execute();
1372
-			} catch(PDOException $e) {
1372
+			} catch (PDOException $e) {
1373 1373
 				return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n";
1374 1374
 			}
1375 1375
 		}
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 		try {
1378 1378
 			$sth = $Connection->db->prepare($query);
1379 1379
 			$sth->execute();
1380
-		} catch(PDOException $e) {
1380
+		} catch (PDOException $e) {
1381 1381
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1382 1382
 		}
1383 1383
 		return $error;
@@ -1388,19 +1388,19 @@  discard block
 block discarded – undo
1388 1388
 		$Connection = new Connection();
1389 1389
 		$error = '';
1390 1390
 		if ($globalDBdriver == 'mysql') {
1391
-			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') {
1391
+			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') {
1392 1392
 				$query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL";
1393 1393
 				try {
1394 1394
 					$sth = $Connection->db->prepare($query);
1395 1395
 					$sth->execute();
1396
-				} catch(PDOException $e) {
1396
+				} catch (PDOException $e) {
1397 1397
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1398 1398
 				}
1399 1399
 				$query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1400 1400
 				try {
1401 1401
 					$sth = $Connection->db->prepare($query);
1402 1402
 					$sth->execute();
1403
-				} catch(PDOException $e) {
1403
+				} catch (PDOException $e) {
1404 1404
 					return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1405 1405
 				}
1406 1406
 				
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
 				try {
1409 1409
 					$sth = $Connection->db->prepare($query);
1410 1410
 					$sth->execute();
1411
-				} catch(PDOException $e) {
1411
+				} catch (PDOException $e) {
1412 1412
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1413 1413
 				}
1414 1414
 				/*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150";
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 				try {
1460 1460
 					$sth = $Connection->db->prepare($query);
1461 1461
 					$sth->execute();
1462
-				} catch(PDOException $e) {
1462
+				} catch (PDOException $e) {
1463 1463
 					return "error (fix date) : ".$e->getMessage()."\n";
1464 1464
 				}
1465 1465
 			}
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 		try {
1545 1545
 			$sth = $Connection->db->prepare($query);
1546 1546
 			$sth->execute();
1547
-		} catch(PDOException $e) {
1547
+		} catch (PDOException $e) {
1548 1548
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1549 1549
 		}
1550 1550
 		return $error;
@@ -1553,13 +1553,13 @@  discard block
 block discarded – undo
1553 1553
 		global $globalDBdriver;
1554 1554
 		$Connection = new Connection();
1555 1555
 		$error = '';
1556
-		if (!$Connection->indexExists('accidents','type')) {
1556
+		if (!$Connection->indexExists('accidents', 'type')) {
1557 1557
 			// Add index key
1558 1558
 			$query = "create index type on accidents (type,date)";
1559 1559
 			try {
1560 1560
 				$sth = $Connection->db->prepare($query);
1561 1561
 				$sth->execute();
1562
-			} catch(PDOException $e) {
1562
+			} catch (PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565 1565
                 }
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
1569 1569
 			$sth->execute();
1570
-		} catch(PDOException $e) {
1570
+		} catch (PDOException $e) {
1571 1571
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1572 1572
 		}
1573 1573
 		return $error;
@@ -1589,7 +1589,7 @@  discard block
 block discarded – undo
1589 1589
 		    try {
1590 1590
             		$sth = $Connection->db->prepare($query);
1591 1591
 		        $sth->execute();
1592
-		    } catch(PDOException $e) {
1592
+		    } catch (PDOException $e) {
1593 1593
 			return "error : ".$e->getMessage()."\n";
1594 1594
     		    }
1595 1595
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +282 added lines, -106 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1581,8 +1647,11 @@  discard block
 block discarded – undo
1581 1647
     	    if ($Connection->tableExists('aircraft')) {
1582 1648
     		if (!$Connection->tableExists('config')) {
1583 1649
     		    $version = '1';
1584
-    		    if ($update) return self::update_from_1();
1585
-    		    else return $version;
1650
+    		    if ($update) {
1651
+    		    	return self::update_from_1();
1652
+    		    } else {
1653
+    		    	return $version;
1654
+    		    }
1586 1655
 		} else {
1587 1656
     		    $Connection = new Connection();
1588 1657
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1596,146 +1665,253 @@  discard block
 block discarded – undo
1596 1665
     		    if ($update) {
1597 1666
     			if ($result['value'] == '2') {
1598 1667
     			    $error = self::update_from_2();
1599
-    			    if ($error != '') return $error;
1600
-    			    else return self::check_version(true);
1668
+    			    if ($error != '') {
1669
+    			    	return $error;
1670
+    			    } else {
1671
+    			    	return self::check_version(true);
1672
+    			    }
1601 1673
     			} elseif ($result['value'] == '3') {
1602 1674
     			    $error = self::update_from_3();
1603
-    			    if ($error != '') return $error;
1604
-    			    else return self::check_version(true);
1675
+    			    if ($error != '') {
1676
+    			    	return $error;
1677
+    			    } else {
1678
+    			    	return self::check_version(true);
1679
+    			    }
1605 1680
     			} elseif ($result['value'] == '4') {
1606 1681
     			    $error = self::update_from_4();
1607
-    			    if ($error != '') return $error;
1608
-    			    else return self::check_version(true);
1682
+    			    if ($error != '') {
1683
+    			    	return $error;
1684
+    			    } else {
1685
+    			    	return self::check_version(true);
1686
+    			    }
1609 1687
     			} elseif ($result['value'] == '5') {
1610 1688
     			    $error = self::update_from_5();
1611
-    			    if ($error != '') return $error;
1612
-    			    else return self::check_version(true);
1689
+    			    if ($error != '') {
1690
+    			    	return $error;
1691
+    			    } else {
1692
+    			    	return self::check_version(true);
1693
+    			    }
1613 1694
     			} elseif ($result['value'] == '6') {
1614 1695
     			    $error = self::update_from_6();
1615
-    			    if ($error != '') return $error;
1616
-    			    else return self::check_version(true);
1696
+    			    if ($error != '') {
1697
+    			    	return $error;
1698
+    			    } else {
1699
+    			    	return self::check_version(true);
1700
+    			    }
1617 1701
     			} elseif ($result['value'] == '7') {
1618 1702
     			    $error = self::update_from_7();
1619
-    			    if ($error != '') return $error;
1620
-    			    else return self::check_version(true);
1703
+    			    if ($error != '') {
1704
+    			    	return $error;
1705
+    			    } else {
1706
+    			    	return self::check_version(true);
1707
+    			    }
1621 1708
     			} elseif ($result['value'] == '8') {
1622 1709
     			    $error = self::update_from_8();
1623
-    			    if ($error != '') return $error;
1624
-    			    else return self::check_version(true);
1710
+    			    if ($error != '') {
1711
+    			    	return $error;
1712
+    			    } else {
1713
+    			    	return self::check_version(true);
1714
+    			    }
1625 1715
     			} elseif ($result['value'] == '9') {
1626 1716
     			    $error = self::update_from_9();
1627
-    			    if ($error != '') return $error;
1628
-    			    else return self::check_version(true);
1717
+    			    if ($error != '') {
1718
+    			    	return $error;
1719
+    			    } else {
1720
+    			    	return self::check_version(true);
1721
+    			    }
1629 1722
     			} elseif ($result['value'] == '10') {
1630 1723
     			    $error = self::update_from_10();
1631
-    			    if ($error != '') return $error;
1632
-    			    else return self::check_version(true);
1724
+    			    if ($error != '') {
1725
+    			    	return $error;
1726
+    			    } else {
1727
+    			    	return self::check_version(true);
1728
+    			    }
1633 1729
     			} elseif ($result['value'] == '11') {
1634 1730
     			    $error = self::update_from_11();
1635
-    			    if ($error != '') return $error;
1636
-    			    else return self::check_version(true);
1731
+    			    if ($error != '') {
1732
+    			    	return $error;
1733
+    			    } else {
1734
+    			    	return self::check_version(true);
1735
+    			    }
1637 1736
     			} elseif ($result['value'] == '12') {
1638 1737
     			    $error = self::update_from_12();
1639
-    			    if ($error != '') return $error;
1640
-    			    else return self::check_version(true);
1738
+    			    if ($error != '') {
1739
+    			    	return $error;
1740
+    			    } else {
1741
+    			    	return self::check_version(true);
1742
+    			    }
1641 1743
     			} elseif ($result['value'] == '13') {
1642 1744
     			    $error = self::update_from_13();
1643
-    			    if ($error != '') return $error;
1644
-    			    else return self::check_version(true);
1745
+    			    if ($error != '') {
1746
+    			    	return $error;
1747
+    			    } else {
1748
+    			    	return self::check_version(true);
1749
+    			    }
1645 1750
     			} elseif ($result['value'] == '14') {
1646 1751
     			    $error = self::update_from_14();
1647
-    			    if ($error != '') return $error;
1648
-    			    else return self::check_version(true);
1752
+    			    if ($error != '') {
1753
+    			    	return $error;
1754
+    			    } else {
1755
+    			    	return self::check_version(true);
1756
+    			    }
1649 1757
     			} elseif ($result['value'] == '15') {
1650 1758
     			    $error = self::update_from_15();
1651
-    			    if ($error != '') return $error;
1652
-    			    else return self::check_version(true);
1759
+    			    if ($error != '') {
1760
+    			    	return $error;
1761
+    			    } else {
1762
+    			    	return self::check_version(true);
1763
+    			    }
1653 1764
     			} elseif ($result['value'] == '16') {
1654 1765
     			    $error = self::update_from_16();
1655
-    			    if ($error != '') return $error;
1656
-    			    else return self::check_version(true);
1766
+    			    if ($error != '') {
1767
+    			    	return $error;
1768
+    			    } else {
1769
+    			    	return self::check_version(true);
1770
+    			    }
1657 1771
     			} elseif ($result['value'] == '17') {
1658 1772
     			    $error = self::update_from_17();
1659
-    			    if ($error != '') return $error;
1660
-    			    else return self::check_version(true);
1773
+    			    if ($error != '') {
1774
+    			    	return $error;
1775
+    			    } else {
1776
+    			    	return self::check_version(true);
1777
+    			    }
1661 1778
     			} elseif ($result['value'] == '18') {
1662 1779
     			    $error = self::update_from_18();
1663
-    			    if ($error != '') return $error;
1664
-    			    else return self::check_version(true);
1780
+    			    if ($error != '') {
1781
+    			    	return $error;
1782
+    			    } else {
1783
+    			    	return self::check_version(true);
1784
+    			    }
1665 1785
     			} elseif ($result['value'] == '19') {
1666 1786
     			    $error = self::update_from_19();
1667
-    			    if ($error != '') return $error;
1668
-    			    else return self::check_version(true);
1787
+    			    if ($error != '') {
1788
+    			    	return $error;
1789
+    			    } else {
1790
+    			    	return self::check_version(true);
1791
+    			    }
1669 1792
     			} elseif ($result['value'] == '20') {
1670 1793
     			    $error = self::update_from_20();
1671
-    			    if ($error != '') return $error;
1672
-    			    else return self::check_version(true);
1794
+    			    if ($error != '') {
1795
+    			    	return $error;
1796
+    			    } else {
1797
+    			    	return self::check_version(true);
1798
+    			    }
1673 1799
     			} elseif ($result['value'] == '21') {
1674 1800
     			    $error = self::update_from_21();
1675
-    			    if ($error != '') return $error;
1676
-    			    else return self::check_version(true);
1801
+    			    if ($error != '') {
1802
+    			    	return $error;
1803
+    			    } else {
1804
+    			    	return self::check_version(true);
1805
+    			    }
1677 1806
     			} elseif ($result['value'] == '22') {
1678 1807
     			    $error = self::update_from_22();
1679
-    			    if ($error != '') return $error;
1680
-    			    else return self::check_version(true);
1808
+    			    if ($error != '') {
1809
+    			    	return $error;
1810
+    			    } else {
1811
+    			    	return self::check_version(true);
1812
+    			    }
1681 1813
     			} elseif ($result['value'] == '23') {
1682 1814
     			    $error = self::update_from_23();
1683
-    			    if ($error != '') return $error;
1684
-    			    else return self::check_version(true);
1815
+    			    if ($error != '') {
1816
+    			    	return $error;
1817
+    			    } else {
1818
+    			    	return self::check_version(true);
1819
+    			    }
1685 1820
     			} elseif ($result['value'] == '24') {
1686 1821
     			    $error = self::update_from_24();
1687
-    			    if ($error != '') return $error;
1688
-    			    else return self::check_version(true);
1822
+    			    if ($error != '') {
1823
+    			    	return $error;
1824
+    			    } else {
1825
+    			    	return self::check_version(true);
1826
+    			    }
1689 1827
     			} elseif ($result['value'] == '25') {
1690 1828
     			    $error = self::update_from_25();
1691
-    			    if ($error != '') return $error;
1692
-    			    else return self::check_version(true);
1829
+    			    if ($error != '') {
1830
+    			    	return $error;
1831
+    			    } else {
1832
+    			    	return self::check_version(true);
1833
+    			    }
1693 1834
     			} elseif ($result['value'] == '26') {
1694 1835
     			    $error = self::update_from_26();
1695
-    			    if ($error != '') return $error;
1696
-    			    else return self::check_version(true);
1836
+    			    if ($error != '') {
1837
+    			    	return $error;
1838
+    			    } else {
1839
+    			    	return self::check_version(true);
1840
+    			    }
1697 1841
     			} elseif ($result['value'] == '27') {
1698 1842
     			    $error = self::update_from_27();
1699
-    			    if ($error != '') return $error;
1700
-    			    else return self::check_version(true);
1843
+    			    if ($error != '') {
1844
+    			    	return $error;
1845
+    			    } else {
1846
+    			    	return self::check_version(true);
1847
+    			    }
1701 1848
     			} elseif ($result['value'] == '28') {
1702 1849
     			    $error = self::update_from_28();
1703
-    			    if ($error != '') return $error;
1704
-    			    else return self::check_version(true);
1850
+    			    if ($error != '') {
1851
+    			    	return $error;
1852
+    			    } else {
1853
+    			    	return self::check_version(true);
1854
+    			    }
1705 1855
     			} elseif ($result['value'] == '29') {
1706 1856
     			    $error = self::update_from_29();
1707
-    			    if ($error != '') return $error;
1708
-    			    else return self::check_version(true);
1857
+    			    if ($error != '') {
1858
+    			    	return $error;
1859
+    			    } else {
1860
+    			    	return self::check_version(true);
1861
+    			    }
1709 1862
     			} elseif ($result['value'] == '30') {
1710 1863
     			    $error = self::update_from_30();
1711
-    			    if ($error != '') return $error;
1712
-    			    else return self::check_version(true);
1864
+    			    if ($error != '') {
1865
+    			    	return $error;
1866
+    			    } else {
1867
+    			    	return self::check_version(true);
1868
+    			    }
1713 1869
     			} elseif ($result['value'] == '31') {
1714 1870
     			    $error = self::update_from_31();
1715
-    			    if ($error != '') return $error;
1716
-    			    else return self::check_version(true);
1871
+    			    if ($error != '') {
1872
+    			    	return $error;
1873
+    			    } else {
1874
+    			    	return self::check_version(true);
1875
+    			    }
1717 1876
     			} elseif ($result['value'] == '32') {
1718 1877
     			    $error = self::update_from_32();
1719
-    			    if ($error != '') return $error;
1720
-    			    else return self::check_version(true);
1878
+    			    if ($error != '') {
1879
+    			    	return $error;
1880
+    			    } else {
1881
+    			    	return self::check_version(true);
1882
+    			    }
1721 1883
     			} elseif ($result['value'] == '33') {
1722 1884
     			    $error = self::update_from_33();
1723
-    			    if ($error != '') return $error;
1724
-    			    else return self::check_version(true);
1885
+    			    if ($error != '') {
1886
+    			    	return $error;
1887
+    			    } else {
1888
+    			    	return self::check_version(true);
1889
+    			    }
1725 1890
     			} elseif ($result['value'] == '34') {
1726 1891
     			    $error = self::update_from_34();
1727
-    			    if ($error != '') return $error;
1728
-    			    else return self::check_version(true);
1892
+    			    if ($error != '') {
1893
+    			    	return $error;
1894
+    			    } else {
1895
+    			    	return self::check_version(true);
1896
+    			    }
1729 1897
     			} elseif ($result['value'] == '35') {
1730 1898
     			    $error = self::update_from_35();
1731
-    			    if ($error != '') return $error;
1732
-    			    else return self::check_version(true);
1733
-    			} else return '';
1899
+    			    if ($error != '') {
1900
+    			    	return $error;
1901
+    			    } else {
1902
+    			    	return self::check_version(true);
1903
+    			    }
1904
+    			} else {
1905
+    				return '';
1906
+    			}
1907
+    		    } else {
1908
+    		    	return $result['value'];
1734 1909
     		    }
1735
-    		    else return $result['value'];
1736 1910
 		}
1737 1911
 		
1738
-	    } else return $version;
1912
+	    } else {
1913
+	    	return $version;
1914
+	    }
1739 1915
     	}
1740 1916
     	
1741 1917
 }
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +696 added lines, -696 removed lines patch added patch discarded remove patch
@@ -19,47 +19,47 @@  discard block
 block discarded – undo
19 19
 // Check if schema is at latest version
20 20
 $Connection = new Connection();
21 21
 if ($Connection->latest() === false) {
22
-    echo "You MUST update to latest schema. Run install/index.php";
23
-    exit();
22
+	echo "You MUST update to latest schema. Run install/index.php";
23
+	exit();
24 24
 }
25 25
 if (PHP_SAPI != 'cli') {
26
-    echo "This script MUST be called from console, not a web browser.";
26
+	echo "This script MUST be called from console, not a web browser.";
27 27
 //    exit();
28 28
 }
29 29
 
30 30
 // This is to be compatible with old version of settings.php
31 31
 if (!isset($globalSources)) {
32
-    if (isset($globalSBS1Hosts)) {
33
-        //$hosts = $globalSBS1Hosts;
34
-        foreach ($globalSBS1Hosts as $host) {
35
-	    $globalSources[] = array('host' => $host);
36
-    	}
37
-    } else {
38
-        if (!isset($globalSBS1Host)) {
39
-	    echo '$globalSources MUST be defined !';
40
-	    die;
32
+	if (isset($globalSBS1Hosts)) {
33
+		//$hosts = $globalSBS1Hosts;
34
+		foreach ($globalSBS1Hosts as $host) {
35
+		$globalSources[] = array('host' => $host);
36
+		}
37
+	} else {
38
+		if (!isset($globalSBS1Host)) {
39
+		echo '$globalSources MUST be defined !';
40
+		die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43 43
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
44
-    }
44
+	}
45 45
 }
46 46
 
47 47
 $options = getopt('s::',array('source::','server','idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
51
-    $globalSources = array();
52
-    $globalSources[] = array('host' => $options['s']);
51
+	$globalSources = array();
52
+	$globalSources[] = array('host' => $options['s']);
53 53
 } elseif (isset($options['source'])) {
54
-    $globalSources = array();
55
-    $globalSources[] = array('host' => $options['source']);
54
+	$globalSources = array();
55
+	$globalSources[] = array('host' => $options['source']);
56 56
 }
57 57
 if (isset($options['server'])) $globalServer = TRUE;
58 58
 if (isset($options['idsource'])) $id_source = $options['idsource'];
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
61
+	if ($globalDebug) echo "Using Server Mode\n";
62
+	$SI=new SpotterServer();
63 63
 } else $SI=new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65 65
 $SBS=new SBS();
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
73
-        global $sockets;
74
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
-        die("Bye!\n");
76
-    });
77
-    pcntl_signal_dispatch();
72
+	pcntl_signal(SIGINT,  function() {
73
+		global $sockets;
74
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
+		die("Bye!\n");
76
+	});
77
+	pcntl_signal_dispatch();
78 78
 }
79 79
 
80 80
 // let's try and connect
@@ -84,162 +84,162 @@  discard block
 block discarded – undo
84 84
 $reset = 0;
85 85
 
86 86
 function create_socket($host, $port, &$errno, &$errstr) {
87
-    $ip = gethostbyname($host);
88
-    $s = socket_create(AF_INET, SOCK_STREAM, 0);
89
-    $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
-        return $s;
93
-    }
94
-    $errno = socket_last_error($s);
95
-    $errstr = socket_strerror($errno);
96
-    socket_close($s);
97
-    return false;
87
+	$ip = gethostbyname($host);
88
+	$s = socket_create(AF_INET, SOCK_STREAM, 0);
89
+	$r = @socket_connect($s, $ip, $port);
90
+	if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
+		return $s;
93
+	}
94
+	$errno = socket_last_error($s);
95
+	$errstr = socket_strerror($errno);
96
+	socket_close($s);
97
+	return false;
98 98
 }
99 99
 
100 100
 function create_socket_udp($host, $port, &$errno, &$errstr) {
101
-    echo "Create an UDP socket...\n";
102
-    $ip = gethostbyname($host);
103
-    $s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
-    $r = @socket_bind($s, $ip, $port);
105
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
-        return $s;
107
-    }
108
-    $errno = socket_last_error($s);
109
-    $errstr = socket_strerror($errno);
110
-    socket_close($s);
111
-    return false;
101
+	echo "Create an UDP socket...\n";
102
+	$ip = gethostbyname($host);
103
+	$s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
+	$r = @socket_bind($s, $ip, $port);
105
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
+		return $s;
107
+	}
108
+	$errno = socket_last_error($s);
109
+	$errstr = socket_strerror($errno);
110
+	socket_close($s);
111
+	return false;
112 112
 }
113 113
 
114 114
 function connect_all($hosts) {
115
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
-    $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
119
-    foreach ($hosts as $id => $value) {
115
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
+	$reset++;
118
+	if ($globalDebug) echo 'Connect to all...'."\n";
119
+	foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123 123
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
125
-        	//$formats[$id] = 'deltadbtxt';
126
-        	$globalSources[$id]['format'] = 'deltadbtxt';
127
-        	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
-        	//$formats[$id] = 'vatsimtxt';
131
-        	$globalSources[$id]['format'] = 'vatsimtxt';
132
-        	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
140
-        	//$formats[$id] = 'aircraftlistjson';
141
-        	$globalSources[$id]['format'] = 'opensky';
142
-        	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
-        	//$formats[$id] = 'radarvirtueljson';
146
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
147
-        	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
-        	    exit(0);
152
-        	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
-        	//$formats[$id] = 'planeupdatefaa';
155
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
156
-        	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
-        	    exit(0);
161
-        	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
-        	//$formats[$id] = 'phpvmacars';
164
-        	$globalSources[$id]['format'] = 'phpvmacars';
165
-        	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
168
-        	//$formats[$id] = 'phpvmacars';
169
-        	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
172
-        	//$formats[$id] = 'whazzup';
173
-        	$globalSources[$id]['format'] = 'whazzup';
174
-        	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
177
-        	//$formats[$id] = 'pirepsjson';
178
-        	$globalSources[$id]['format'] = 'pirepsjson';
179
-        	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
-        	//$formats[$id] = 'fr24json';
183
-        	$globalSources[$id]['format'] = 'fr24json';
184
-        	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
-        	    exit(0);
189
-        	}
190
-            //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
-        	//$formats[$id] = 'tsv';
193
-        	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
-            }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
200
-	    if (isset($hostport[1])) {
124
+			if (preg_match('/deltadb.txt$/i',$host)) {
125
+			//$formats[$id] = 'deltadbtxt';
126
+			$globalSources[$id]['format'] = 'deltadbtxt';
127
+			//$last_exec['deltadbtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
+			//$formats[$id] = 'vatsimtxt';
131
+			$globalSources[$id]['format'] = 'vatsimtxt';
132
+			//$last_exec['vatsimtxt'] = 0;
133
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'aircraftlistjson';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
+			} else if (preg_match('/opensky/i',$host)) {
140
+			//$formats[$id] = 'aircraftlistjson';
141
+			$globalSources[$id]['format'] = 'opensky';
142
+			//$last_exec['aircraftlistjson'] = 0;
143
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
+			//$formats[$id] = 'radarvirtueljson';
146
+			$globalSources[$id]['format'] = 'radarvirtueljson';
147
+			//$last_exec['radarvirtueljson'] = 0;
148
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
+				exit(0);
152
+			}
153
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
+			//$formats[$id] = 'planeupdatefaa';
155
+			$globalSources[$id]['format'] = 'planeupdatefaa';
156
+			//$last_exec['planeupdatefaa'] = 0;
157
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
+				exit(0);
161
+			}
162
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
+			//$formats[$id] = 'phpvmacars';
164
+			$globalSources[$id]['format'] = 'phpvmacars';
165
+			//$last_exec['phpvmacars'] = 0;
166
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
168
+			//$formats[$id] = 'phpvmacars';
169
+			$globalSources[$id]['format'] = 'vam';
170
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
+			} else if (preg_match('/whazzup/i',$host)) {
172
+			//$formats[$id] = 'whazzup';
173
+			$globalSources[$id]['format'] = 'whazzup';
174
+			//$last_exec['whazzup'] = 0;
175
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
+			} else if (preg_match('/recentpireps/i',$host)) {
177
+			//$formats[$id] = 'pirepsjson';
178
+			$globalSources[$id]['format'] = 'pirepsjson';
179
+			//$last_exec['pirepsjson'] = 0;
180
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
+			//$formats[$id] = 'fr24json';
183
+			$globalSources[$id]['format'] = 'fr24json';
184
+			//$last_exec['fr24json'] = 0;
185
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
+				exit(0);
189
+			}
190
+			//} else if (preg_match('/10001/',$host)) {
191
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
+			//$formats[$id] = 'tsv';
193
+			$globalSources[$id]['format'] = 'tsv';
194
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
+			}
196
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
+			if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
+		$hostport = explode(':',$host);
200
+		if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
203
-	    } else {
203
+		} else {
204 204
 		$port = $globalSources[$id]['port'];
205 205
 		$hostn = $globalSources[$id]['host'];
206
-	    }
207
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
209
-    	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
-	    }
212
-	    if ($s) {
213
-    	        $sockets[$id] = $s;
214
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
206
+		}
207
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
+			$s = create_socket($hostn,$port, $errno, $errstr);
209
+			} else {
210
+			$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
+		}
212
+		if ($s) {
213
+				$sockets[$id] = $s;
214
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
+			if (preg_match('/aprs/',$hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
219 219
 			//$use_aprs = true;
220
-    		    } elseif ($port == '10001') {
221
-        		//$formats[$id] = 'tsv';
222
-        		$globalSources[$id]['format'] = 'tsv';
223
-		    } elseif ($port == '30002') {
224
-        		//$formats[$id] = 'raw';
225
-        		$globalSources[$id]['format'] = 'raw';
226
-		    } elseif ($port == '5001') {
227
-        		//$formats[$id] = 'raw';
228
-        		$globalSources[$id]['format'] = 'flightgearmp';
229
-		    } elseif ($port == '30005') {
220
+				} elseif ($port == '10001') {
221
+				//$formats[$id] = 'tsv';
222
+				$globalSources[$id]['format'] = 'tsv';
223
+			} elseif ($port == '30002') {
224
+				//$formats[$id] = 'raw';
225
+				$globalSources[$id]['format'] = 'raw';
226
+			} elseif ($port == '5001') {
227
+				//$formats[$id] = 'raw';
228
+				$globalSources[$id]['format'] = 'flightgearmp';
229
+			} elseif ($port == '30005') {
230 230
 			// Not yet supported
231
-        		//$formats[$id] = 'beast';
232
-        		$globalSources[$id]['format'] = 'beast';
233
-		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
235
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231
+				//$formats[$id] = 'beast';
232
+				$globalSources[$id]['format'] = 'beast';
233
+			//} else $formats[$id] = 'sbs';
234
+			} else $globalSources[$id]['format'] = 'sbs';
235
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 236
 		}
237 237
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
238
-            } else {
238
+			} else {
239 239
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
240
-    	    }
241
-        }
242
-    }
240
+			}
241
+		}
242
+	}
243 243
 }
244 244
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
245 245
 
@@ -266,18 +266,18 @@  discard block
 block discarded – undo
266 266
 	die;
267 267
 }
268 268
 foreach ($globalSources as $key => $source) {
269
-    if (!isset($source['format'])) {
270
-        $globalSources[$key]['format'] = 'auto';
271
-    }
269
+	if (!isset($source['format'])) {
270
+		$globalSources[$key]['format'] = 'auto';
271
+	}
272 272
 }
273 273
 connect_all($globalSources);
274 274
 foreach ($globalSources as $key => $source) {
275
-    if (isset($source['format']) && $source['format'] == 'aprs') {
275
+	if (isset($source['format']) && $source['format'] == 'aprs') {
276 276
 	$aprs_connect = 0;
277 277
 	$use_aprs = true;
278 278
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
279 279
 	break;
280
-    }
280
+	}
281 281
 }
282 282
 
283 283
 if ($use_aprs) {
@@ -316,70 +316,70 @@  discard block
 block discarded – undo
316 316
 
317 317
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
318 318
 while ($i > 0) {
319
-    if (!$globalDaemon) $i = $endtime-time();
320
-    // Delete old ATC
321
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
319
+	if (!$globalDaemon) $i = $endtime-time();
320
+	// Delete old ATC
321
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
322 322
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
323
-        $ATC->deleteOldATC();
324
-    }
323
+		$ATC->deleteOldATC();
324
+	}
325 325
     
326
-    if (count($last_exec) > 0) {
326
+	if (count($last_exec) > 0) {
327 327
 	$max = $globalMinFetch;
328 328
 	foreach ($last_exec as $last) {
329
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
329
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
330 330
 	}
331 331
 	if ($max != $globalMinFetch) {
332
-	    if ($globalDebug) echo 'Sleeping...'."\n";
333
-	    sleep($globalMinFetch-$max+2);
332
+		if ($globalDebug) echo 'Sleeping...'."\n";
333
+		sleep($globalMinFetch-$max+2);
334
+	}
334 335
 	}
335
-    }
336 336
 
337 337
     
338
-    //foreach ($formats as $id => $value) {
339
-    foreach ($globalSources as $id => $value) {
338
+	//foreach ($formats as $id => $value) {
339
+	foreach ($globalSources as $id => $value) {
340 340
 	date_default_timezone_set('UTC');
341 341
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
342 342
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
343
-	    //$buffer = $Common->getData($hosts[$id]);
344
-	    $buffer = $Common->getData($value['host']);
345
-	    if ($buffer != '') $reset = 0;
346
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
-	    $buffer = explode('\n',$buffer);
348
-	    foreach ($buffer as $line) {
349
-    		if ($line != '' && count($line) > 7) {
350
-    		    $line = explode(',', $line);
351
-	            $data = array();
352
-	            $data['hex'] = $line[1]; // hex
353
-	            $data['ident'] = $line[2]; // ident
354
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
359
-	            $data['verticalrate'] = ''; // vertical rate
360
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361
-	            $data['emergency'] = ''; // emergency
362
-		    $data['datetime'] = date('Y-m-d H:i:s');
363
-		    $data['format_source'] = 'deltadbtxt';
364
-    		    $data['id_source'] = $id_source;
365
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
367
-    		    $SI->add($data);
368
-		    unset($data);
369
-    		}
370
-    	    }
371
-    	    $last_exec[$id]['last'] = time();
343
+		//$buffer = $Common->getData($hosts[$id]);
344
+		$buffer = $Common->getData($value['host']);
345
+		if ($buffer != '') $reset = 0;
346
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
+		$buffer = explode('\n',$buffer);
348
+		foreach ($buffer as $line) {
349
+			if ($line != '' && count($line) > 7) {
350
+				$line = explode(',', $line);
351
+				$data = array();
352
+				$data['hex'] = $line[1]; // hex
353
+				$data['ident'] = $line[2]; // ident
354
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
359
+				$data['verticalrate'] = ''; // vertical rate
360
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361
+				$data['emergency'] = ''; // emergency
362
+			$data['datetime'] = date('Y-m-d H:i:s');
363
+			$data['format_source'] = 'deltadbtxt';
364
+				$data['id_source'] = $id_source;
365
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
367
+				$SI->add($data);
368
+			unset($data);
369
+			}
370
+			}
371
+			$last_exec[$id]['last'] = time();
372 372
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
373 373
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
374
-	    //$buffer = $Common->getData($hosts[$id]);
375
-	    $buffer = $Common->getData($value['host']);
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
378
-	    $reset = 0;
379
-	    foreach ($buffer as $line) {
380
-    		if ($line != '') {
381
-    		    $line = explode(':', $line);
382
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
374
+		//$buffer = $Common->getData($hosts[$id]);
375
+		$buffer = $Common->getData($value['host']);
376
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
+		$buffer = explode('\n',$buffer);
378
+		$reset = 0;
379
+		foreach ($buffer as $line) {
380
+			if ($line != '') {
381
+				$line = explode(':', $line);
382
+				if (count($line) > 30 && $line[0] != 'callsign') {
383 383
 			$data = array();
384 384
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
385 385
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -392,36 +392,36 @@  discard block
 block discarded – undo
392 392
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
393 393
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
394 394
 			$data['latitude'] = $line[5]; // lat
395
-	        	$data['longitude'] = $line[6]; // long
396
-	        	$data['verticalrate'] = ''; // vertical rate
397
-	        	$data['squawk'] = ''; // squawk
398
-	        	$data['emergency'] = ''; // emergency
399
-	        	$data['waypoints'] = $line[30];
395
+				$data['longitude'] = $line[6]; // long
396
+				$data['verticalrate'] = ''; // vertical rate
397
+				$data['squawk'] = ''; // squawk
398
+				$data['emergency'] = ''; // emergency
399
+				$data['waypoints'] = $line[30];
400 400
 			$data['datetime'] = date('Y-m-d H:i:s');
401 401
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
402 402
 			//if (isset($line[37])) $data['last_update'] = $line[37];
403
-		        $data['departure_airport_icao'] = $line[11];
404
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
405
-		        $data['arrival_airport_icao'] = $line[13];
403
+				$data['departure_airport_icao'] = $line[11];
404
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
405
+				$data['arrival_airport_icao'] = $line[13];
406 406
 			$data['frequency'] = $line[4];
407 407
 			$data['type'] = $line[18];
408 408
 			$data['range'] = $line[19];
409 409
 			if (isset($line[35])) $data['info'] = $line[35];
410
-    			$data['id_source'] = $id_source;
411
-	    		//$data['arrival_airport_time'] = ;
412
-	    		if ($line[9] != '') {
413
-	    		    $aircraft_data = explode('/',$line[9]);
414
-	    		    if (isset($aircraft_data[1])) {
415
-	    			$data['aircraft_icao'] = $aircraft_data[1];
416
-	    		    }
417
-        		}
418
-	    		/*
410
+				$data['id_source'] = $id_source;
411
+				//$data['arrival_airport_time'] = ;
412
+				if ($line[9] != '') {
413
+					$aircraft_data = explode('/',$line[9]);
414
+					if (isset($aircraft_data[1])) {
415
+					$data['aircraft_icao'] = $aircraft_data[1];
416
+					}
417
+				}
418
+				/*
419 419
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
420 420
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
421 421
 	    		*/
422
-	    		$data['format_source'] = $value['format'];
422
+				$data['format_source'] = $value['format'];
423 423
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
424
-    			if ($line[3] == 'PILOT') $SI->add($data);
424
+				if ($line[3] == 'PILOT') $SI->add($data);
425 425
 			elseif ($line[3] == 'ATC') {
426 426
 				//print_r($data);
427 427
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -439,247 +439,247 @@  discard block
 block discarded – undo
439 439
 				if (!isset($data['source_name'])) $data['source_name'] = '';
440 440
 				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
441 441
 			}
442
-    			unset($data);
443
-    		    }
444
-    		}
445
-    	    }
446
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
447
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
448
-    	    $last_exec[$id]['last'] = time();
449
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
450
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
451
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
452
-	    if ($buffer != '') {
453
-	    $all_data = json_decode($buffer,true);
454
-	    if (isset($all_data['acList'])) {
442
+				unset($data);
443
+				}
444
+			}
445
+			}
446
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
447
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
448
+			$last_exec[$id]['last'] = time();
449
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
450
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
451
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
452
+		if ($buffer != '') {
453
+		$all_data = json_decode($buffer,true);
454
+		if (isset($all_data['acList'])) {
455 455
 		$reset = 0;
456 456
 		foreach ($all_data['acList'] as $line) {
457
-		    $data = array();
458
-		    $data['hex'] = $line['Icao']; // hex
459
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
460
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
461
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
462
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
463
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
464
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
465
-		    //$data['verticalrate'] = $line['']; // verticale rate
466
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
467
-		    $data['emergency'] = ''; // emergency
468
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
469
-		    /*
457
+			$data = array();
458
+			$data['hex'] = $line['Icao']; // hex
459
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
460
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
461
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
462
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
463
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
464
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
465
+			//$data['verticalrate'] = $line['']; // verticale rate
466
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
467
+			$data['emergency'] = ''; // emergency
468
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
469
+			/*
470 470
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
471 471
 		    else $data['datetime'] = date('Y-m-d H:i:s');
472 472
 		    */
473
-		    $data['datetime'] = date('Y-m-d H:i:s');
474
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
475
-	    	    $data['format_source'] = 'aircraftlistjson';
476
-		    $data['id_source'] = $id_source;
477
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
478
-		    if (isset($data['datetime'])) $SI->add($data);
479
-		    unset($data);
473
+			$data['datetime'] = date('Y-m-d H:i:s');
474
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
475
+				$data['format_source'] = 'aircraftlistjson';
476
+			$data['id_source'] = $id_source;
477
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
478
+			if (isset($data['datetime'])) $SI->add($data);
479
+			unset($data);
480 480
 		}
481
-	    } else {
481
+		} else {
482 482
 		$reset = 0;
483 483
 		foreach ($all_data as $line) {
484
-		    $data = array();
485
-		    $data['hex'] = $line['hex']; // hex
486
-		    $data['ident'] = $line['flight']; // ident
487
-		    $data['altitude'] = $line['altitude']; // altitude
488
-		    $data['speed'] = $line['speed']; // speed
489
-		    $data['heading'] = $line['track']; // heading
490
-		    $data['latitude'] = $line['lat']; // lat
491
-		    $data['longitude'] = $line['lon']; // long
492
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
493
-		    $data['squawk'] = $line['squawk']; // squawk
494
-		    $data['emergency'] = ''; // emergency
495
-		    $data['datetime'] = date('Y-m-d H:i:s');
496
-	    	    $data['format_source'] = 'aircraftlistjson';
497
-    		    $data['id_source'] = $id_source;
498
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
499
-		    $SI->add($data);
500
-		    unset($data);
484
+			$data = array();
485
+			$data['hex'] = $line['hex']; // hex
486
+			$data['ident'] = $line['flight']; // ident
487
+			$data['altitude'] = $line['altitude']; // altitude
488
+			$data['speed'] = $line['speed']; // speed
489
+			$data['heading'] = $line['track']; // heading
490
+			$data['latitude'] = $line['lat']; // lat
491
+			$data['longitude'] = $line['lon']; // long
492
+			$data['verticalrate'] = $line['vrt']; // verticale rate
493
+			$data['squawk'] = $line['squawk']; // squawk
494
+			$data['emergency'] = ''; // emergency
495
+			$data['datetime'] = date('Y-m-d H:i:s');
496
+				$data['format_source'] = 'aircraftlistjson';
497
+				$data['id_source'] = $id_source;
498
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
499
+			$SI->add($data);
500
+			unset($data);
501
+		}
501 502
 		}
502
-	    }
503
-	    }
504
-    	    //$last_exec['aircraftlistjson'] = time();
505
-    	    $last_exec[$id]['last'] = time();
506
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
507
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
508
-	    $buffer = $Common->getData($value['host']);
509
-	    $all_data = json_decode($buffer,true);
510
-	    if (isset($all_data['planes'])) {
503
+		}
504
+			//$last_exec['aircraftlistjson'] = time();
505
+			$last_exec[$id]['last'] = time();
506
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
507
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
508
+		$buffer = $Common->getData($value['host']);
509
+		$all_data = json_decode($buffer,true);
510
+		if (isset($all_data['planes'])) {
511 511
 		$reset = 0;
512 512
 		foreach ($all_data['planes'] as $key => $line) {
513
-		    $data = array();
514
-		    $data['hex'] = $key; // hex
515
-		    $data['ident'] = $line[3]; // ident
516
-		    $data['altitude'] = $line[6]; // altitude
517
-		    $data['speed'] = $line[8]; // speed
518
-		    $data['heading'] = $line[7]; // heading
519
-		    $data['latitude'] = $line[4]; // lat
520
-		    $data['longitude'] = $line[5]; // long
521
-		    //$data['verticalrate'] = $line[]; // verticale rate
522
-		    $data['squawk'] = $line[10]; // squawk
523
-		    $data['emergency'] = ''; // emergency
524
-		    $data['registration'] = $line[2];
525
-		    $data['aircraft_icao'] = $line[0];
526
-		    $deparr = explode('-',$line[1]);
527
-		    if (count($deparr) == 2) {
513
+			$data = array();
514
+			$data['hex'] = $key; // hex
515
+			$data['ident'] = $line[3]; // ident
516
+			$data['altitude'] = $line[6]; // altitude
517
+			$data['speed'] = $line[8]; // speed
518
+			$data['heading'] = $line[7]; // heading
519
+			$data['latitude'] = $line[4]; // lat
520
+			$data['longitude'] = $line[5]; // long
521
+			//$data['verticalrate'] = $line[]; // verticale rate
522
+			$data['squawk'] = $line[10]; // squawk
523
+			$data['emergency'] = ''; // emergency
524
+			$data['registration'] = $line[2];
525
+			$data['aircraft_icao'] = $line[0];
526
+			$deparr = explode('-',$line[1]);
527
+			if (count($deparr) == 2) {
528 528
 			$data['departure_airport_icao'] = $deparr[0];
529 529
 			$data['arrival_airport_icao'] = $deparr[1];
530
-		    }
531
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
532
-	    	    $data['format_source'] = 'planeupdatefaa';
533
-    		    $data['id_source'] = $id_source;
534
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
535
-		    $SI->add($data);
536
-		    unset($data);
530
+			}
531
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
532
+				$data['format_source'] = 'planeupdatefaa';
533
+				$data['id_source'] = $id_source;
534
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
535
+			$SI->add($data);
536
+			unset($data);
537
+		}
537 538
 		}
538
-	    }
539
-    	    //$last_exec['planeupdatefaa'] = time();
540
-    	    $last_exec[$id]['last'] = time();
541
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
542
-	    $buffer = $Common->getData($value['host']);
543
-	    $all_data = json_decode($buffer,true);
544
-	    if (isset($all_data['states'])) {
539
+			//$last_exec['planeupdatefaa'] = time();
540
+			$last_exec[$id]['last'] = time();
541
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
542
+		$buffer = $Common->getData($value['host']);
543
+		$all_data = json_decode($buffer,true);
544
+		if (isset($all_data['states'])) {
545 545
 		$reset = 0;
546 546
 		foreach ($all_data['states'] as $key => $line) {
547
-		    $data = array();
548
-		    $data['hex'] = $line[0]; // hex
549
-		    $data['ident'] = trim($line[1]); // ident
550
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
551
-		    $data['speed'] = round($line[9]*1.94384); // speed
552
-		    $data['heading'] = round($line[10]); // heading
553
-		    $data['latitude'] = $line[5]; // lat
554
-		    $data['longitude'] = $line[6]; // long
555
-		    $data['verticalrate'] = $line[11]; // verticale rate
556
-		    //$data['squawk'] = $line[10]; // squawk
557
-		    //$data['emergency'] = ''; // emergency
558
-		    //$data['registration'] = $line[2];
559
-		    //$data['aircraft_icao'] = $line[0];
560
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
561
-	    	    $data['format_source'] = 'opensky';
562
-    		    $data['id_source'] = $id_source;
563
-		    $SI->add($data);
564
-		    unset($data);
547
+			$data = array();
548
+			$data['hex'] = $line[0]; // hex
549
+			$data['ident'] = trim($line[1]); // ident
550
+			$data['altitude'] = round($line[7]*3.28084); // altitude
551
+			$data['speed'] = round($line[9]*1.94384); // speed
552
+			$data['heading'] = round($line[10]); // heading
553
+			$data['latitude'] = $line[5]; // lat
554
+			$data['longitude'] = $line[6]; // long
555
+			$data['verticalrate'] = $line[11]; // verticale rate
556
+			//$data['squawk'] = $line[10]; // squawk
557
+			//$data['emergency'] = ''; // emergency
558
+			//$data['registration'] = $line[2];
559
+			//$data['aircraft_icao'] = $line[0];
560
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
561
+				$data['format_source'] = 'opensky';
562
+				$data['id_source'] = $id_source;
563
+			$SI->add($data);
564
+			unset($data);
565
+		}
565 566
 		}
566
-	    }
567
-    	    //$last_exec['planeupdatefaa'] = time();
568
-    	    $last_exec[$id]['last'] = time();
569
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
570
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
571
-	    //$buffer = $Common->getData($hosts[$id]);
572
-	    $buffer = $Common->getData($value['host']);
573
-	    $all_data = json_decode($buffer,true);
574
-	    if (!empty($all_data)) $reset = 0;
575
-	    foreach ($all_data as $key => $line) {
567
+			//$last_exec['planeupdatefaa'] = time();
568
+			$last_exec[$id]['last'] = time();
569
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
570
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
571
+		//$buffer = $Common->getData($hosts[$id]);
572
+		$buffer = $Common->getData($value['host']);
573
+		$all_data = json_decode($buffer,true);
574
+		if (!empty($all_data)) $reset = 0;
575
+		foreach ($all_data as $key => $line) {
576 576
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
577
-		    $data = array();
578
-		    $data['hex'] = $line[0];
579
-		    $data['ident'] = $line[16]; //$line[13]
580
-	    	    $data['altitude'] = $line[4]; // altitude
581
-	    	    $data['speed'] = $line[5]; // speed
582
-	    	    $data['heading'] = $line[3]; // heading
583
-	    	    $data['latitude'] = $line[1]; // lat
584
-	    	    $data['longitude'] = $line[2]; // long
585
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
586
-	    	    $data['squawk'] = $line[6]; // squawk
587
-	    	    $data['aircraft_icao'] = $line[8];
588
-	    	    $data['registration'] = $line[9];
589
-		    $data['departure_airport_iata'] = $line[11];
590
-		    $data['arrival_airport_iata'] = $line[12];
591
-	    	    $data['emergency'] = ''; // emergency
592
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
593
-	    	    $data['format_source'] = 'fr24json';
594
-    		    $data['id_source'] = $id_source;
595
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
596
-		    $SI->add($data);
597
-		    unset($data);
577
+			$data = array();
578
+			$data['hex'] = $line[0];
579
+			$data['ident'] = $line[16]; //$line[13]
580
+				$data['altitude'] = $line[4]; // altitude
581
+				$data['speed'] = $line[5]; // speed
582
+				$data['heading'] = $line[3]; // heading
583
+				$data['latitude'] = $line[1]; // lat
584
+				$data['longitude'] = $line[2]; // long
585
+				$data['verticalrate'] = $line[15]; // verticale rate
586
+				$data['squawk'] = $line[6]; // squawk
587
+				$data['aircraft_icao'] = $line[8];
588
+				$data['registration'] = $line[9];
589
+			$data['departure_airport_iata'] = $line[11];
590
+			$data['arrival_airport_iata'] = $line[12];
591
+				$data['emergency'] = ''; // emergency
592
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
593
+				$data['format_source'] = 'fr24json';
594
+				$data['id_source'] = $id_source;
595
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
596
+			$SI->add($data);
597
+			unset($data);
598
+		}
598 599
 		}
599
-	    }
600
-    	    //$last_exec['fr24json'] = time();
601
-    	    $last_exec[$id]['last'] = time();
602
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
603
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
604
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
605
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
606
-	    //echo $buffer;
607
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
608
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
609
-	    $all_data = json_decode($buffer,true);
610
-	    if (json_last_error() != JSON_ERROR_NONE) {
600
+			//$last_exec['fr24json'] = time();
601
+			$last_exec[$id]['last'] = time();
602
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
603
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
604
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
605
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
606
+		//echo $buffer;
607
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
608
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
609
+		$all_data = json_decode($buffer,true);
610
+		if (json_last_error() != JSON_ERROR_NONE) {
611 611
 		die(json_last_error_msg());
612
-	    }
613
-	    if (isset($all_data['mrkrs'])) {
612
+		}
613
+		if (isset($all_data['mrkrs'])) {
614 614
 		$reset = 0;
615 615
 		foreach ($all_data['mrkrs'] as $key => $line) {
616
-		    if (isset($line['inf'])) {
616
+			if (isset($line['inf'])) {
617 617
 			$data = array();
618 618
 			$data['hex'] = $line['inf']['ia'];
619 619
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
620
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
621
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
622
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
623
-	    		$data['latitude'] = $line['pt'][0]; // lat
624
-	    		$data['longitude'] = $line['pt'][1]; // long
625
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
626
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
627
-	    		//$data['aircraft_icao'] = $line[8];
628
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
620
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
621
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
622
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
623
+				$data['latitude'] = $line['pt'][0]; // lat
624
+				$data['longitude'] = $line['pt'][1]; // long
625
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
626
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
627
+				//$data['aircraft_icao'] = $line[8];
628
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
629 629
 			//$data['departure_airport_iata'] = $line[11];
630 630
 			//$data['arrival_airport_iata'] = $line[12];
631
-	    		//$data['emergency'] = ''; // emergency
631
+				//$data['emergency'] = ''; // emergency
632 632
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
633
-	    		$data['format_source'] = 'radarvirtueljson';
634
-    			$data['id_source'] = $id_source;
633
+				$data['format_source'] = 'radarvirtueljson';
634
+				$data['id_source'] = $id_source;
635 635
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
636 636
 			$SI->add($data);
637 637
 			unset($data);
638
-		    }
638
+			}
639
+		}
639 640
 		}
640
-	    }
641
-    	    //$last_exec['radarvirtueljson'] = time();
642
-    	    $last_exec[$id]['last'] = time();
643
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
644
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
645
-	    //$buffer = $Common->getData($hosts[$id]);
646
-	    $buffer = $Common->getData($value['host'].'?'.time());
647
-	    $all_data = json_decode(utf8_encode($buffer),true);
641
+			//$last_exec['radarvirtueljson'] = time();
642
+			$last_exec[$id]['last'] = time();
643
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
644
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
645
+		//$buffer = $Common->getData($hosts[$id]);
646
+		$buffer = $Common->getData($value['host'].'?'.time());
647
+		$all_data = json_decode(utf8_encode($buffer),true);
648 648
 	    
649
-	    if (isset($all_data['pireps'])) {
649
+		if (isset($all_data['pireps'])) {
650 650
 		$reset = 0;
651
-	        foreach ($all_data['pireps'] as $line) {
652
-		    $data = array();
653
-		    $data['id'] = $line['id'];
654
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
655
-		    $data['ident'] = $line['callsign']; // ident
656
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
658
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
659
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
660
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
661
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
662
-		    $data['latitude'] = $line['lat']; // lat
663
-		    $data['longitude'] = $line['lon']; // long
664
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
665
-		    //$data['squawk'] = $line['squawk']; // squawk
666
-		    //$data['emergency'] = ''; // emergency
667
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
668
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
669
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
670
-		    //$data['arrival_airport_time'] = $line['arrtime'];
671
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
672
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
673
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
674
-		    else $data['info'] = '';
675
-		    $data['format_source'] = 'pireps';
676
-    		    $data['id_source'] = $id_source;
677
-		    $data['datetime'] = date('Y-m-d H:i:s');
678
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
679
-		    if ($line['icon'] == 'plane') {
651
+			foreach ($all_data['pireps'] as $line) {
652
+			$data = array();
653
+			$data['id'] = $line['id'];
654
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
655
+			$data['ident'] = $line['callsign']; // ident
656
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
658
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
659
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
660
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
661
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
662
+			$data['latitude'] = $line['lat']; // lat
663
+			$data['longitude'] = $line['lon']; // long
664
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
665
+			//$data['squawk'] = $line['squawk']; // squawk
666
+			//$data['emergency'] = ''; // emergency
667
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
668
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
669
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
670
+			//$data['arrival_airport_time'] = $line['arrtime'];
671
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
672
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
673
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
674
+			else $data['info'] = '';
675
+			$data['format_source'] = 'pireps';
676
+				$data['id_source'] = $id_source;
677
+			$data['datetime'] = date('Y-m-d H:i:s');
678
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
679
+			if ($line['icon'] == 'plane') {
680 680
 			$SI->add($data);
681
-		    //    print_r($data);
682
-    		    } elseif ($line['icon'] == 'ct') {
681
+			//    print_r($data);
682
+				} elseif ($line['icon'] == 'ct') {
683 683
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
684 684
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
685 685
 			$typec = substr($data['ident'],-3);
@@ -694,163 +694,163 @@  discard block
 block discarded – undo
694 694
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
695 695
 			else $data['type'] = 'Observer';
696 696
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
697
-		    }
698
-		    unset($data);
697
+			}
698
+			unset($data);
699
+		}
699 700
 		}
700
-	    }
701
-    	    //$last_exec['pirepsjson'] = time();
702
-    	    $last_exec[$id]['last'] = time();
703
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
704
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705
-	    //$buffer = $Common->getData($hosts[$id]);
706
-	    if ($globalDebug) echo 'Get Data...'."\n";
707
-	    $buffer = $Common->getData($value['host']);
708
-	    $all_data = json_decode($buffer,true);
709
-	    if ($buffer != '' && is_array($all_data)) {
701
+			//$last_exec['pirepsjson'] = time();
702
+			$last_exec[$id]['last'] = time();
703
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
704
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705
+		//$buffer = $Common->getData($hosts[$id]);
706
+		if ($globalDebug) echo 'Get Data...'."\n";
707
+		$buffer = $Common->getData($value['host']);
708
+		$all_data = json_decode($buffer,true);
709
+		if ($buffer != '' && is_array($all_data)) {
710 710
 		$reset = 0;
711 711
 		foreach ($all_data as $line) {
712
-	    	    $data = array();
713
-	    	    //$data['id'] = $line['id']; // id not usable
714
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
715
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
716
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
718
-	    	    $data['ident'] = $line['flightnum']; // ident
719
-	    	    $data['altitude'] = $line['alt']; // altitude
720
-	    	    $data['speed'] = $line['gs']; // speed
721
-	    	    $data['heading'] = $line['heading']; // heading
722
-	    	    $data['latitude'] = $line['lat']; // lat
723
-	    	    $data['longitude'] = $line['lng']; // long
724
-	    	    $data['verticalrate'] = ''; // verticale rate
725
-	    	    $data['squawk'] = ''; // squawk
726
-	    	    $data['emergency'] = ''; // emergency
727
-	    	    //$data['datetime'] = $line['lastupdate'];
728
-	    	    $data['last_update'] = $line['lastupdate'];
729
-		    $data['datetime'] = date('Y-m-d H:i:s');
730
-	    	    $data['departure_airport_icao'] = $line['depicao'];
731
-	    	    $data['departure_airport_time'] = $line['deptime'];
732
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
733
-    		    $data['arrival_airport_time'] = $line['arrtime'];
734
-    		    $data['registration'] = $line['aircraft'];
735
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
736
-		    if (isset($line['aircraftname'])) {
712
+				$data = array();
713
+				//$data['id'] = $line['id']; // id not usable
714
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
715
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
716
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
718
+				$data['ident'] = $line['flightnum']; // ident
719
+				$data['altitude'] = $line['alt']; // altitude
720
+				$data['speed'] = $line['gs']; // speed
721
+				$data['heading'] = $line['heading']; // heading
722
+				$data['latitude'] = $line['lat']; // lat
723
+				$data['longitude'] = $line['lng']; // long
724
+				$data['verticalrate'] = ''; // verticale rate
725
+				$data['squawk'] = ''; // squawk
726
+				$data['emergency'] = ''; // emergency
727
+				//$data['datetime'] = $line['lastupdate'];
728
+				$data['last_update'] = $line['lastupdate'];
729
+			$data['datetime'] = date('Y-m-d H:i:s');
730
+				$data['departure_airport_icao'] = $line['depicao'];
731
+				$data['departure_airport_time'] = $line['deptime'];
732
+				$data['arrival_airport_icao'] = $line['arricao'];
733
+				$data['arrival_airport_time'] = $line['arrtime'];
734
+				$data['registration'] = $line['aircraft'];
735
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
736
+			if (isset($line['aircraftname'])) {
737 737
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
738 738
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
739
-	    		$aircraft_data = explode('-',$line['aircraftname']);
740
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742
-	    		else {
743
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
744
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
746
-	    		}
747
-	    	    }
748
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
749
-    		    $data['id_source'] = $id_source;
750
-	    	    $data['format_source'] = 'phpvmacars';
751
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
752
-		    $SI->add($data);
753
-		    unset($data);
739
+				$aircraft_data = explode('-',$line['aircraftname']);
740
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742
+				else {
743
+					$aircraft_data = explode(' ',$line['aircraftname']);
744
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745
+					else $data['aircraft_icao'] = $line['aircraftname'];
746
+				}
747
+				}
748
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
749
+				$data['id_source'] = $id_source;
750
+				$data['format_source'] = 'phpvmacars';
751
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
752
+			$SI->add($data);
753
+			unset($data);
754 754
 		}
755 755
 		if ($globalDebug) echo 'No more data...'."\n";
756 756
 		unset($buffer);
757 757
 		unset($all_data);
758
-	    }
759
-    	    //$last_exec['phpvmacars'] = time();
760
-    	    $last_exec[$id]['last'] = time();
761
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
762
-	    //$buffer = $Common->getData($hosts[$id]);
763
-	    if ($globalDebug) echo 'Get Data...'."\n";
764
-	    $buffer = $Common->getData($value['host']);
765
-	    $all_data = json_decode($buffer,true);
766
-	    if ($buffer != '' && is_array($all_data)) {
758
+		}
759
+			//$last_exec['phpvmacars'] = time();
760
+			$last_exec[$id]['last'] = time();
761
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
762
+		//$buffer = $Common->getData($hosts[$id]);
763
+		if ($globalDebug) echo 'Get Data...'."\n";
764
+		$buffer = $Common->getData($value['host']);
765
+		$all_data = json_decode($buffer,true);
766
+		if ($buffer != '' && is_array($all_data)) {
767 767
 		$reset = 0;
768 768
 		foreach ($all_data as $line) {
769
-	    	    $data = array();
770
-	    	    //$data['id'] = $line['id']; // id not usable
771
-	    	    $data['id'] = trim($line['flight_id']);
772
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
773
-	    	    $data['pilot_name'] = $line['pilot_name'];
774
-	    	    $data['pilot_id'] = $line['pilot_id'];
775
-	    	    $data['ident'] = trim($line['callsign']); // ident
776
-	    	    $data['altitude'] = $line['altitude']; // altitude
777
-	    	    $data['speed'] = $line['gs']; // speed
778
-	    	    $data['heading'] = $line['heading']; // heading
779
-	    	    $data['latitude'] = $line['latitude']; // lat
780
-	    	    $data['longitude'] = $line['longitude']; // long
781
-	    	    $data['verticalrate'] = ''; // verticale rate
782
-	    	    $data['squawk'] = ''; // squawk
783
-	    	    $data['emergency'] = ''; // emergency
784
-	    	    //$data['datetime'] = $line['lastupdate'];
785
-	    	    $data['last_update'] = $line['last_update'];
786
-		    $data['datetime'] = date('Y-m-d H:i:s');
787
-	    	    $data['departure_airport_icao'] = $line['departure'];
788
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
789
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
790
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
791
-    		    //$data['registration'] = $line['aircraft'];
792
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
793
-	    	    $data['aircraft_icao'] = $line['plane_type'];
794
-    		    $data['id_source'] = $id_source;
795
-	    	    $data['format_source'] = 'vam';
796
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
797
-		    $SI->add($data);
798
-		    unset($data);
769
+				$data = array();
770
+				//$data['id'] = $line['id']; // id not usable
771
+				$data['id'] = trim($line['flight_id']);
772
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
773
+				$data['pilot_name'] = $line['pilot_name'];
774
+				$data['pilot_id'] = $line['pilot_id'];
775
+				$data['ident'] = trim($line['callsign']); // ident
776
+				$data['altitude'] = $line['altitude']; // altitude
777
+				$data['speed'] = $line['gs']; // speed
778
+				$data['heading'] = $line['heading']; // heading
779
+				$data['latitude'] = $line['latitude']; // lat
780
+				$data['longitude'] = $line['longitude']; // long
781
+				$data['verticalrate'] = ''; // verticale rate
782
+				$data['squawk'] = ''; // squawk
783
+				$data['emergency'] = ''; // emergency
784
+				//$data['datetime'] = $line['lastupdate'];
785
+				$data['last_update'] = $line['last_update'];
786
+			$data['datetime'] = date('Y-m-d H:i:s');
787
+				$data['departure_airport_icao'] = $line['departure'];
788
+				//$data['departure_airport_time'] = $line['departure_time'];
789
+				$data['arrival_airport_icao'] = $line['arrival'];
790
+				//$data['arrival_airport_time'] = $line['arrival_time'];
791
+				//$data['registration'] = $line['aircraft'];
792
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
793
+				$data['aircraft_icao'] = $line['plane_type'];
794
+				$data['id_source'] = $id_source;
795
+				$data['format_source'] = 'vam';
796
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
797
+			$SI->add($data);
798
+			unset($data);
799 799
 		}
800 800
 		if ($globalDebug) echo 'No more data...'."\n";
801 801
 		unset($buffer);
802 802
 		unset($all_data);
803
-	    }
804
-    	    //$last_exec['phpvmacars'] = time();
805
-    	    $last_exec[$id]['last'] = time();
803
+		}
804
+			//$last_exec['phpvmacars'] = time();
805
+			$last_exec[$id]['last'] = time();
806 806
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
807 807
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
808
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
809
-    	    //$last_exec[$id]['last'] = time();
808
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
809
+			//$last_exec[$id]['last'] = time();
810 810
 
811
-	    //$read = array( $sockets[$id] );
812
-	    $read = $sockets;
813
-	    $write = NULL;
814
-	    $e = NULL;
815
-	    $n = socket_select($read, $write, $e, $timeout);
816
-	    if ($e != NULL) var_dump($e);
817
-	    if ($n > 0) {
811
+		//$read = array( $sockets[$id] );
812
+		$read = $sockets;
813
+		$write = NULL;
814
+		$e = NULL;
815
+		$n = socket_select($read, $write, $e, $timeout);
816
+		if ($e != NULL) var_dump($e);
817
+		if ($n > 0) {
818 818
 		$reset = 0;
819 819
 		foreach ($read as $nb => $r) {
820
-		    //$value = $formats[$nb];
821
-		    $format = $globalSources[$nb]['format'];
822
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
823
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
824
-        	    } else {
825
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
826
-	    	    }
827
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
828
-        	    //echo $buffer."\n";
829
-		    // lets play nice and handle signals such as ctrl-c/kill properly
830
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
831
-		    $error = false;
832
-		    //$SI::del();
833
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
834
-		    // SBS format is CSV format
835
-		    if ($buffer != '') {
820
+			//$value = $formats[$nb];
821
+			$format = $globalSources[$nb]['format'];
822
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
823
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
824
+				} else {
825
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
826
+				}
827
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
828
+				//echo $buffer."\n";
829
+			// lets play nice and handle signals such as ctrl-c/kill properly
830
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
831
+			$error = false;
832
+			//$SI::del();
833
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
834
+			// SBS format is CSV format
835
+			if ($buffer != '') {
836 836
 			$tt[$format] = 0;
837 837
 			if ($format == 'acarssbs3') {
838
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
839
-			    $ACARS->add(trim($buffer));
840
-			    $ACARS->deleteLiveAcarsData();
838
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
839
+				$ACARS->add(trim($buffer));
840
+				$ACARS->deleteLiveAcarsData();
841 841
 			} elseif ($format == 'raw') {
842
-			    // AVR format
843
-			    $data = $SBS->parse($buffer);
844
-			    if (is_array($data)) {
842
+				// AVR format
843
+				$data = $SBS->parse($buffer);
844
+				if (is_array($data)) {
845 845
 				$data['datetime'] = date('Y-m-d H:i:s');
846 846
 				$data['format_source'] = 'raw';
847 847
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
848
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
849
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
850
-                            }
851
-                        } elseif ($format == 'flightgearsp') {
852
-                    	    //echo $buffer."\n";
853
-                    	    if (strlen($buffer) > 5) {
848
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
849
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
850
+							}
851
+						} elseif ($format == 'flightgearsp') {
852
+							//echo $buffer."\n";
853
+							if (strlen($buffer) > 5) {
854 854
 				$line = explode(',',$buffer);
855 855
 				$data = array();
856 856
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -866,124 +866,124 @@  discard block
 block discarded – undo
866 866
 				$data['format_source'] = 'flightgearsp';
867 867
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
868 868
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
869
-			    }
870
-                        } elseif ($format == 'acars') {
871
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
872
-			    $ACARS->add(trim($buffer));
873
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
874
-			    $ACARS->deleteLiveAcarsData();
869
+				}
870
+						} elseif ($format == 'acars') {
871
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
872
+				$ACARS->add(trim($buffer));
873
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
874
+				$ACARS->deleteLiveAcarsData();
875 875
 			} elseif ($format == 'flightgearmp') {
876
-			    if (substr($buffer,0,1) != '#') {
876
+				if (substr($buffer,0,1) != '#') {
877 877
 				$data = array();
878 878
 				//echo $buffer."\n";
879 879
 				$line = explode(' ',$buffer);
880 880
 				if (count($line) == 11) {
881
-				    $userserver = explode('@',$line[0]);
882
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
883
-				    $data['ident'] = $userserver[0];
884
-				    $data['registration'] = $userserver[0];
885
-				    $data['latitude'] = $line[4];
886
-				    $data['longitude'] = $line[5];
887
-				    $data['altitude'] = $line[6];
888
-				    $data['datetime'] = date('Y-m-d H:i:s');
889
-				    $aircraft_type = $line[10];
890
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
891
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
892
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
881
+					$userserver = explode('@',$line[0]);
882
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
883
+					$data['ident'] = $userserver[0];
884
+					$data['registration'] = $userserver[0];
885
+					$data['latitude'] = $line[4];
886
+					$data['longitude'] = $line[5];
887
+					$data['altitude'] = $line[6];
888
+					$data['datetime'] = date('Y-m-d H:i:s');
889
+					$aircraft_type = $line[10];
890
+					$aircraft_type = preg_split(':/:',$aircraft_type);
891
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
892
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
893
+				}
893 894
 				}
894
-			    }
895 895
 			} elseif ($format == 'beast') {
896
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
897
-			    die;
896
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
897
+				die;
898 898
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
899
-			    $line = explode("\t", $buffer);
900
-			    for($k = 0; $k < count($line); $k=$k+2) {
899
+				$line = explode("\t", $buffer);
900
+				for($k = 0; $k < count($line); $k=$k+2) {
901 901
 				$key = $line[$k];
902
-			        $lined[$key] = $line[$k+1];
903
-			    }
904
-    			    if (count($lined) > 3) {
905
-    				$data['hex'] = $lined['hexid'];
906
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907
-    				$data['datetime'] = date('Y-m-d H:i:s');;
908
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
911
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
912
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
913
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
914
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
915
-    				$data['id_source'] = $id_source;
916
-    				$data['format_source'] = 'tsv';
917
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
918
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
919
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
920
-    				unset($lined);
921
-    				unset($data);
922
-    			    } else $error = true;
902
+					$lined[$key] = $line[$k+1];
903
+				}
904
+					if (count($lined) > 3) {
905
+					$data['hex'] = $lined['hexid'];
906
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907
+					$data['datetime'] = date('Y-m-d H:i:s');;
908
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
911
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
912
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
913
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
914
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
915
+					$data['id_source'] = $id_source;
916
+					$data['format_source'] = 'tsv';
917
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
918
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
919
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
920
+					unset($lined);
921
+					unset($data);
922
+					} else $error = true;
923 923
 			} elseif ($format == 'aprs' && $use_aprs) {
924
-			    if ($aprs_connect == 0) {
924
+				if ($aprs_connect == 0) {
925 925
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
926 926
 				$aprs_connect = 1;
927
-			    }
927
+				}
928 928
 			    
929
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
929
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
930 930
 				$aprs_last_tx = time();
931 931
 				$data_aprs = "# Keep alive";
932 932
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
933
-			    }
933
+				}
934 934
 			    
935
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
936
-			    $buffer = str_replace('APRS <- ','',$buffer);
937
-			    $buffer = str_replace('APRS -> ','',$buffer);
938
-			    //echo $buffer."\n";
939
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
935
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
936
+				$buffer = str_replace('APRS <- ','',$buffer);
937
+				$buffer = str_replace('APRS -> ','',$buffer);
938
+				//echo $buffer."\n";
939
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
940 940
 				$line = $APRS->parse($buffer);
941 941
 				//print_r($line);
942 942
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
943
-				    $aprs_last_tx = time();
944
-				    $data = array();
945
-				    //print_r($line);
946
-				    $data['hex'] = $line['address'];
947
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
948
-				    else $data['datetime'] = date('Y-m-d H:i:s');
949
-				    //$data['datetime'] = date('Y-m-d H:i:s');
950
-				    $data['ident'] = $line['ident'];
951
-				    $data['latitude'] = $line['latitude'];
952
-				    $data['longitude'] = $line['longitude'];
953
-				    //$data['verticalrate'] = $line[16];
954
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
955
-				    else $data['speed'] = 0;
956
-				    $data['altitude'] = $line['altitude'];
957
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
958
-				    //else $data['heading'] = 0;
959
-				    $data['aircraft_type'] = $line['stealth'];
960
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
961
-    				    $data['id_source'] = $id_source;
962
-				    $data['format_source'] = 'aprs';
963
-				    $data['source_name'] = $line['source'];
964
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
965
-				    $currentdate = date('Y-m-d H:i:s');
966
-				    $aprsdate = strtotime($data['datetime']);
967
-				    // Accept data if time <= system time + 20s
968
-				    if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
943
+					$aprs_last_tx = time();
944
+					$data = array();
945
+					//print_r($line);
946
+					$data['hex'] = $line['address'];
947
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
948
+					else $data['datetime'] = date('Y-m-d H:i:s');
949
+					//$data['datetime'] = date('Y-m-d H:i:s');
950
+					$data['ident'] = $line['ident'];
951
+					$data['latitude'] = $line['latitude'];
952
+					$data['longitude'] = $line['longitude'];
953
+					//$data['verticalrate'] = $line[16];
954
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
955
+					else $data['speed'] = 0;
956
+					$data['altitude'] = $line['altitude'];
957
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
958
+					//else $data['heading'] = 0;
959
+					$data['aircraft_type'] = $line['stealth'];
960
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
961
+						$data['id_source'] = $id_source;
962
+					$data['format_source'] = 'aprs';
963
+					$data['source_name'] = $line['source'];
964
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
965
+					$currentdate = date('Y-m-d H:i:s');
966
+					$aprsdate = strtotime($data['datetime']);
967
+					// Accept data if time <= system time + 20s
968
+					if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
969 969
 					$send = $SI->add($data);
970
-				    } else {
970
+					} else {
971 971
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
972 972
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
973
-				    }
974
-				    unset($data);
973
+					}
974
+					unset($data);
975 975
 				} 
976 976
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
977 977
 					echo '!! Weather Station not yet supported'."\n";
978 978
 				}
979 979
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
980 980
 				//elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
981
-			    }
981
+				}
982 982
 			} else {
983
-			    $line = explode(',', $buffer);
984
-    			    if (count($line) > 20) {
985
-    			    	$data['hex'] = $line[4];
986
-    				/*
983
+				$line = explode(',', $buffer);
984
+					if (count($line) > 20) {
985
+						$data['hex'] = $line[4];
986
+					/*
987 987
     				$data['datetime'] = $line[6].' '.$line[7];
988 988
     					date_default_timezone_set($globalTimezone);
989 989
     					$datetime = new DateTime($data['datetime']);
@@ -991,29 +991,29 @@  discard block
 block discarded – undo
991 991
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
992 992
     					date_default_timezone_set('UTC');
993 993
     				*/
994
-    				// Force datetime to current UTC datetime
995
-    				date_default_timezone_set('UTC');
996
-    				$data['datetime'] = date('Y-m-d H:i:s');
997
-    				$data['ident'] = trim($line[10]);
998
-    				$data['latitude'] = $line[14];
999
-    				$data['longitude'] = $line[15];
1000
-    				$data['verticalrate'] = $line[16];
1001
-    				$data['emergency'] = $line[20];
1002
-    				$data['speed'] = $line[12];
1003
-    				$data['squawk'] = $line[17];
1004
-    				$data['altitude'] = $line[11];
1005
-    				$data['heading'] = $line[13];
1006
-    				$data['ground'] = $line[21];
1007
-    				$data['emergency'] = $line[19];
1008
-    				$data['format_source'] = 'sbs';
994
+					// Force datetime to current UTC datetime
995
+					date_default_timezone_set('UTC');
996
+					$data['datetime'] = date('Y-m-d H:i:s');
997
+					$data['ident'] = trim($line[10]);
998
+					$data['latitude'] = $line[14];
999
+					$data['longitude'] = $line[15];
1000
+					$data['verticalrate'] = $line[16];
1001
+					$data['emergency'] = $line[20];
1002
+					$data['speed'] = $line[12];
1003
+					$data['squawk'] = $line[17];
1004
+					$data['altitude'] = $line[11];
1005
+					$data['heading'] = $line[13];
1006
+					$data['ground'] = $line[21];
1007
+					$data['emergency'] = $line[19];
1008
+					$data['format_source'] = 'sbs';
1009 1009
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1010
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1011
-    				$data['id_source'] = $id_source;
1012
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1013
-    				else $error = true;
1014
-    				unset($data);
1015
-    			    } else $error = true;
1016
-			    if ($error) {
1010
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1011
+					$data['id_source'] = $id_source;
1012
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1013
+					else $error = true;
1014
+					unset($data);
1015
+					} else $error = true;
1016
+				if ($error) {
1017 1017
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1018 1018
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1019 1019
 				} else {
@@ -1029,13 +1029,13 @@  discard block
 block discarded – undo
1029 1029
 					connect_all($sourceer);
1030 1030
 					$sourceer = array();
1031 1031
 				}
1032
-			    }
1032
+				}
1033 1033
 			}
1034 1034
 			// Sleep for xxx microseconds
1035 1035
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1036
-		    } else {
1036
+			} else {
1037 1037
 			if ($format == 'flightgearmp') {
1038
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1038
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1039 1039
 				//@socket_close($r);
1040 1040
 				sleep($globalMinFetch);
1041 1041
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1044,9 +1044,9 @@  discard block
 block discarded – undo
1044 1044
 				break;
1045 1045
 				
1046 1046
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1047
-			    if (isset($tt[$format])) $tt[$format]++;
1048
-			    else $tt[$format] = 0;
1049
-			    if ($tt[$format] > 30) {
1047
+				if (isset($tt[$format])) $tt[$format]++;
1048
+				else $tt[$format] = 0;
1049
+				if ($tt[$format] > 30) {
1050 1050
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1051 1051
 				//@socket_close($r);
1052 1052
 				sleep(2);
@@ -1057,23 +1057,23 @@  discard block
 block discarded – undo
1057 1057
 				//connect_all($globalSources);
1058 1058
 				$tt[$format]=0;
1059 1059
 				break;
1060
-			    }
1060
+				}
1061
+			}
1061 1062
 			}
1062
-		    }
1063 1063
 		}
1064
-	    } else {
1064
+		} else {
1065 1065
 		$error = socket_strerror(socket_last_error());
1066 1066
 		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1067 1067
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1068 1068
 			if (isset($globalDebug)) echo "Restarting...\n";
1069 1069
 			// Restart the script if possible
1070 1070
 			if (is_array($sockets)) {
1071
-			    if ($globalDebug) echo "Shutdown all sockets...";
1071
+				if ($globalDebug) echo "Shutdown all sockets...";
1072 1072
 			    
1073
-			    foreach ($sockets as $sock) {
1073
+				foreach ($sockets as $sock) {
1074 1074
 				@socket_shutdown($sock,2);
1075 1075
 				@socket_close($sock);
1076
-			    }
1076
+				}
1077 1077
 			    
1078 1078
 			}
1079 1079
 			if ($globalDebug) echo "Restart all connections...";
@@ -1084,13 +1084,13 @@  discard block
 block discarded – undo
1084 1084
 			if ($reset > 40) exit('Too many attempts...');
1085 1085
 			connect_all($globalSources);
1086 1086
 		}
1087
-	    }
1087
+		}
1088 1088
 	}
1089 1089
 	if ($globalDaemon === false) {
1090
-	    if ($globalDebug) echo 'Check all...'."\n";
1091
-	    $SI->checkAll();
1090
+		if ($globalDebug) echo 'Check all...'."\n";
1091
+		$SI->checkAll();
1092
+	}
1092 1093
 	}
1093
-    }
1094 1094
 }
1095 1095
 
1096 1096
 ?>
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	    die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
43
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
44 44
     }
45 45
 }
46 46
 
47
-$options = getopt('s::',array('source::','server','idsource::'));
47
+$options = getopt('s::', array('source::', 'server', 'idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61 61
     if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
62
+    $SI = new SpotterServer();
63
+} else $SI = new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65
-$SBS=new SBS();
66
-$ACARS=new ACARS($Connection->db);
67
-$Common=new Common();
65
+$SBS = new SBS();
66
+$ACARS = new ACARS($Connection->db);
67
+$Common = new Common();
68 68
 date_default_timezone_set('UTC');
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
72
+    pcntl_signal(SIGINT, function() {
73 73
         global $sockets;
74 74
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75 75
         die("Bye!\n");
@@ -113,35 +113,35 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
116
+    global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
143 143
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
144
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
145 145
         	//$formats[$id] = 'radarvirtueljson';
146 146
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 147
         	//$last_exec['radarvirtueljson'] = 0;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 151
         	    exit(0);
152 152
         	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
153
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
154 154
         	//$formats[$id] = 'planeupdatefaa';
155 155
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 156
         	//$last_exec['planeupdatefaa'] = 0;
@@ -159,26 +159,26 @@  discard block
 block discarded – undo
159 159
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 160
         	    exit(0);
161 161
         	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
162
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
163 163
         	//$formats[$id] = 'phpvmacars';
164 164
         	$globalSources[$id]['format'] = 'phpvmacars';
165 165
         	//$last_exec['phpvmacars'] = 0;
166 166
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
167
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
168 168
         	//$formats[$id] = 'phpvmacars';
169 169
         	$globalSources[$id]['format'] = 'vam';
170 170
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
171
+            } else if (preg_match('/whazzup/i', $host)) {
172 172
         	//$formats[$id] = 'whazzup';
173 173
         	$globalSources[$id]['format'] = 'whazzup';
174 174
         	//$last_exec['whazzup'] = 0;
175 175
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
176
+            } else if (preg_match('/recentpireps/i', $host)) {
177 177
         	//$formats[$id] = 'pirepsjson';
178 178
         	$globalSources[$id]['format'] = 'pirepsjson';
179 179
         	//$last_exec['pirepsjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
181
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
182 182
         	//$formats[$id] = 'fr24json';
183 183
         	$globalSources[$id]['format'] = 'fr24json';
184 184
         	//$last_exec['fr24json'] = 0;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
         	    exit(0);
189 189
         	}
190 190
             //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 192
         	//$formats[$id] = 'tsv';
193 193
         	$globalSources[$id]['format'] = 'tsv';
194 194
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195 195
             }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
197 197
         	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
198
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
199
+	    $hostport = explode(':', $host);
200 200
 	    if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
 		$hostn = $globalSources[$id]['host'];
206 206
 	    }
207 207
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
208
+        	$s = create_socket($hostn, $port, $errno, $errstr);
209 209
     	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
210
+        	$s = create_socket_udp($hostn, $port, $errno, $errstr);
211 211
 	    }
212 212
 	    if ($s) {
213 213
     	        $sockets[$id] = $s;
214 214
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
215
+		    if (preg_match('/aprs/', $hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254 254
 else $timeout = 20;
255 255
 $errno = '';
256
-$errstr='';
256
+$errstr = '';
257 257
 
258 258
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
259 259
 /* Initiate connections to all the hosts simultaneously */
@@ -282,16 +282,16 @@  discard block
 block discarded – undo
282 282
 
283 283
 if ($use_aprs) {
284 284
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
285
-	$APRS=new APRS();
285
+	$APRS = new APRS();
286 286
 	$aprs_connect = 0;
287 287
 	$aprs_keep = 120;
288 288
 	$aprs_last_tx = time();
289 289
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
290
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
290
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
291 291
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
292
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
292
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
293 293
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
294
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
294
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
295 295
 	if ($aprs_full) $aprs_filter = '';
296 296
 
297 297
 	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
@@ -303,12 +303,12 @@  discard block
 block discarded – undo
303 303
 sleep(1);
304 304
 if ($globalDebug) echo "SCAN MODE \n\n";
305 305
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
306
-$endtime = time()+$globalCronEnd;
306
+$endtime = time() + $globalCronEnd;
307 307
 $i = 1;
308 308
 $tt = array();
309 309
 // Delete all ATC
310 310
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
311
-	$ATC=new ATC($Connection->db);
311
+	$ATC = new ATC($Connection->db);
312 312
 }
313 313
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
314 314
 	$ATC->deleteAll();
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
318 318
 while ($i > 0) {
319
-    if (!$globalDaemon) $i = $endtime-time();
319
+    if (!$globalDaemon) $i = $endtime - time();
320 320
     // Delete old ATC
321 321
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
322 322
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	}
331 331
 	if ($max != $globalMinFetch) {
332 332
 	    if ($globalDebug) echo 'Sleeping...'."\n";
333
-	    sleep($globalMinFetch-$max+2);
333
+	    sleep($globalMinFetch - $max + 2);
334 334
 	}
335 335
     }
336 336
 
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	    //$buffer = $Common->getData($hosts[$id]);
344 344
 	    $buffer = $Common->getData($value['host']);
345 345
 	    if ($buffer != '') $reset = 0;
346
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
-	    $buffer = explode('\n',$buffer);
346
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
347
+	    $buffer = explode('\n', $buffer);
348 348
 	    foreach ($buffer as $line) {
349 349
     		if ($line != '' && count($line) > 7) {
350 350
     		    $line = explode(',', $line);
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
374 374
 	    //$buffer = $Common->getData($hosts[$id]);
375 375
 	    $buffer = $Common->getData($value['host']);
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
376
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
377
+	    $buffer = explode('\n', $buffer);
378 378
 	    $reset = 0;
379 379
 	    foreach ($buffer as $line) {
380 380
     		if ($line != '') {
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
386 386
 			$data['pilot_id'] = $line[1];
387 387
 			$data['pilot_name'] = $line[2];
388
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
388
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
389 389
 			$data['ident'] = $line[0]; // ident
390 390
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
391 391
 			$data['speed'] = $line[8]; // speed
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
402 402
 			//if (isset($line[37])) $data['last_update'] = $line[37];
403 403
 		        $data['departure_airport_icao'] = $line[11];
404
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
404
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
405 405
 		        $data['arrival_airport_icao'] = $line[13];
406 406
 			$data['frequency'] = $line[4];
407 407
 			$data['type'] = $line[18];
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
     			$data['id_source'] = $id_source;
411 411
 	    		//$data['arrival_airport_time'] = ;
412 412
 	    		if ($line[9] != '') {
413
-	    		    $aircraft_data = explode('/',$line[9]);
413
+	    		    $aircraft_data = explode('/', $line[9]);
414 414
 	    		    if (isset($aircraft_data[1])) {
415 415
 	    			$data['aircraft_icao'] = $aircraft_data[1];
416 416
 	    		    }
@@ -424,9 +424,9 @@  discard block
 block discarded – undo
424 424
     			if ($line[3] == 'PILOT') $SI->add($data);
425 425
 			elseif ($line[3] == 'ATC') {
426 426
 				//print_r($data);
427
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
428
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
429
-				$typec = substr($data['ident'],-3);
427
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
428
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
429
+				$typec = substr($data['ident'], -3);
430 430
 				if ($typec == 'APP') $data['type'] = 'Approach';
431 431
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
432 432
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
438 438
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
439 439
 				if (!isset($data['source_name'])) $data['source_name'] = '';
440
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
440
+				if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
441 441
 			}
442 442
     			unset($data);
443 443
     		    }
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
     	    $last_exec[$id]['last'] = time();
449 449
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
450 450
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
451
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
451
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
452 452
 	    if ($buffer != '') {
453
-	    $all_data = json_decode($buffer,true);
453
+	    $all_data = json_decode($buffer, true);
454 454
 	    if (isset($all_data['acList'])) {
455 455
 		$reset = 0;
456 456
 		foreach ($all_data['acList'] as $line) {
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
507 507
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
508 508
 	    $buffer = $Common->getData($value['host']);
509
-	    $all_data = json_decode($buffer,true);
509
+	    $all_data = json_decode($buffer, true);
510 510
 	    if (isset($all_data['planes'])) {
511 511
 		$reset = 0;
512 512
 		foreach ($all_data['planes'] as $key => $line) {
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
 		    $data['emergency'] = ''; // emergency
524 524
 		    $data['registration'] = $line[2];
525 525
 		    $data['aircraft_icao'] = $line[0];
526
-		    $deparr = explode('-',$line[1]);
526
+		    $deparr = explode('-', $line[1]);
527 527
 		    if (count($deparr) == 2) {
528 528
 			$data['departure_airport_icao'] = $deparr[0];
529 529
 			$data['arrival_airport_icao'] = $deparr[1];
530 530
 		    }
531
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
531
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
532 532
 	    	    $data['format_source'] = 'planeupdatefaa';
533 533
     		    $data['id_source'] = $id_source;
534 534
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
     	    $last_exec[$id]['last'] = time();
541 541
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
542 542
 	    $buffer = $Common->getData($value['host']);
543
-	    $all_data = json_decode($buffer,true);
543
+	    $all_data = json_decode($buffer, true);
544 544
 	    if (isset($all_data['states'])) {
545 545
 		$reset = 0;
546 546
 		foreach ($all_data['states'] as $key => $line) {
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		    //$data['emergency'] = ''; // emergency
558 558
 		    //$data['registration'] = $line[2];
559 559
 		    //$data['aircraft_icao'] = $line[0];
560
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
560
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
561 561
 	    	    $data['format_source'] = 'opensky';
562 562
     		    $data['id_source'] = $id_source;
563 563
 		    $SI->add($data);
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
571 571
 	    //$buffer = $Common->getData($hosts[$id]);
572 572
 	    $buffer = $Common->getData($value['host']);
573
-	    $all_data = json_decode($buffer,true);
573
+	    $all_data = json_decode($buffer, true);
574 574
 	    if (!empty($all_data)) $reset = 0;
575 575
 	    foreach ($all_data as $key => $line) {
576 576
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -602,11 +602,11 @@  discard block
 block discarded – undo
602 602
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
603 603
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
604 604
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
605
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
605
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
606 606
 	    //echo $buffer;
607
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
608
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
609
-	    $all_data = json_decode($buffer,true);
607
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
608
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
609
+	    $all_data = json_decode($buffer, true);
610 610
 	    if (json_last_error() != JSON_ERROR_NONE) {
611 611
 		die(json_last_error_msg());
612 612
 	    }
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 			//$data['departure_airport_iata'] = $line[11];
630 630
 			//$data['arrival_airport_iata'] = $line[12];
631 631
 	    		//$data['emergency'] = ''; // emergency
632
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
632
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
633 633
 	    		$data['format_source'] = 'radarvirtueljson';
634 634
     			$data['id_source'] = $id_source;
635 635
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -644,14 +644,14 @@  discard block
 block discarded – undo
644 644
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
645 645
 	    //$buffer = $Common->getData($hosts[$id]);
646 646
 	    $buffer = $Common->getData($value['host'].'?'.time());
647
-	    $all_data = json_decode(utf8_encode($buffer),true);
647
+	    $all_data = json_decode(utf8_encode($buffer), true);
648 648
 	    
649 649
 	    if (isset($all_data['pireps'])) {
650 650
 		$reset = 0;
651 651
 	        foreach ($all_data['pireps'] as $line) {
652 652
 		    $data = array();
653 653
 		    $data['id'] = $line['id'];
654
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
654
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
655 655
 		    $data['ident'] = $line['callsign']; // ident
656 656
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657 657
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -680,9 +680,9 @@  discard block
 block discarded – undo
680 680
 			$SI->add($data);
681 681
 		    //    print_r($data);
682 682
     		    } elseif ($line['icon'] == 'ct') {
683
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
684
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
685
-			$typec = substr($data['ident'],-3);
683
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
684
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
685
+			$typec = substr($data['ident'], -3);
686 686
 			$data['type'] = '';
687 687
 			if ($typec == 'APP') $data['type'] = 'Approach';
688 688
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
694 694
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
695 695
 			else $data['type'] = 'Observer';
696
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
696
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
697 697
 		    }
698 698
 		    unset($data);
699 699
 		}
@@ -705,14 +705,14 @@  discard block
 block discarded – undo
705 705
 	    //$buffer = $Common->getData($hosts[$id]);
706 706
 	    if ($globalDebug) echo 'Get Data...'."\n";
707 707
 	    $buffer = $Common->getData($value['host']);
708
-	    $all_data = json_decode($buffer,true);
708
+	    $all_data = json_decode($buffer, true);
709 709
 	    if ($buffer != '' && is_array($all_data)) {
710 710
 		$reset = 0;
711 711
 		foreach ($all_data as $line) {
712 712
 	    	    $data = array();
713 713
 	    	    //$data['id'] = $line['id']; // id not usable
714 714
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
715
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
715
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
716 716
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717 717
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
718 718
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -735,12 +735,12 @@  discard block
 block discarded – undo
735 735
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
736 736
 		    if (isset($line['aircraftname'])) {
737 737
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
738
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
739
-	    		$aircraft_data = explode('-',$line['aircraftname']);
738
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
739
+	    		$aircraft_data = explode('-', $line['aircraftname']);
740 740
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741 741
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742 742
 	    		else {
743
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
743
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
744 744
 	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745 745
 	    		    else $data['aircraft_icao'] = $line['aircraftname'];
746 746
 	    		}
@@ -762,14 +762,14 @@  discard block
 block discarded – undo
762 762
 	    //$buffer = $Common->getData($hosts[$id]);
763 763
 	    if ($globalDebug) echo 'Get Data...'."\n";
764 764
 	    $buffer = $Common->getData($value['host']);
765
-	    $all_data = json_decode($buffer,true);
765
+	    $all_data = json_decode($buffer, true);
766 766
 	    if ($buffer != '' && is_array($all_data)) {
767 767
 		$reset = 0;
768 768
 		foreach ($all_data as $line) {
769 769
 	    	    $data = array();
770 770
 	    	    //$data['id'] = $line['id']; // id not usable
771 771
 	    	    $data['id'] = trim($line['flight_id']);
772
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
772
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
773 773
 	    	    $data['pilot_name'] = $line['pilot_name'];
774 774
 	    	    $data['pilot_id'] = $line['pilot_id'];
775 775
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -820,9 +820,9 @@  discard block
 block discarded – undo
820 820
 		    //$value = $formats[$nb];
821 821
 		    $format = $globalSources[$nb]['format'];
822 822
         	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
823
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
823
+        		$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
824 824
         	    } else {
825
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
825
+	    	        $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
826 826
 	    	    }
827 827
         	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
828 828
         	    //echo $buffer."\n";
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
831 831
 		    $error = false;
832 832
 		    //$SI::del();
833
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
833
+		    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
834 834
 		    // SBS format is CSV format
835 835
 		    if ($buffer != '') {
836 836
 			$tt[$format] = 0;
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
                         } elseif ($format == 'flightgearsp') {
852 852
                     	    //echo $buffer."\n";
853 853
                     	    if (strlen($buffer) > 5) {
854
-				$line = explode(',',$buffer);
854
+				$line = explode(',', $buffer);
855 855
 				$data = array();
856 856
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
857
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
857
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
858 858
 				$data['ident'] = $line[6];
859 859
 				$data['aircraft_name'] = $line[7];
860 860
 				$data['longitude'] = $line[1];
@@ -865,21 +865,21 @@  discard block
 block discarded – undo
865 865
 				$data['datetime'] = date('Y-m-d H:i:s');
866 866
 				$data['format_source'] = 'flightgearsp';
867 867
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
868
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
868
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
869 869
 			    }
870 870
                         } elseif ($format == 'acars') {
871 871
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
872 872
 			    $ACARS->add(trim($buffer));
873
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
873
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
874 874
 			    $ACARS->deleteLiveAcarsData();
875 875
 			} elseif ($format == 'flightgearmp') {
876
-			    if (substr($buffer,0,1) != '#') {
876
+			    if (substr($buffer, 0, 1) != '#') {
877 877
 				$data = array();
878 878
 				//echo $buffer."\n";
879
-				$line = explode(' ',$buffer);
879
+				$line = explode(' ', $buffer);
880 880
 				if (count($line) == 11) {
881
-				    $userserver = explode('@',$line[0]);
882
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
881
+				    $userserver = explode('@', $line[0]);
882
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
883 883
 				    $data['ident'] = $userserver[0];
884 884
 				    $data['registration'] = $userserver[0];
885 885
 				    $data['latitude'] = $line[4];
@@ -887,24 +887,24 @@  discard block
 block discarded – undo
887 887
 				    $data['altitude'] = $line[6];
888 888
 				    $data['datetime'] = date('Y-m-d H:i:s');
889 889
 				    $aircraft_type = $line[10];
890
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
891
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
890
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
891
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
892 892
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
893 893
 				}
894 894
 			    }
895 895
 			} elseif ($format == 'beast') {
896 896
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
897 897
 			    die;
898
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
898
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
899 899
 			    $line = explode("\t", $buffer);
900
-			    for($k = 0; $k < count($line); $k=$k+2) {
900
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
901 901
 				$key = $line[$k];
902
-			        $lined[$key] = $line[$k+1];
902
+			        $lined[$key] = $line[$k + 1];
903 903
 			    }
904 904
     			    if (count($lined) > 3) {
905 905
     				$data['hex'] = $lined['hexid'];
906 906
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907
-    				$data['datetime'] = date('Y-m-d H:i:s');;
907
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
908 908
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909 909
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910 910
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -922,21 +922,21 @@  discard block
 block discarded – undo
922 922
     			    } else $error = true;
923 923
 			} elseif ($format == 'aprs' && $use_aprs) {
924 924
 			    if ($aprs_connect == 0) {
925
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
925
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
926 926
 				$aprs_connect = 1;
927 927
 			    }
928 928
 			    
929
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
929
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
930 930
 				$aprs_last_tx = time();
931 931
 				$data_aprs = "# Keep alive";
932
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
932
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
933 933
 			    }
934 934
 			    
935 935
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
936
-			    $buffer = str_replace('APRS <- ','',$buffer);
937
-			    $buffer = str_replace('APRS -> ','',$buffer);
936
+			    $buffer = str_replace('APRS <- ', '', $buffer);
937
+			    $buffer = str_replace('APRS -> ', '', $buffer);
938 938
 			    //echo $buffer."\n";
939
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
939
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
940 940
 				$line = $APRS->parse($buffer);
941 941
 				//print_r($line);
942 942
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 				    $data = array();
945 945
 				    //print_r($line);
946 946
 				    $data['hex'] = $line['address'];
947
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
947
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
948 948
 				    else $data['datetime'] = date('Y-m-d H:i:s');
949 949
 				    //$data['datetime'] = date('Y-m-d H:i:s');
950 950
 				    $data['ident'] = $line['ident'];
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 				    $currentdate = date('Y-m-d H:i:s');
966 966
 				    $aprsdate = strtotime($data['datetime']);
967 967
 				    // Accept data if time <= system time + 20s
968
-				    if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
968
+				    if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
969 969
 					$send = $SI->add($data);
970 970
 				    } else {
971 971
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 				connect_all($sourceee);
1056 1056
 				$sourceee = array();
1057 1057
 				//connect_all($globalSources);
1058
-				$tt[$format]=0;
1058
+				$tt[$format] = 0;
1059 1059
 				break;
1060 1060
 			    }
1061 1061
 			}
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 		}
1064 1064
 	    } else {
1065 1065
 		$error = socket_strerror(socket_last_error());
1066
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1066
+		if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1067 1067
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1068 1068
 			if (isset($globalDebug)) echo "Restarting...\n";
1069 1069
 			// Restart the script if possible
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 			    if ($globalDebug) echo "Shutdown all sockets...";
1072 1072
 			    
1073 1073
 			    foreach ($sockets as $sock) {
1074
-				@socket_shutdown($sock,2);
1074
+				@socket_shutdown($sock, 2);
1075 1075
 				@socket_close($sock);
1076 1076
 			    }
1077 1077
 			    
Please login to merge, or discard this patch.
Braces   +552 added lines, -190 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 
17
-if (!isset($globalDebug)) $globalDebug = FALSE;
17
+if (!isset($globalDebug)) {
18
+	$globalDebug = FALSE;
19
+}
18 20
 
19 21
 // Check if schema is at latest version
20 22
 $Connection = new Connection();
@@ -54,13 +56,22 @@  discard block
 block discarded – undo
54 56
     $globalSources = array();
55 57
     $globalSources[] = array('host' => $options['source']);
56 58
 }
57
-if (isset($options['server'])) $globalServer = TRUE;
58
-if (isset($options['idsource'])) $id_source = $options['idsource'];
59
-else $id_source = 1;
59
+if (isset($options['server'])) {
60
+	$globalServer = TRUE;
61
+}
62
+if (isset($options['idsource'])) {
63
+	$id_source = $options['idsource'];
64
+} else {
65
+	$id_source = 1;
66
+}
60 67
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
68
+    if ($globalDebug) {
69
+    	echo "Using Server Mode\n";
70
+    }
62 71
     $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
72
+} else {
73
+	$SI=new SpotterImport($Connection->db);
74
+}
64 75
 //$APRS=new APRS($Connection->db);
65 76
 $SBS=new SBS();
66 77
 $ACARS=new ACARS($Connection->db);
@@ -78,7 +89,9 @@  discard block
 block discarded – undo
78 89
 }
79 90
 
80 91
 // let's try and connect
81
-if ($globalDebug) echo "Connecting...\n";
92
+if ($globalDebug) {
93
+	echo "Connecting...\n";
94
+}
82 95
 $use_aprs = false;
83 96
 $aprs_full = false;
84 97
 $reset = 0;
@@ -87,7 +100,9 @@  discard block
 block discarded – undo
87 100
     $ip = gethostbyname($host);
88 101
     $s = socket_create(AF_INET, SOCK_STREAM, 0);
89 102
     $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
103
+    if (!socket_set_nonblock($s)) {
104
+    	echo "Unable to set nonblock on socket\n";
105
+    }
91 106
     if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92 107
         return $s;
93 108
     }
@@ -115,7 +130,9 @@  discard block
 block discarded – undo
115 130
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 131
     global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117 132
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
133
+    if ($globalDebug) {
134
+    	echo 'Connect to all...'."\n";
135
+    }
119 136
     foreach ($hosts as $id => $value) {
120 137
 	$host = $value['host'];
121 138
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,27 +142,37 @@  discard block
 block discarded – undo
125 142
         	//$formats[$id] = 'deltadbtxt';
126 143
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 144
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
145
+        	if ($globalDebug) {
146
+        		echo "Connect to deltadb source (".$host.")...\n";
147
+        	}
129 148
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 149
         	//$formats[$id] = 'vatsimtxt';
131 150
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 151
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
152
+        	if ($globalDebug) {
153
+        		echo "Connect to vatsim source (".$host.")...\n";
154
+        	}
134 155
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 156
         	//$formats[$id] = 'aircraftlistjson';
136 157
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 158
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
159
+        	if ($globalDebug) {
160
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
161
+        	}
139 162
     	    } else if (preg_match('/opensky/i',$host)) {
140 163
         	//$formats[$id] = 'aircraftlistjson';
141 164
         	$globalSources[$id]['format'] = 'opensky';
142 165
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
166
+        	if ($globalDebug) {
167
+        		echo "Connect to opensky source (".$host.")...\n";
168
+        	}
144 169
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145 170
         	//$formats[$id] = 'radarvirtueljson';
146 171
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 172
         	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
173
+        	if ($globalDebug) {
174
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
175
+        	}
149 176
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150 177
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 178
         	    exit(0);
@@ -154,7 +181,9 @@  discard block
 block discarded – undo
154 181
         	//$formats[$id] = 'planeupdatefaa';
155 182
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 183
         	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
186
+        	}
158 187
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159 188
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 189
         	    exit(0);
@@ -163,26 +192,36 @@  discard block
 block discarded – undo
163 192
         	//$formats[$id] = 'phpvmacars';
164 193
         	$globalSources[$id]['format'] = 'phpvmacars';
165 194
         	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
195
+        	if ($globalDebug) {
196
+        		echo "Connect to phpvmacars source (".$host.")...\n";
197
+        	}
167 198
             } else if (preg_match('/VAM-json.php$/i',$host)) {
168 199
         	//$formats[$id] = 'phpvmacars';
169 200
         	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
201
+        	if ($globalDebug) {
202
+        		echo "Connect to Vam source (".$host.")...\n";
203
+        	}
171 204
             } else if (preg_match('/whazzup/i',$host)) {
172 205
         	//$formats[$id] = 'whazzup';
173 206
         	$globalSources[$id]['format'] = 'whazzup';
174 207
         	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
208
+        	if ($globalDebug) {
209
+        		echo "Connect to whazzup source (".$host.")...\n";
210
+        	}
176 211
             } else if (preg_match('/recentpireps/i',$host)) {
177 212
         	//$formats[$id] = 'pirepsjson';
178 213
         	$globalSources[$id]['format'] = 'pirepsjson';
179 214
         	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
215
+        	if ($globalDebug) {
216
+        		echo "Connect to pirepsjson source (".$host.")...\n";
217
+        	}
181 218
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182 219
         	//$formats[$id] = 'fr24json';
183 220
         	$globalSources[$id]['format'] = 'fr24json';
184 221
         	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to fr24 source (".$host.")...\n";
224
+        	}
186 225
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187 226
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188 227
         	    exit(0);
@@ -191,10 +230,14 @@  discard block
 block discarded – undo
191 230
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 231
         	//$formats[$id] = 'tsv';
193 232
         	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
233
+        	if ($globalDebug) {
234
+        		echo "Connect to tsv source (".$host.")...\n";
235
+        	}
195 236
             }
196 237
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
238
+        	if ($globalDebug) {
239
+        		echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
+        	}
198 241
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199 242
 	    $hostport = explode(':',$host);
200 243
 	    if (isset($hostport[1])) {
@@ -231,17 +274,25 @@  discard block
 block discarded – undo
231 274
         		//$formats[$id] = 'beast';
232 275
         		$globalSources[$id]['format'] = 'beast';
233 276
 		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
277
+		    } else {
278
+		    	$globalSources[$id]['format'] = 'sbs';
279
+		    }
235 280
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 281
 		}
237
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
282
+		if ($globalDebug) {
283
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
284
+		}
238 285
             } else {
239
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
286
+		if ($globalDebug) {
287
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
288
+		}
240 289
     	    }
241 290
         }
242 291
     }
243 292
 }
244
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
293
+if (!isset($globalMinFetch)) {
294
+	$globalMinFetch = 15;
295
+}
245 296
 
246 297
 // Initialize all
247 298
 $status = array();
@@ -249,13 +300,19 @@  discard block
 block discarded – undo
249 300
 $formats = array();
250 301
 $last_exec = array();
251 302
 $time = time();
252
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
253
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254
-else $timeout = 20;
303
+if (isset($globalSourcesTimeout)) {
304
+	$timeout = $globalSourcesTimeOut;
305
+} else if (isset($globalSBS1TimeOut)) {
306
+	$timeout = $globalSBS1TimeOut;
307
+} else {
308
+	$timeout = 20;
309
+}
255 310
 $errno = '';
256 311
 $errstr='';
257 312
 
258
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
313
+if (!isset($globalDaemon)) {
314
+	$globalDaemon = TRUE;
315
+}
259 316
 /* Initiate connections to all the hosts simultaneously */
260 317
 //connect_all($hosts);
261 318
 //connect_all($globalSources);
@@ -275,7 +332,9 @@  discard block
 block discarded – undo
275 332
     if (isset($source['format']) && $source['format'] == 'aprs') {
276 333
 	$aprs_connect = 0;
277 334
 	$use_aprs = true;
278
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
335
+	if (isset($source['port']) && $source['port'] == '10152') {
336
+		$aprs_full = true;
337
+	}
279 338
 	break;
280 339
     }
281 340
 }
@@ -286,23 +345,43 @@  discard block
 block discarded – undo
286 345
 	$aprs_connect = 0;
287 346
 	$aprs_keep = 120;
288 347
 	$aprs_last_tx = time();
289
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
290
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
291
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
292
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
293
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
294
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
295
-	if ($aprs_full) $aprs_filter = '';
348
+	if (isset($globalAPRSversion)) {
349
+		$aprs_version = $globalAPRSversion;
350
+	} else {
351
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
352
+	}
353
+	if (isset($globalAPRSssid)) {
354
+		$aprs_ssid = $globalAPRSssid;
355
+	} else {
356
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
357
+	}
358
+	if (isset($globalAPRSfilter)) {
359
+		$aprs_filter = $globalAPRSfilter;
360
+	} else {
361
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
362
+	}
363
+	if ($aprs_full) {
364
+		$aprs_filter = '';
365
+	}
296 366
 
297
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
298
-	else $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n";
299
-}
367
+	if ($aprs_filter != '') {
368
+		$aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
369
+	} else {
370
+		$aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n";
371
+	}
372
+	}
300 373
 
301 374
 // connected - lets do some work
302
-if ($globalDebug) echo "Connected!\n";
375
+if ($globalDebug) {
376
+	echo "Connected!\n";
377
+}
303 378
 sleep(1);
304
-if ($globalDebug) echo "SCAN MODE \n\n";
305
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
379
+if ($globalDebug) {
380
+	echo "SCAN MODE \n\n";
381
+}
382
+if (!isset($globalCronEnd)) {
383
+	$globalCronEnd = 60;
384
+}
306 385
 $endtime = time()+$globalCronEnd;
307 386
 $i = 1;
308 387
 $tt = array();
@@ -316,20 +395,28 @@  discard block
 block discarded – undo
316 395
 
317 396
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
318 397
 while ($i > 0) {
319
-    if (!$globalDaemon) $i = $endtime-time();
398
+    if (!$globalDaemon) {
399
+    	$i = $endtime-time();
400
+    }
320 401
     // Delete old ATC
321 402
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
322
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
403
+	if ($globalDebug) {
404
+		echo 'Delete old ATC...'."\n";
405
+	}
323 406
         $ATC->deleteOldATC();
324 407
     }
325 408
     
326 409
     if (count($last_exec) > 0) {
327 410
 	$max = $globalMinFetch;
328 411
 	foreach ($last_exec as $last) {
329
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
412
+	    if ((time() - $last['last']) < $max) {
413
+	    	$max = time() - $last['last'];
414
+	    }
330 415
 	}
331 416
 	if ($max != $globalMinFetch) {
332
-	    if ($globalDebug) echo 'Sleeping...'."\n";
417
+	    if ($globalDebug) {
418
+	    	echo 'Sleeping...'."\n";
419
+	    }
333 420
 	    sleep($globalMinFetch-$max+2);
334 421
 	}
335 422
     }
@@ -338,11 +425,15 @@  discard block
 block discarded – undo
338 425
     //foreach ($formats as $id => $value) {
339 426
     foreach ($globalSources as $id => $value) {
340 427
 	date_default_timezone_set('UTC');
341
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
428
+	if (!isset($last_exec[$id]['last'])) {
429
+		$last_exec[$id]['last'] = 0;
430
+	}
342 431
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
343 432
 	    //$buffer = $Common->getData($hosts[$id]);
344 433
 	    $buffer = $Common->getData($value['host']);
345
-	    if ($buffer != '') $reset = 0;
434
+	    if ($buffer != '') {
435
+	    	$reset = 0;
436
+	    }
346 437
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347 438
 	    $buffer = explode('\n',$buffer);
348 439
 	    foreach ($buffer as $line) {
@@ -351,19 +442,38 @@  discard block
 block discarded – undo
351 442
 	            $data = array();
352 443
 	            $data['hex'] = $line[1]; // hex
353 444
 	            $data['ident'] = $line[2]; // ident
354
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
445
+	            if (isset($line[3])) {
446
+	            	$data['altitude'] = $line[3];
447
+	            }
448
+	            // altitude
449
+	            if (isset($line[4])) {
450
+	            	$data['speed'] = $line[4];
451
+	            }
452
+	            // speed
453
+	            if (isset($line[5])) {
454
+	            	$data['heading'] = $line[5];
455
+	            }
456
+	            // heading
457
+	            if (isset($line[6])) {
458
+	            	$data['latitude'] = $line[6];
459
+	            }
460
+	            // lat
461
+	            if (isset($line[7])) {
462
+	            	$data['longitude'] = $line[7];
463
+	            }
464
+	            // long
359 465
 	            $data['verticalrate'] = ''; // vertical rate
360 466
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361 467
 	            $data['emergency'] = ''; // emergency
362 468
 		    $data['datetime'] = date('Y-m-d H:i:s');
363 469
 		    $data['format_source'] = 'deltadbtxt';
364 470
     		    $data['id_source'] = $id_source;
365
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
471
+		    if (isset($value['name']) && $value['name'] != '') {
472
+		    	$data['source_name'] = $value['name'];
473
+		    }
474
+		    if (isset($value['sourcestats'])) {
475
+		    	$data['sourcestats'] = $value['sourcestats'];
476
+		    }
367 477
     		    $SI->add($data);
368 478
 		    unset($data);
369 479
     		}
@@ -381,16 +491,28 @@  discard block
 block discarded – undo
381 491
     		    $line = explode(':', $line);
382 492
     		    if (count($line) > 30 && $line[0] != 'callsign') {
383 493
 			$data = array();
384
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
385
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
494
+			if (isset($line[37]) && $line[37] != '') {
495
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
496
+			} else {
497
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
498
+			}
386 499
 			$data['pilot_id'] = $line[1];
387 500
 			$data['pilot_name'] = $line[2];
388 501
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
389 502
 			$data['ident'] = $line[0]; // ident
390
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
503
+			if ($line[7] != '' && $line[7] != 0) {
504
+				$data['altitude'] = $line[7];
505
+			}
506
+			// altitude
391 507
 			$data['speed'] = $line[8]; // speed
392
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
393
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
508
+			if (isset($line[45])) {
509
+				$data['heading'] = $line[45];
510
+			}
511
+			// heading
512
+			elseif (isset($line[38])) {
513
+				$data['heading'] = $line[38];
514
+			}
515
+			// heading
394 516
 			$data['latitude'] = $line[5]; // lat
395 517
 	        	$data['longitude'] = $line[6]; // long
396 518
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -406,7 +528,9 @@  discard block
 block discarded – undo
406 528
 			$data['frequency'] = $line[4];
407 529
 			$data['type'] = $line[18];
408 530
 			$data['range'] = $line[19];
409
-			if (isset($line[35])) $data['info'] = $line[35];
531
+			if (isset($line[35])) {
532
+				$data['info'] = $line[35];
533
+			}
410 534
     			$data['id_source'] = $id_source;
411 535
 	    		//$data['arrival_airport_time'] = ;
412 536
 	    		if ($line[9] != '') {
@@ -420,24 +544,41 @@  discard block
 block discarded – undo
420 544
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
421 545
 	    		*/
422 546
 	    		$data['format_source'] = $value['format'];
423
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
424
-    			if ($line[3] == 'PILOT') $SI->add($data);
425
-			elseif ($line[3] == 'ATC') {
547
+			if (isset($value['name']) && $value['name'] != '') {
548
+				$data['source_name'] = $value['name'];
549
+			}
550
+    			if ($line[3] == 'PILOT') {
551
+    				$SI->add($data);
552
+    			} elseif ($line[3] == 'ATC') {
426 553
 				//print_r($data);
427 554
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
428 555
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
429 556
 				$typec = substr($data['ident'],-3);
430
-				if ($typec == 'APP') $data['type'] = 'Approach';
431
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
432
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
433
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
434
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
435
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
436
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
437
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
438
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
439
-				if (!isset($data['source_name'])) $data['source_name'] = '';
440
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
557
+				if ($typec == 'APP') {
558
+					$data['type'] = 'Approach';
559
+				} elseif ($typec == 'TWR') {
560
+					$data['type'] = 'Tower';
561
+				} elseif ($typec == 'OBS') {
562
+					$data['type'] = 'Observer';
563
+				} elseif ($typec == 'GND') {
564
+					$data['type'] = 'Ground';
565
+				} elseif ($typec == 'DEL') {
566
+					$data['type'] = 'Delivery';
567
+				} elseif ($typec == 'DEP') {
568
+					$data['type'] = 'Departure';
569
+				} elseif ($typec == 'FSS') {
570
+					$data['type'] = 'Flight Service Station';
571
+				} elseif ($typec == 'CTR') {
572
+					$data['type'] = 'Control Radar or Centre';
573
+				} elseif ($data['type'] == '') {
574
+					$data['type'] = 'Observer';
575
+				}
576
+				if (!isset($data['source_name'])) {
577
+					$data['source_name'] = '';
578
+				}
579
+				if (isset($ATC)) {
580
+					echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
581
+				}
441 582
 			}
442 583
     			unset($data);
443 584
     		    }
@@ -456,26 +597,55 @@  discard block
 block discarded – undo
456 597
 		foreach ($all_data['acList'] as $line) {
457 598
 		    $data = array();
458 599
 		    $data['hex'] = $line['Icao']; // hex
459
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
460
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
461
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
462
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
463
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
464
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
600
+		    if (isset($line['Call'])) {
601
+		    	$data['ident'] = $line['Call'];
602
+		    }
603
+		    // ident
604
+		    if (isset($line['Alt'])) {
605
+		    	$data['altitude'] = $line['Alt'];
606
+		    }
607
+		    // altitude
608
+		    if (isset($line['Spd'])) {
609
+		    	$data['speed'] = $line['Spd'];
610
+		    }
611
+		    // speed
612
+		    if (isset($line['Trak'])) {
613
+		    	$data['heading'] = $line['Trak'];
614
+		    }
615
+		    // heading
616
+		    if (isset($line['Lat'])) {
617
+		    	$data['latitude'] = $line['Lat'];
618
+		    }
619
+		    // lat
620
+		    if (isset($line['Long'])) {
621
+		    	$data['longitude'] = $line['Long'];
622
+		    }
623
+		    // long
465 624
 		    //$data['verticalrate'] = $line['']; // verticale rate
466
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
625
+		    if (isset($line['Sqk'])) {
626
+		    	$data['squawk'] = $line['Sqk'];
627
+		    }
628
+		    // squawk
467 629
 		    $data['emergency'] = ''; // emergency
468
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
630
+		    if (isset($line['Reg'])) {
631
+		    	$data['registration'] = $line['Reg'];
632
+		    }
469 633
 		    /*
470 634
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
471 635
 		    else $data['datetime'] = date('Y-m-d H:i:s');
472 636
 		    */
473 637
 		    $data['datetime'] = date('Y-m-d H:i:s');
474
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
638
+		    if (isset($line['Type'])) {
639
+		    	$data['aircraft_icao'] = $line['Type'];
640
+		    }
475 641
 	    	    $data['format_source'] = 'aircraftlistjson';
476 642
 		    $data['id_source'] = $id_source;
477
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
478
-		    if (isset($data['datetime'])) $SI->add($data);
643
+		    if (isset($value['name']) && $value['name'] != '') {
644
+		    	$data['source_name'] = $value['name'];
645
+		    }
646
+		    if (isset($data['datetime'])) {
647
+		    	$SI->add($data);
648
+		    }
479 649
 		    unset($data);
480 650
 		}
481 651
 	    } else {
@@ -495,7 +665,9 @@  discard block
 block discarded – undo
495 665
 		    $data['datetime'] = date('Y-m-d H:i:s');
496 666
 	    	    $data['format_source'] = 'aircraftlistjson';
497 667
     		    $data['id_source'] = $id_source;
498
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
668
+		    if (isset($value['name']) && $value['name'] != '') {
669
+		    	$data['source_name'] = $value['name'];
670
+		    }
499 671
 		    $SI->add($data);
500 672
 		    unset($data);
501 673
 		}
@@ -531,7 +703,9 @@  discard block
 block discarded – undo
531 703
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
532 704
 	    	    $data['format_source'] = 'planeupdatefaa';
533 705
     		    $data['id_source'] = $id_source;
534
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
706
+		    if (isset($value['name']) && $value['name'] != '') {
707
+		    	$data['source_name'] = $value['name'];
708
+		    }
535 709
 		    $SI->add($data);
536 710
 		    unset($data);
537 711
 		}
@@ -571,7 +745,9 @@  discard block
 block discarded – undo
571 745
 	    //$buffer = $Common->getData($hosts[$id]);
572 746
 	    $buffer = $Common->getData($value['host']);
573 747
 	    $all_data = json_decode($buffer,true);
574
-	    if (!empty($all_data)) $reset = 0;
748
+	    if (!empty($all_data)) {
749
+	    	$reset = 0;
750
+	    }
575 751
 	    foreach ($all_data as $key => $line) {
576 752
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
577 753
 		    $data = array();
@@ -592,7 +768,9 @@  discard block
 block discarded – undo
592 768
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
593 769
 	    	    $data['format_source'] = 'fr24json';
594 770
     		    $data['id_source'] = $id_source;
595
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
771
+		    if (isset($value['name']) && $value['name'] != '') {
772
+		    	$data['source_name'] = $value['name'];
773
+		    }
596 774
 		    $SI->add($data);
597 775
 		    unset($data);
598 776
 		}
@@ -616,23 +794,39 @@  discard block
 block discarded – undo
616 794
 		    if (isset($line['inf'])) {
617 795
 			$data = array();
618 796
 			$data['hex'] = $line['inf']['ia'];
619
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
797
+			if (isset($line['inf']['cs'])) {
798
+				$data['ident'] = $line['inf']['cs'];
799
+			}
800
+			//$line[13]
620 801
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
621
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
622
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
802
+	    		if (isset($line['inf']['gs'])) {
803
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
804
+	    		}
805
+	    		// speed
806
+	    		if (isset($line['inf']['tr'])) {
807
+	    			$data['heading'] = $line['inf']['tr'];
808
+	    		}
809
+	    		// heading
623 810
 	    		$data['latitude'] = $line['pt'][0]; // lat
624 811
 	    		$data['longitude'] = $line['pt'][1]; // long
625 812
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
626
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
813
+	    		if (isset($line['inf']['sq'])) {
814
+	    			$data['squawk'] = $line['inf']['sq'];
815
+	    		}
816
+	    		// squawk
627 817
 	    		//$data['aircraft_icao'] = $line[8];
628
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
818
+	    		if (isset($line['inf']['rc'])) {
819
+	    			$data['registration'] = $line['inf']['rc'];
820
+	    		}
629 821
 			//$data['departure_airport_iata'] = $line[11];
630 822
 			//$data['arrival_airport_iata'] = $line[12];
631 823
 	    		//$data['emergency'] = ''; // emergency
632 824
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
633 825
 	    		$data['format_source'] = 'radarvirtueljson';
634 826
     			$data['id_source'] = $id_source;
635
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
827
+			if (isset($value['name']) && $value['name'] != '') {
828
+				$data['source_name'] = $value['name'];
829
+			}
636 830
 			$SI->add($data);
637 831
 			unset($data);
638 832
 		    }
@@ -653,29 +847,62 @@  discard block
 block discarded – undo
653 847
 		    $data['id'] = $line['id'];
654 848
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
655 849
 		    $data['ident'] = $line['callsign']; // ident
656
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
658
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
659
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
660
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
661
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
850
+		    if (isset($line['pilotid'])) {
851
+		    	$data['pilot_id'] = $line['pilotid'];
852
+		    }
853
+		    // pilot id
854
+		    if (isset($line['name'])) {
855
+		    	$data['pilot_name'] = $line['name'];
856
+		    }
857
+		    // pilot name
858
+		    if (isset($line['alt'])) {
859
+		    	$data['altitude'] = $line['alt'];
860
+		    }
861
+		    // altitude
862
+		    if (isset($line['gs'])) {
863
+		    	$data['speed'] = $line['gs'];
864
+		    }
865
+		    // speed
866
+		    if (isset($line['heading'])) {
867
+		    	$data['heading'] = $line['heading'];
868
+		    }
869
+		    // heading
870
+		    if (isset($line['route'])) {
871
+		    	$data['waypoints'] = $line['route'];
872
+		    }
873
+		    // route
662 874
 		    $data['latitude'] = $line['lat']; // lat
663 875
 		    $data['longitude'] = $line['lon']; // long
664 876
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
665 877
 		    //$data['squawk'] = $line['squawk']; // squawk
666 878
 		    //$data['emergency'] = ''; // emergency
667
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
668
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
669
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
879
+		    if (isset($line['depicao'])) {
880
+		    	$data['departure_airport_icao'] = $line['depicao'];
881
+		    }
882
+		    if (isset($line['deptime'])) {
883
+		    	$data['departure_airport_time'] = $line['deptime'];
884
+		    }
885
+		    if (isset($line['arricao'])) {
886
+		    	$data['arrival_airport_icao'] = $line['arricao'];
887
+		    }
670 888
 		    //$data['arrival_airport_time'] = $line['arrtime'];
671
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
672
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
673
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
674
-		    else $data['info'] = '';
889
+		    if (isset($line['aircraft'])) {
890
+		    	$data['aircraft_icao'] = $line['aircraft'];
891
+		    }
892
+		    if (isset($line['transponder'])) {
893
+		    	$data['squawk'] = $line['transponder'];
894
+		    }
895
+		    if (isset($line['atis'])) {
896
+		    	$data['info'] = $line['atis'];
897
+		    } else {
898
+		    	$data['info'] = '';
899
+		    }
675 900
 		    $data['format_source'] = 'pireps';
676 901
     		    $data['id_source'] = $id_source;
677 902
 		    $data['datetime'] = date('Y-m-d H:i:s');
678
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
903
+		    if (isset($value['name']) && $value['name'] != '') {
904
+		    	$data['source_name'] = $value['name'];
905
+		    }
679 906
 		    if ($line['icon'] == 'plane') {
680 907
 			$SI->add($data);
681 908
 		    //    print_r($data);
@@ -684,16 +911,28 @@  discard block
 block discarded – undo
684 911
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
685 912
 			$typec = substr($data['ident'],-3);
686 913
 			$data['type'] = '';
687
-			if ($typec == 'APP') $data['type'] = 'Approach';
688
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
689
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
690
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
691
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
692
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
693
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
694
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
695
-			else $data['type'] = 'Observer';
696
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
914
+			if ($typec == 'APP') {
915
+				$data['type'] = 'Approach';
916
+			} elseif ($typec == 'TWR') {
917
+				$data['type'] = 'Tower';
918
+			} elseif ($typec == 'OBS') {
919
+				$data['type'] = 'Observer';
920
+			} elseif ($typec == 'GND') {
921
+				$data['type'] = 'Ground';
922
+			} elseif ($typec == 'DEL') {
923
+				$data['type'] = 'Delivery';
924
+			} elseif ($typec == 'DEP') {
925
+				$data['type'] = 'Departure';
926
+			} elseif ($typec == 'FSS') {
927
+				$data['type'] = 'Flight Service Station';
928
+			} elseif ($typec == 'CTR') {
929
+				$data['type'] = 'Control Radar or Centre';
930
+			} else {
931
+				$data['type'] = 'Observer';
932
+			}
933
+			if (isset($ATC)) {
934
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
935
+			}
697 936
 		    }
698 937
 		    unset($data);
699 938
 		}
@@ -703,7 +942,9 @@  discard block
 block discarded – undo
703 942
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
704 943
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705 944
 	    //$buffer = $Common->getData($hosts[$id]);
706
-	    if ($globalDebug) echo 'Get Data...'."\n";
945
+	    if ($globalDebug) {
946
+	    	echo 'Get Data...'."\n";
947
+	    }
707 948
 	    $buffer = $Common->getData($value['host']);
708 949
 	    $all_data = json_decode($buffer,true);
709 950
 	    if ($buffer != '' && is_array($all_data)) {
@@ -711,10 +952,16 @@  discard block
 block discarded – undo
711 952
 		foreach ($all_data as $line) {
712 953
 	    	    $data = array();
713 954
 	    	    //$data['id'] = $line['id']; // id not usable
714
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
955
+	    	    if (isset($line['pilotid'])) {
956
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
957
+	    	    }
715 958
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
716
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
959
+	    	    if (isset($line['pilotname'])) {
960
+	    	    	$data['pilot_name'] = $line['pilotname'];
961
+	    	    }
962
+	    	    if (isset($line['pilotid'])) {
963
+	    	    	$data['pilot_id'] = $line['pilotid'];
964
+	    	    }
718 965
 	    	    $data['ident'] = $line['flightnum']; // ident
719 966
 	    	    $data['altitude'] = $line['alt']; // altitude
720 967
 	    	    $data['speed'] = $line['gs']; // speed
@@ -732,27 +979,41 @@  discard block
 block discarded – undo
732 979
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
733 980
     		    $data['arrival_airport_time'] = $line['arrtime'];
734 981
     		    $data['registration'] = $line['aircraft'];
735
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
982
+		    if (isset($line['route'])) {
983
+		    	$data['waypoints'] = $line['route'];
984
+		    }
985
+		    // route
736 986
 		    if (isset($line['aircraftname'])) {
737 987
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
738 988
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
739 989
 	    		$aircraft_data = explode('-',$line['aircraftname']);
740
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742
-	    		else {
990
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
991
+	    			$data['aircraft_icao'] = $aircraft_data[0];
992
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
993
+	    			$data['aircraft_icao'] = $aircraft_data[1];
994
+	    		} else {
743 995
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
744
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
996
+	    		    if (isset($aircraft_data[1])) {
997
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
998
+	    		    } else {
999
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
1000
+	    		    }
746 1001
 	    		}
747 1002
 	    	    }
748
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1003
+    		    if (isset($line['route'])) {
1004
+    		    	$data['waypoints'] = $line['route'];
1005
+    		    }
749 1006
     		    $data['id_source'] = $id_source;
750 1007
 	    	    $data['format_source'] = 'phpvmacars';
751
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1008
+		    if (isset($value['name']) && $value['name'] != '') {
1009
+		    	$data['source_name'] = $value['name'];
1010
+		    }
752 1011
 		    $SI->add($data);
753 1012
 		    unset($data);
754 1013
 		}
755
-		if ($globalDebug) echo 'No more data...'."\n";
1014
+		if ($globalDebug) {
1015
+			echo 'No more data...'."\n";
1016
+		}
756 1017
 		unset($buffer);
757 1018
 		unset($all_data);
758 1019
 	    }
@@ -760,7 +1021,9 @@  discard block
 block discarded – undo
760 1021
     	    $last_exec[$id]['last'] = time();
761 1022
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
762 1023
 	    //$buffer = $Common->getData($hosts[$id]);
763
-	    if ($globalDebug) echo 'Get Data...'."\n";
1024
+	    if ($globalDebug) {
1025
+	    	echo 'Get Data...'."\n";
1026
+	    }
764 1027
 	    $buffer = $Common->getData($value['host']);
765 1028
 	    $all_data = json_decode($buffer,true);
766 1029
 	    if ($buffer != '' && is_array($all_data)) {
@@ -789,15 +1052,22 @@  discard block
 block discarded – undo
789 1052
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
790 1053
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
791 1054
     		    //$data['registration'] = $line['aircraft'];
792
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1055
+		    if (isset($line['route'])) {
1056
+		    	$data['waypoints'] = $line['route'];
1057
+		    }
1058
+		    // route
793 1059
 	    	    $data['aircraft_icao'] = $line['plane_type'];
794 1060
     		    $data['id_source'] = $id_source;
795 1061
 	    	    $data['format_source'] = 'vam';
796
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1062
+		    if (isset($value['name']) && $value['name'] != '') {
1063
+		    	$data['source_name'] = $value['name'];
1064
+		    }
797 1065
 		    $SI->add($data);
798 1066
 		    unset($data);
799 1067
 		}
800
-		if ($globalDebug) echo 'No more data...'."\n";
1068
+		if ($globalDebug) {
1069
+			echo 'No more data...'."\n";
1070
+		}
801 1071
 		unset($buffer);
802 1072
 		unset($all_data);
803 1073
 	    }
@@ -805,7 +1075,9 @@  discard block
 block discarded – undo
805 1075
     	    $last_exec[$id]['last'] = time();
806 1076
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
807 1077
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
808
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1078
+	    if (function_exists('pcntl_fork')) {
1079
+	    	pcntl_signal_dispatch();
1080
+	    }
809 1081
     	    //$last_exec[$id]['last'] = time();
810 1082
 
811 1083
 	    //$read = array( $sockets[$id] );
@@ -813,7 +1085,9 @@  discard block
 block discarded – undo
813 1085
 	    $write = NULL;
814 1086
 	    $e = NULL;
815 1087
 	    $n = socket_select($read, $write, $e, $timeout);
816
-	    if ($e != NULL) var_dump($e);
1088
+	    if ($e != NULL) {
1089
+	    	var_dump($e);
1090
+	    }
817 1091
 	    if ($n > 0) {
818 1092
 		$reset = 0;
819 1093
 		foreach ($read as $nb => $r) {
@@ -835,7 +1109,9 @@  discard block
 block discarded – undo
835 1109
 		    if ($buffer != '') {
836 1110
 			$tt[$format] = 0;
837 1111
 			if ($format == 'acarssbs3') {
838
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1112
+                    	    if ($globalDebug) {
1113
+                    	    	echo 'ACARS : '.$buffer."\n";
1114
+                    	    }
839 1115
 			    $ACARS->add(trim($buffer));
840 1116
 			    $ACARS->deleteLiveAcarsData();
841 1117
 			} elseif ($format == 'raw') {
@@ -844,9 +1120,15 @@  discard block
 block discarded – undo
844 1120
 			    if (is_array($data)) {
845 1121
 				$data['datetime'] = date('Y-m-d H:i:s');
846 1122
 				$data['format_source'] = 'raw';
847
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
848
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
849
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1123
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1124
+					$data['source_name'] = $globalSources[$nb]['name'];
1125
+				}
1126
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1127
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1128
+    				}
1129
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1130
+                                	$SI->add($data);
1131
+                                }
850 1132
                             }
851 1133
                         } elseif ($format == 'flightgearsp') {
852 1134
                     	    //echo $buffer."\n";
@@ -864,11 +1146,15 @@  discard block
 block discarded – undo
864 1146
 				$data['speed'] = round($line[5]*1.94384);
865 1147
 				$data['datetime'] = date('Y-m-d H:i:s');
866 1148
 				$data['format_source'] = 'flightgearsp';
867
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1149
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1150
+					$SI->add($data);
1151
+				}
868 1152
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
869 1153
 			    }
870 1154
                         } elseif ($format == 'acars') {
871
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1155
+                    	    if ($globalDebug) {
1156
+                    	    	echo 'ACARS : '.$buffer."\n";
1157
+                    	    }
872 1158
 			    $ACARS->add(trim($buffer));
873 1159
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
874 1160
 			    $ACARS->deleteLiveAcarsData();
@@ -889,7 +1175,9 @@  discard block
 block discarded – undo
889 1175
 				    $aircraft_type = $line[10];
890 1176
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
891 1177
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
892
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1178
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1179
+				    	$SI->add($data);
1180
+				    }
893 1181
 				}
894 1182
 			    }
895 1183
 			} elseif ($format == 'beast') {
@@ -905,21 +1193,43 @@  discard block
 block discarded – undo
905 1193
     				$data['hex'] = $lined['hexid'];
906 1194
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907 1195
     				$data['datetime'] = date('Y-m-d H:i:s');;
908
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
911
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
912
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
913
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
914
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1196
+    				if (isset($lined['ident'])) {
1197
+    					$data['ident'] = $lined['ident'];
1198
+    				}
1199
+    				if (isset($lined['lat'])) {
1200
+    					$data['latitude'] = $lined['lat'];
1201
+    				}
1202
+    				if (isset($lined['lon'])) {
1203
+    					$data['longitude'] = $lined['lon'];
1204
+    				}
1205
+    				if (isset($lined['speed'])) {
1206
+    					$data['speed'] = $lined['speed'];
1207
+    				}
1208
+    				if (isset($lined['squawk'])) {
1209
+    					$data['squawk'] = $lined['squawk'];
1210
+    				}
1211
+    				if (isset($lined['alt'])) {
1212
+    					$data['altitude'] = $lined['alt'];
1213
+    				}
1214
+    				if (isset($lined['heading'])) {
1215
+    					$data['heading'] = $lined['heading'];
1216
+    				}
915 1217
     				$data['id_source'] = $id_source;
916 1218
     				$data['format_source'] = 'tsv';
917
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
918
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
919
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1219
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1220
+    					$data['source_name'] = $globalSources[$nb]['name'];
1221
+    				}
1222
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1223
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1224
+    				}
1225
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1226
+    					$SI->add($data);
1227
+    				}
920 1228
     				unset($lined);
921 1229
     				unset($data);
922
-    			    } else $error = true;
1230
+    			    } else {
1231
+    			    	$error = true;
1232
+    			    }
923 1233
 			} elseif ($format == 'aprs' && $use_aprs) {
924 1234
 			    if ($aprs_connect == 0) {
925 1235
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -944,36 +1254,50 @@  discard block
 block discarded – undo
944 1254
 				    $data = array();
945 1255
 				    //print_r($line);
946 1256
 				    $data['hex'] = $line['address'];
947
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
948
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1257
+				    if (isset($line['timestamp'])) {
1258
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1259
+				    } else {
1260
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1261
+				    }
949 1262
 				    //$data['datetime'] = date('Y-m-d H:i:s');
950 1263
 				    $data['ident'] = $line['ident'];
951 1264
 				    $data['latitude'] = $line['latitude'];
952 1265
 				    $data['longitude'] = $line['longitude'];
953 1266
 				    //$data['verticalrate'] = $line[16];
954
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
955
-				    else $data['speed'] = 0;
1267
+				    if (isset($line['speed'])) {
1268
+				    	$data['speed'] = $line['speed'];
1269
+				    } else {
1270
+				    	$data['speed'] = 0;
1271
+				    }
956 1272
 				    $data['altitude'] = $line['altitude'];
957
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1273
+				    if (isset($line['heading'])) {
1274
+				    	$data['heading'] = $line['heading'];
1275
+				    }
958 1276
 				    //else $data['heading'] = 0;
959 1277
 				    $data['aircraft_type'] = $line['stealth'];
960
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1278
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1279
+				    	$data['noarchive'] = true;
1280
+				    }
961 1281
     				    $data['id_source'] = $id_source;
962 1282
 				    $data['format_source'] = 'aprs';
963 1283
 				    $data['source_name'] = $line['source'];
964
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1284
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1285
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1286
+    				    }
965 1287
 				    $currentdate = date('Y-m-d H:i:s');
966 1288
 				    $aprsdate = strtotime($data['datetime']);
967 1289
 				    // Accept data if time <= system time + 20s
968 1290
 				    if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
969 1291
 					$send = $SI->add($data);
970 1292
 				    } else {
971
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
972
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1293
+					if ($line['stealth'] != 0) {
1294
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1295
+					} else {
1296
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1297
+					}
973 1298
 				    }
974 1299
 				    unset($data);
975
-				} 
976
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1300
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
977 1301
 					echo '!! Weather Station not yet supported'."\n";
978 1302
 				}
979 1303
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1006,25 +1330,42 @@  discard block
 block discarded – undo
1006 1330
     				$data['ground'] = $line[21];
1007 1331
     				$data['emergency'] = $line[19];
1008 1332
     				$data['format_source'] = 'sbs';
1009
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1010
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1333
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1334
+					$data['source_name'] = $globalSources[$nb]['name'];
1335
+				}
1336
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1337
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1338
+    				}
1011 1339
     				$data['id_source'] = $id_source;
1012
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1013
-    				else $error = true;
1340
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1341
+    					$send = $SI->add($data);
1342
+    				} else {
1343
+    					$error = true;
1344
+    				}
1014 1345
     				unset($data);
1015
-    			    } else $error = true;
1346
+    			    } else {
1347
+    			    	$error = true;
1348
+    			    }
1016 1349
 			    if ($error) {
1017 1350
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1018
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1351
+					if ($globalDebug) {
1352
+						echo "Not a message. Ignoring... \n";
1353
+					}
1019 1354
 				} else {
1020
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1355
+					if ($globalDebug) {
1356
+						echo "Wrong line format. Ignoring... \n";
1357
+					}
1021 1358
 					if ($globalDebug) {
1022 1359
 						echo $buffer;
1023 1360
 						print_r($line);
1024 1361
 					}
1025 1362
 					//socket_close($r);
1026
-					if ($globalDebug) echo "Reconnect after an error...\n";
1027
-					if ($format == 'aprs') $aprs_connect = 0;
1363
+					if ($globalDebug) {
1364
+						echo "Reconnect after an error...\n";
1365
+					}
1366
+					if ($format == 'aprs') {
1367
+						$aprs_connect = 0;
1368
+					}
1028 1369
 					$sourceer[$nb] = $globalSources[$nb];
1029 1370
 					connect_all($sourceer);
1030 1371
 					$sourceer = array();
@@ -1032,10 +1373,14 @@  discard block
 block discarded – undo
1032 1373
 			    }
1033 1374
 			}
1034 1375
 			// Sleep for xxx microseconds
1035
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1376
+			if (isset($globalSBSSleep)) {
1377
+				usleep($globalSBSSleep);
1378
+			}
1036 1379
 		    } else {
1037 1380
 			if ($format == 'flightgearmp') {
1038
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1381
+			    	if ($globalDebug) {
1382
+			    		echo "Reconnect FlightGear MP...";
1383
+			    	}
1039 1384
 				//@socket_close($r);
1040 1385
 				sleep($globalMinFetch);
1041 1386
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1044,10 +1389,15 @@  discard block
 block discarded – undo
1044 1389
 				break;
1045 1390
 				
1046 1391
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1047
-			    if (isset($tt[$format])) $tt[$format]++;
1048
-			    else $tt[$format] = 0;
1392
+			    if (isset($tt[$format])) {
1393
+			    	$tt[$format]++;
1394
+			    } else {
1395
+			    	$tt[$format] = 0;
1396
+			    }
1049 1397
 			    if ($tt[$format] > 30) {
1050
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1398
+				if ($globalDebug) {
1399
+					echo "ERROR : Reconnect ".$format."...";
1400
+				}
1051 1401
 				//@socket_close($r);
1052 1402
 				sleep(2);
1053 1403
 				$aprs_connect = 0;
@@ -1063,12 +1413,18 @@  discard block
 block discarded – undo
1063 1413
 		}
1064 1414
 	    } else {
1065 1415
 		$error = socket_strerror(socket_last_error());
1066
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1416
+		if ($globalDebug) {
1417
+			echo "ERROR : socket_select give this error ".$error . "\n";
1418
+		}
1067 1419
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1068
-			if (isset($globalDebug)) echo "Restarting...\n";
1420
+			if (isset($globalDebug)) {
1421
+				echo "Restarting...\n";
1422
+			}
1069 1423
 			// Restart the script if possible
1070 1424
 			if (is_array($sockets)) {
1071
-			    if ($globalDebug) echo "Shutdown all sockets...";
1425
+			    if ($globalDebug) {
1426
+			    	echo "Shutdown all sockets...";
1427
+			    }
1072 1428
 			    
1073 1429
 			    foreach ($sockets as $sock) {
1074 1430
 				@socket_shutdown($sock,2);
@@ -1076,18 +1432,24 @@  discard block
 block discarded – undo
1076 1432
 			    }
1077 1433
 			    
1078 1434
 			}
1079
-			if ($globalDebug) echo "Restart all connections...";
1435
+			if ($globalDebug) {
1436
+				echo "Restart all connections...";
1437
+			}
1080 1438
 			sleep(2);
1081 1439
 			$time = time();
1082 1440
 			//connect_all($hosts);
1083 1441
 			$aprs_connect = 0;
1084
-			if ($reset > 40) exit('Too many attempts...');
1442
+			if ($reset > 40) {
1443
+				exit('Too many attempts...');
1444
+			}
1085 1445
 			connect_all($globalSources);
1086 1446
 		}
1087 1447
 	    }
1088 1448
 	}
1089 1449
 	if ($globalDaemon === false) {
1090
-	    if ($globalDebug) echo 'Check all...'."\n";
1450
+	    if ($globalDebug) {
1451
+	    	echo 'Check all...'."\n";
1452
+	    }
1091 1453
 	    $SI->checkAll();
1092 1454
 	}
1093 1455
     }
Please login to merge, or discard this patch.
require/class.Stats.php 4 patches
Doc Comments   +35 added lines patch added patch discarded remove patch
@@ -18,6 +18,10 @@  discard block
 block discarded – undo
18 18
 		$this->db = $Connection->db();
19 19
         }
20 20
               
21
+	/**
22
+	 * @param string $type
23
+	 * @param string $stats_date
24
+	 */
21 25
 	public function addLastStatsUpdate($type,$stats_date) {
22 26
                 $query = "DELETE FROM config WHERE name = :type;
23 27
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
@@ -961,6 +965,10 @@  discard block
 block discarded – undo
961 965
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
962 966
                 return $all;
963 967
         }
968
+
969
+	/**
970
+	 * @param string $type
971
+	 */
964 972
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
965 973
 		if ($filter_name == '') $filter_name = $this->filter_name;
966 974
                 $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -974,6 +982,11 @@  discard block
 block discarded – undo
974 982
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
975 983
                 return $all;
976 984
         }
985
+
986
+	/**
987
+	 * @param string $type
988
+	 * @param string $year
989
+	 */
977 990
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
978 991
 		if ($filter_name == '') $filter_name = $this->filter_name;
979 992
     		global $globalArchiveMonths, $globalDBdriver;
@@ -1118,6 +1131,10 @@  discard block
 block discarded – undo
1118 1131
                 else return 0;
1119 1132
         }
1120 1133
 
1134
+	/**
1135
+	 * @param string $type
1136
+	 * @param string $stats_date
1137
+	 */
1121 1138
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1122 1139
 		global $globalDBdriver;
1123 1140
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -1171,6 +1188,9 @@  discard block
 block discarded – undo
1171 1188
         }
1172 1189
         */
1173 1190
 
1191
+	/**
1192
+	 * @param string $stats_type
1193
+	 */
1174 1194
 	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1175 1195
 		global $globalDBdriver;
1176 1196
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
@@ -1214,6 +1234,9 @@  discard block
 block discarded – undo
1214 1234
 		return $all;
1215 1235
 	}
1216 1236
 
1237
+	/**
1238
+	 * @param string $stats_type
1239
+	 */
1217 1240
 	public function addStatSource($data,$source_name,$stats_type,$date) {
1218 1241
 		global $globalDBdriver;
1219 1242
 		if ($globalDBdriver == 'mysql') {
@@ -1229,6 +1252,10 @@  discard block
 block discarded – undo
1229 1252
                         return "error : ".$e->getMessage();
1230 1253
                 }
1231 1254
         }
1255
+
1256
+	/**
1257
+	 * @param string $type
1258
+	 */
1232 1259
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1233 1260
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1234 1261
                 $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
@@ -1495,6 +1522,10 @@  discard block
 block discarded – undo
1495 1522
                         return "error : ".$e->getMessage();
1496 1523
                 }
1497 1524
         }
1525
+
1526
+	/**
1527
+	 * @param string $type
1528
+	 */
1498 1529
 	public function deleteStatFlight($type) {
1499 1530
                 $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1500 1531
                 $query_values = array(':type' => $type);
@@ -1505,6 +1536,10 @@  discard block
 block discarded – undo
1505 1536
                         return "error : ".$e->getMessage();
1506 1537
                 }
1507 1538
         }
1539
+
1540
+	/**
1541
+	 * @param string $type
1542
+	 */
1508 1543
 	public function deleteStatAirport($type) {
1509 1544
                 $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1510 1545
                 $query_values = array(':type' => $type);
Please login to merge, or discard this patch.
Spacing   +373 added lines, -373 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 		$this->db = $Connection->db();
19 19
         }
20 20
               
21
-	public function addLastStatsUpdate($type,$stats_date) {
21
+	public function addLastStatsUpdate($type, $stats_date) {
22 22
                 $query = "DELETE FROM config WHERE name = :type;
23 23
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
24
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
25 25
                  try {
26 26
                         $sth = $this->db->prepare($query);
27 27
                         $sth->execute($query_values);
28
-                } catch(PDOException $e) {
28
+                } catch (PDOException $e) {
29 29
                         return "error : ".$e->getMessage();
30 30
                 }
31 31
         }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                  try {
36 36
                         $sth = $this->db->prepare($query);
37 37
                         $sth->execute(array(':type' => $type));
38
-                } catch(PDOException $e) {
38
+                } catch (PDOException $e) {
39 39
                         echo "error : ".$e->getMessage();
40 40
                 }
41 41
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                  try {
56 56
                         $sth = $this->db->prepare($query);
57 57
                         $sth->execute(array(':filter_name' => $filter_name));
58
-                } catch(PDOException $e) {
58
+                } catch (PDOException $e) {
59 59
                         return "error : ".$e->getMessage();
60 60
                 }
61 61
         }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                  try {
69 69
                         $sth = $this->db->prepare($query);
70 70
                         $sth->execute();
71
-                } catch(PDOException $e) {
71
+                } catch (PDOException $e) {
72 72
                         return "error : ".$e->getMessage();
73 73
                 }
74 74
                 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                  try {
77 77
                         $sth = $this->db->prepare($query);
78 78
                         $sth->execute(array(':filter_name' => $filter_name));
79
-                } catch(PDOException $e) {
79
+                } catch (PDOException $e) {
80 80
                         return "error : ".$e->getMessage();
81 81
                 }
82 82
         }
@@ -86,69 +86,69 @@  discard block
 block discarded – undo
86 86
                  try {
87 87
                         $sth = $this->db->prepare($query);
88 88
                         $sth->execute(array(':filter_name' => $filter_name));
89
-                } catch(PDOException $e) {
89
+                } catch (PDOException $e) {
90 90
                         echo "error : ".$e->getMessage();
91 91
                 }
92 92
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
93 93
                 return $all;
94 94
         }
95
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
95
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
96 96
 		if ($filter_name == '') $filter_name = $this->filter_name;
97 97
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
98 98
                  try {
99 99
                         $sth = $this->db->prepare($query);
100
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
101
-                } catch(PDOException $e) {
100
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
101
+                } catch (PDOException $e) {
102 102
                         echo "error : ".$e->getMessage();
103 103
                 }
104 104
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
105 105
                 return $all;
106 106
         }
107
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
107
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
108 108
 		if ($filter_name == '') $filter_name = $this->filter_name;
109 109
                 $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";
110 110
                  try {
111 111
                         $sth = $this->db->prepare($query);
112
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
113
-                } catch(PDOException $e) {
112
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
113
+                } catch (PDOException $e) {
114 114
                         echo "error : ".$e->getMessage();
115 115
                 }
116 116
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
117 117
                 return $all;
118 118
         }
119
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
119
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
120 120
 		if ($filter_name == '') $filter_name = $this->filter_name;
121 121
                 $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";
122 122
                  try {
123 123
                         $sth = $this->db->prepare($query);
124
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
125
-                } catch(PDOException $e) {
124
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
125
+                } catch (PDOException $e) {
126 126
                         echo "error : ".$e->getMessage();
127 127
                 }
128 128
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
129 129
                 return $all;
130 130
         }
131 131
 
132
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
132
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
133 133
 		if ($filter_name == '') $filter_name = $this->filter_name;
134 134
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
135 135
                  try {
136 136
                         $sth = $this->db->prepare($query);
137
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
138
-                } catch(PDOException $e) {
137
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
138
+                } catch (PDOException $e) {
139 139
                         echo "error : ".$e->getMessage();
140 140
                 }
141 141
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
142 142
                 return $all;
143 143
         }
144 144
 
145
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
145
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
146 146
 		if ($filter_name == '') $filter_name = $this->filter_name;
147 147
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
148 148
                  try {
149 149
                         $sth = $this->db->prepare($query);
150
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
151
-                } catch(PDOException $e) {
150
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
151
+                } catch (PDOException $e) {
152 152
                         echo "error : ".$e->getMessage();
153 153
                 }
154 154
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         }
157 157
 
158 158
 
159
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
159
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
160 160
 		global $globalStatsFilters;
161 161
 		if ($filter_name == '') $filter_name = $this->filter_name;
162 162
 		if ($year == '' && $month == '') {
@@ -164,24 +164,24 @@  discard block
 block discarded – undo
164 164
 			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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";
165 165
 			try {
166 166
 				$sth = $this->db->prepare($query);
167
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
168
-			} catch(PDOException $e) {
167
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
168
+			} catch (PDOException $e) {
169 169
 				echo "error : ".$e->getMessage();
170 170
 			}
171 171
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
172 172
 		} else $all = array();
173 173
                 if (empty($all)) {
174
-            	    $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
174
+            	    $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
175 175
             	    if ($filter_name != '') {
176
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
176
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
177 177
             	    }
178 178
             	    $Spotter = new Spotter($this->db);
179 179
             	    //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
180
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
180
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
181 181
                 }
182 182
                 return $all;
183 183
 	}
184
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
184
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
185 185
 		global $globalStatsFilters;
186 186
 		if ($filter_name == '') $filter_name = $this->filter_name;
187 187
 		if ($year == '' && $month == '') {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 			try {
191 191
 				$sth = $this->db->prepare($query);
192 192
 				$sth->execute(array(':filter_name' => $filter_name));
193
-			} catch(PDOException $e) {
193
+			} catch (PDOException $e) {
194 194
 				echo "error : ".$e->getMessage();
195 195
 			}
196 196
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
                 if (empty($all)) {
199 199
             		$Spotter = new Spotter($this->db);
200 200
             		$filters = array();
201
-            		$filters = array('year' => $year,'month' => $month);
201
+            		$filters = array('year' => $year, 'month' => $month);
202 202
             		if ($filter_name != '') {
203
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
203
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
204 204
 			}
205 205
             		//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
206
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
206
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters);
207 207
                 }
208 208
                 return $all;
209 209
 	}
210
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
210
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
211 211
 		global $globalStatsFilters;
212 212
 		if ($filter_name == '') $filter_name = $this->filter_name;
213 213
 		if ($year == '' && $month == '') {
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
 			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";
216 216
 			try {
217 217
 				$sth = $this->db->prepare($query);
218
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
219
-			} catch(PDOException $e) {
218
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
219
+			} catch (PDOException $e) {
220 220
 				echo "error : ".$e->getMessage();
221 221
 			}
222 222
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
223 223
 		} else $all = array();
224 224
 		if (empty($all)) {
225
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
225
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
226 226
 			if ($filter_name != '') {
227
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
227
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
228 228
 			}
229 229
 			$Spotter = new Spotter($this->db);
230 230
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		return $all;
234 234
 	}
235 235
 
236
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
236
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
237 237
 		global $globalStatsFilters;
238 238
 		if ($filter_name == '') $filter_name = $this->filter_name;
239 239
 		if ($year == '' && $month == '') {
@@ -241,20 +241,20 @@  discard block
 block discarded – undo
241 241
 			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";
242 242
 			try {
243 243
 				$sth = $this->db->prepare($query);
244
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
245
-			} catch(PDOException $e) {
244
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
245
+			} catch (PDOException $e) {
246 246
 				echo "error : ".$e->getMessage();
247 247
 			}
248 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
249 249
 		} else $all = array();
250 250
                 if (empty($all)) {
251
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
251
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
252 252
 			if ($filter_name != '') {
253
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
253
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
254 254
 			}
255 255
 			$Spotter = new Spotter($this->db);
256 256
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
257
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
257
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
258 258
                 }
259 259
                 return $all;
260 260
 	}
@@ -265,15 +265,15 @@  discard block
 block discarded – undo
265 265
 		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";
266 266
                  try {
267 267
                         $sth = $this->db->prepare($query);
268
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
269
-                } catch(PDOException $e) {
268
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
269
+                } catch (PDOException $e) {
270 270
                         echo "error : ".$e->getMessage();
271 271
                 }
272 272
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
273 273
                 if (empty($all)) {
274
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
274
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
275 275
 			if ($filter_name != '') {
276
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
276
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
277 277
 			}
278 278
 			$Spotter = new Spotter($this->db);
279 279
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 return $all;
283 283
 	}
284 284
 
285
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
285
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
286 286
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
287 287
 		if ($filter_name == '') $filter_name = $this->filter_name;
288 288
 		if ($year == '' && $month == '') {
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 			if (isset($forsource)) {
292 292
 				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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
293 293
 				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 AND airlines.forsource = :forsource ORDER BY airline_count DESC";
294
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
294
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
295 295
 			} else {
296 296
 				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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
297 297
 				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 AND airlines.forsource IS NULL ORDER BY airline_count DESC";
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 			try {
301 301
 				$sth = $this->db->prepare($query);
302 302
 				$sth->execute($query_values);
303
-			} catch(PDOException $e) {
303
+			} catch (PDOException $e) {
304 304
 				echo "error : ".$e->getMessage();
305 305
 			}
306 306
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -308,16 +308,16 @@  discard block
 block discarded – undo
308 308
                 if (empty($all)) {
309 309
 	                $Spotter = new Spotter($this->db);
310 310
             		$filters = array();
311
-			$filters = array('year' => $year,'month' => $month);
311
+			$filters = array('year' => $year, 'month' => $month);
312 312
             		if ($filter_name != '') {
313
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
313
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
314 314
 			}
315 315
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
316
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
316
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
317 317
                 }
318 318
                 return $all;
319 319
 	}
320
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
320
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
321 321
 		global $globalStatsFilters;
322 322
 		if ($filter_name == '') $filter_name = $this->filter_name;
323 323
 		if ($year == '' && $month == '') {
@@ -325,24 +325,24 @@  discard block
 block discarded – undo
325 325
 			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";
326 326
 			try {
327 327
 				$sth = $this->db->prepare($query);
328
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
329
-			} catch(PDOException $e) {
328
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
329
+			} catch (PDOException $e) {
330 330
 				echo "error : ".$e->getMessage();
331 331
 			}
332 332
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
333 333
 		} else $all = array();
334 334
                 if (empty($all)) {
335
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
335
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
336 336
 			if ($filter_name != '') {
337
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
337
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
338 338
 			}
339 339
 	                $Spotter = new Spotter($this->db);
340 340
     		        //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
341
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
341
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
342 342
                 }
343 343
                 return $all;
344 344
 	}
345
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
345
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
346 346
 		global $globalStatsFilters;
347 347
 		if ($filter_name == '') $filter_name = $this->filter_name;
348 348
 		if ($year == '' && $month == '') {
@@ -350,24 +350,24 @@  discard block
 block discarded – undo
350 350
 			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";
351 351
 			 try {
352 352
 				$sth = $this->db->prepare($query);
353
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
354
-			} catch(PDOException $e) {
353
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
354
+			} catch (PDOException $e) {
355 355
 				echo "error : ".$e->getMessage();
356 356
 			}
357 357
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
358 358
 		} else $all = array();
359 359
 		if (empty($all)) {
360
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
360
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
361 361
 			if ($filter_name != '') {
362
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
362
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
363 363
 			}
364 364
 			$Spotter = new Spotter($this->db);
365 365
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
366
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
366
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
367 367
 		}
368 368
 		return $all;
369 369
 	}
370
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
370
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
371 371
 		$Connection = new Connection();
372 372
 		if ($filter_name == '') $filter_name = $this->filter_name;
373 373
 		if ($Connection->tableExists('countries')) {
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 				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";
377 377
 				 try {
378 378
 					$sth = $this->db->prepare($query);
379
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
380
-				} catch(PDOException $e) {
379
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
380
+				} catch (PDOException $e) {
381 381
 					echo "error : ".$e->getMessage();
382 382
 				}
383 383
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			return array();
394 394
 		}
395 395
 	}
396
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
396
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
397 397
 		global $globalStatsFilters;
398 398
 		if ($filter_name == '') $filter_name = $this->filter_name;
399 399
 		if ($year == '' && $month == '') {
@@ -401,25 +401,25 @@  discard block
 block discarded – undo
401 401
 			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";
402 402
 			try {
403 403
 				$sth = $this->db->prepare($query);
404
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
405
-			} catch(PDOException $e) {
404
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
405
+			} catch (PDOException $e) {
406 406
 				echo "error : ".$e->getMessage();
407 407
 			}
408 408
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
409 409
 		} else $all = array();
410 410
 		if (empty($all)) {
411
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
411
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
412 412
 			if ($filter_name != '') {
413
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
413
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
414 414
 			}
415 415
 			$Spotter = new Spotter($this->db);
416 416
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
417
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
417
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
418 418
 		}
419 419
 		return $all;
420 420
 	}
421 421
 
422
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
422
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
423 423
 		global $globalStatsFilters;
424 424
 		if ($filter_name == '') $filter_name = $this->filter_name;
425 425
 		if ($year == '' && $month == '') {
@@ -427,24 +427,24 @@  discard block
 block discarded – undo
427 427
 			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";
428 428
 			try {
429 429
 				$sth = $this->db->prepare($query);
430
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
431
-			} catch(PDOException $e) {
430
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
431
+			} catch (PDOException $e) {
432 432
 				echo "error : ".$e->getMessage();
433 433
 			}
434 434
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
435 435
 		} else $all = array();
436 436
                 if (empty($all)) {
437
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
437
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
438 438
 			if ($filter_name != '') {
439
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
439
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
440 440
 			}
441 441
             		$Spotter = new Spotter($this->db);
442 442
             		//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
443
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
443
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters);
444 444
                 }
445 445
                 return $all;
446 446
 	}
447
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
447
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
448 448
 		global $globalStatsFilters;
449 449
 		if ($filter_name == '') $filter_name = $this->filter_name;
450 450
 		if ($year == '' && $month == '') {
@@ -452,22 +452,22 @@  discard block
 block discarded – undo
452 452
 			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";
453 453
 			try {
454 454
 				$sth = $this->db->prepare($query);
455
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
456
-			} catch(PDOException $e) {
455
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
456
+			} catch (PDOException $e) {
457 457
 				echo "error : ".$e->getMessage();
458 458
 			}
459 459
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
460 460
 		} else $all = array();
461 461
                 if (empty($all)) {
462
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
462
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
463 463
             		if ($filter_name != '') {
464
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
464
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
465 465
 			}
466 466
             		$Spotter = new Spotter($this->db);
467 467
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
468 468
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
469
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
470
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
469
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
470
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
471 471
         		$all = array();
472 472
         		foreach ($pall as $value) {
473 473
         			$icao = $value['airport_departure_icao'];
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
         		foreach ($all as $key => $row) {
485 485
         			$count[$key] = $row['airport_departure_icao_count'];
486 486
         		}
487
-        		array_multisort($count,SORT_DESC,$all);
487
+        		array_multisort($count, SORT_DESC, $all);
488 488
                 }
489 489
                 return $all;
490 490
 	}
491
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
491
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
492 492
 		global $globalStatsFilters;
493 493
 		if ($filter_name == '') $filter_name = $this->filter_name;
494 494
 		if ($year == '' && $month == '') {
@@ -496,22 +496,22 @@  discard block
 block discarded – undo
496 496
 			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";
497 497
 			try {
498 498
 				$sth = $this->db->prepare($query);
499
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
500
-			} catch(PDOException $e) {
499
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
500
+			} catch (PDOException $e) {
501 501
 				echo "error : ".$e->getMessage();
502 502
 			}
503 503
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
504 504
 		} else $all = array();
505 505
 		if (empty($all)) {
506
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
506
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
507 507
 			if ($filter_name != '') {
508
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
508
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
509 509
 			}
510 510
 			$Spotter = new Spotter($this->db);
511 511
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
512 512
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
513
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
514
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
513
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
514
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
515 515
         		$all = array();
516 516
         		foreach ($pall as $value) {
517 517
         			$icao = $value['airport_arrival_icao'];
@@ -528,12 +528,12 @@  discard block
 block discarded – undo
528 528
         		foreach ($all as $key => $row) {
529 529
         			$count[$key] = $row['airport_arrival_icao_count'];
530 530
         		}
531
-        		array_multisort($count,SORT_DESC,$all);
531
+        		array_multisort($count, SORT_DESC, $all);
532 532
                 }
533 533
  
534 534
                 return $all;
535 535
 	}
536
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
536
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
537 537
 		global $globalDBdriver, $globalStatsFilters;
538 538
 		if ($filter_name == '') $filter_name = $this->filter_name;
539 539
 		if ($globalDBdriver == 'mysql') {
@@ -543,18 +543,18 @@  discard block
 block discarded – undo
543 543
 			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";
544 544
 			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";
545 545
 		}
546
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
546
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
547 547
                  try {
548 548
                         $sth = $this->db->prepare($query);
549 549
                         $sth->execute($query_data);
550
-                } catch(PDOException $e) {
550
+                } catch (PDOException $e) {
551 551
                         echo "error : ".$e->getMessage();
552 552
                 }
553 553
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
554 554
                 if (empty($all)) {
555 555
 			$filters = array('airlines' => array($stats_airline));
556 556
 			if ($filter_name != '') {
557
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
557
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
558 558
 			}
559 559
             		$Spotter = new Spotter($this->db);
560 560
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -563,29 +563,29 @@  discard block
 block discarded – undo
563 563
                 return $all;
564 564
 	}
565 565
 	
566
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
566
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
567 567
 		global $globalStatsFilters;
568 568
 		if ($filter_name == '') $filter_name = $this->filter_name;
569 569
 		$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";
570
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
570
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
571 571
                  try {
572 572
                         $sth = $this->db->prepare($query);
573 573
                         $sth->execute($query_data);
574
-                } catch(PDOException $e) {
574
+                } catch (PDOException $e) {
575 575
                         echo "error : ".$e->getMessage();
576 576
                 }
577 577
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
578 578
                 if (empty($all)) {
579 579
 			$filters = array('airlines' => array($stats_airline));
580 580
 			if ($filter_name != '') {
581
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
581
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
582 582
 			}
583 583
             		$Spotter = new Spotter($this->db);
584 584
             		$all = $Spotter->countAllDatesLastMonth($filters);
585 585
                 }
586 586
                 return $all;
587 587
 	}
588
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
588
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
589 589
 		global $globalDBdriver, $globalStatsFilters;
590 590
 		if ($filter_name == '') $filter_name = $this->filter_name;
591 591
 		if ($globalDBdriver == 'mysql') {
@@ -593,40 +593,40 @@  discard block
 block discarded – undo
593 593
 		} else {
594 594
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
595 595
 		}
596
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
596
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
597 597
                  try {
598 598
                         $sth = $this->db->prepare($query);
599 599
                         $sth->execute($query_data);
600
-                } catch(PDOException $e) {
600
+                } catch (PDOException $e) {
601 601
                         echo "error : ".$e->getMessage();
602 602
                 }
603 603
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
604 604
                 if (empty($all)) {
605 605
 			$filters = array('airlines' => array($stats_airline));
606 606
 			if ($filter_name != '') {
607
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
607
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
608 608
 			}
609 609
             		$Spotter = new Spotter($this->db);
610 610
             		$all = $Spotter->countAllDatesLast7Days($filters);
611 611
                 }
612 612
                 return $all;
613 613
 	}
614
-	public function countAllDates($stats_airline = '',$filter_name = '') {
614
+	public function countAllDates($stats_airline = '', $filter_name = '') {
615 615
 		global $globalStatsFilters;
616 616
 		if ($filter_name == '') $filter_name = $this->filter_name;
617 617
 		$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";
618
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
618
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
619 619
                  try {
620 620
                         $sth = $this->db->prepare($query);
621 621
                         $sth->execute($query_data);
622
-                } catch(PDOException $e) {
622
+                } catch (PDOException $e) {
623 623
                         echo "error : ".$e->getMessage();
624 624
                 }
625 625
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
626 626
                 if (empty($all)) {
627 627
 			$filters = array('airlines' => array($stats_airline));
628 628
 			if ($filter_name != '') {
629
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
629
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
630 630
 			}
631 631
             		$Spotter = new Spotter($this->db);
632 632
             		$all = $Spotter->countAllDates($filters);
@@ -641,21 +641,21 @@  discard block
 block discarded – undo
641 641
                  try {
642 642
                         $sth = $this->db->prepare($query);
643 643
                         $sth->execute($query_data);
644
-                } catch(PDOException $e) {
644
+                } catch (PDOException $e) {
645 645
                         echo "error : ".$e->getMessage();
646 646
                 }
647 647
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
648 648
                 if (empty($all)) {
649 649
             		$filters = array();
650 650
             		if ($filter_name != '') {
651
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
651
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
652 652
 			}
653 653
             		$Spotter = new Spotter($this->db);
654 654
             		$all = $Spotter->countAllDatesByAirlines($filters);
655 655
                 }
656 656
                 return $all;
657 657
 	}
658
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
658
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
659 659
 		global $globalStatsFilters, $globalDBdriver;
660 660
 		if ($filter_name == '') $filter_name = $this->filter_name;
661 661
 		if ($globalDBdriver == 'mysql') {
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
                  try {
667 667
                         $sth = $this->db->prepare($query);
668 668
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
669
-                } catch(PDOException $e) {
669
+                } catch (PDOException $e) {
670 670
                         echo "error : ".$e->getMessage();
671 671
                 }
672 672
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
                 if (empty($all)) {
675 675
 			$filters = array('airlines' => array($stats_airline));
676 676
 			if ($filter_name != '') {
677
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
677
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
678 678
 			}
679 679
             		$Spotter = new Spotter($this->db);
680 680
             		$all = $Spotter->countAllMonths($filters);
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
                  try {
693 693
                         $sth = $this->db->prepare($query);
694 694
                         $sth->execute();
695
-                } catch(PDOException $e) {
695
+                } catch (PDOException $e) {
696 696
                         echo "error : ".$e->getMessage();
697 697
                 }
698 698
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
                  try {
714 714
                         $sth = $this->db->prepare($query);
715 715
                         $sth->execute();
716
-                } catch(PDOException $e) {
716
+                } catch (PDOException $e) {
717 717
                         echo "error : ".$e->getMessage();
718 718
                 }
719 719
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -731,21 +731,21 @@  discard block
 block discarded – undo
731 731
                  try {
732 732
                         $sth = $this->db->prepare($query);
733 733
                         $sth->execute(array(':filter_name' => $filter_name));
734
-                } catch(PDOException $e) {
734
+                } catch (PDOException $e) {
735 735
                         echo "error : ".$e->getMessage();
736 736
                 }
737 737
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
738 738
                 if (empty($all)) {
739 739
             		$filters = array();
740 740
             		if ($filter_name != '') {
741
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
741
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
742 742
 			}
743 743
             		$Spotter = new Spotter($this->db);
744 744
             		$all = $Spotter->countAllMilitaryMonths($filters);
745 745
                 }
746 746
                 return $all;
747 747
 	}
748
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
748
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
749 749
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
750 750
 		if ($filter_name == '') $filter_name = $this->filter_name;
751 751
 		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";
@@ -762,30 +762,30 @@  discard block
 block discarded – undo
762 762
                  try {
763 763
                         $sth = $this->db->prepare($query);
764 764
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
765
-                } catch(PDOException $e) {
765
+                } catch (PDOException $e) {
766 766
                         echo "error : ".$e->getMessage();
767 767
                 }
768 768
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
769 769
                 if (empty($all)) {
770 770
 			$filters = array('airlines' => array($stats_airline));
771 771
 			if ($filter_name != '') {
772
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
772
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
773 773
 			}
774 774
             		$Spotter = new Spotter($this->db);
775
-            		$all = $Spotter->countAllHours($orderby,$filters);
775
+            		$all = $Spotter->countAllHours($orderby, $filters);
776 776
                 }
777 777
                 return $all;
778 778
 	}
779 779
 	
780
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
780
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
781 781
 		global $globalStatsFilters;
782 782
 		if ($filter_name == '') $filter_name = $this->filter_name;
783 783
 		if ($year == '') $year = date('Y');
784
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
784
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
785 785
 		if (empty($all)) {
786
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
786
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
787 787
 			if ($filter_name != '') {
788
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
788
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
789 789
 			}
790 790
 			$Spotter = new Spotter($this->db);
791 791
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -793,16 +793,16 @@  discard block
 block discarded – undo
793 793
 		}
794 794
 		return $all;
795 795
 	}
796
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
796
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
797 797
 		global $globalStatsFilters;
798 798
 		if ($filter_name == '') $filter_name = $this->filter_name;
799 799
 		if ($year == '') $year = date('Y');
800
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
800
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
801 801
 		if (empty($all)) {
802 802
 		        $filters = array();
803
-			$filters = array('year' => $year,'month' => $month);
803
+			$filters = array('year' => $year, 'month' => $month);
804 804
             		if ($filter_name != '') {
805
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
805
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
806 806
 			}
807 807
 			$Spotter = new Spotter($this->db);
808 808
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -810,15 +810,15 @@  discard block
 block discarded – undo
810 810
 		}
811 811
 		return $all;
812 812
 	}
813
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
813
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
814 814
 		global $globalStatsFilters;
815 815
 		if ($filter_name == '') $filter_name = $this->filter_name;
816 816
 		if ($year == '') $year = date('Y');
817
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
817
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
818 818
 		if (empty($all)) {
819
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
819
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
820 820
 			if ($filter_name != '') {
821
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
821
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
822 822
 			}
823 823
 			$Spotter = new Spotter($this->db);
824 824
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -826,24 +826,24 @@  discard block
 block discarded – undo
826 826
 		}
827 827
 		return $all;
828 828
 	}
829
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
829
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
830 830
 		global $globalStatsFilters;
831 831
 		if ($filter_name == '') $filter_name = $this->filter_name;
832 832
 		if ($year == '' && $month == '') {
833 833
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
834 834
 			try {
835 835
 				$sth = $this->db->prepare($query);
836
-				$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
837
-			} catch(PDOException $e) {
836
+				$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
837
+			} catch (PDOException $e) {
838 838
 				echo "error : ".$e->getMessage();
839 839
 			}
840 840
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
841 841
 			$all = $result[0]['nb'];
842
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
842
+		} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
843 843
 		if (empty($all)) {
844
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
844
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
845 845
 			if ($filter_name != '') {
846
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
846
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
847 847
 			}
848 848
 			$Spotter = new Spotter($this->db);
849 849
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 		}
852 852
 		return $all;
853 853
 	}
854
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
854
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
855 855
 		global $globalStatsFilters;
856 856
 		if ($filter_name == '') $filter_name = $this->filter_name;
857 857
 		if ($year == '' && $month == '') {
@@ -859,17 +859,17 @@  discard block
 block discarded – undo
859 859
 			try {
860 860
 				$sth = $this->db->prepare($query);
861 861
 				$sth->execute(array(':filter_name' => $filter_name));
862
-			} catch(PDOException $e) {
862
+			} catch (PDOException $e) {
863 863
 				echo "error : ".$e->getMessage();
864 864
 			}
865 865
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
866 866
 			$all = $result[0]['nb_airline'];
867
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
867
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
868 868
 		if (empty($all)) {
869 869
             		$filters = array();
870
-			$filters = array('year' => $year,'month' => $month);
870
+			$filters = array('year' => $year, 'month' => $month);
871 871
             		if ($filter_name != '') {
872
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
872
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
873 873
 			}
874 874
 			$Spotter = new Spotter($this->db);
875 875
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 		}
878 878
 		return $all;
879 879
 	}
880
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
880
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
881 881
 		global $globalStatsFilters;
882 882
 		if ($filter_name == '') $filter_name = $this->filter_name;
883 883
 		if ($year == '' && $month == '') {
@@ -886,18 +886,18 @@  discard block
 block discarded – undo
886 886
 			try {
887 887
 				$sth = $this->db->prepare($query);
888 888
 				$sth->execute($query_values);
889
-			} catch(PDOException $e) {
889
+			} catch (PDOException $e) {
890 890
 				echo "error : ".$e->getMessage();
891 891
 			}
892 892
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
893 893
 			$all = $result[0]['nb'];
894 894
 		} else {
895
-			$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
895
+			$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
896 896
 		}
897 897
 		if (empty($all)) {
898
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
898
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
899 899
 			if ($filter_name != '') {
900
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
900
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
901 901
 			}
902 902
 			$Spotter = new Spotter($this->db);
903 903
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 		}
906 906
 		return $all;
907 907
 	}
908
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
908
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
909 909
 		global $globalStatsFilters;
910 910
 		if ($filter_name == '') $filter_name = $this->filter_name;
911 911
 		//if ($year == '') $year = date('Y');
@@ -915,18 +915,18 @@  discard block
 block discarded – undo
915 915
 			try {
916 916
 				$sth = $this->db->prepare($query);
917 917
 				$sth->execute($query_values);
918
-			} catch(PDOException $e) {
918
+			} catch (PDOException $e) {
919 919
 				echo "error : ".$e->getMessage();
920 920
 			}
921 921
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
922 922
 			$all = $result[0]['nb'];
923 923
 		} else {
924
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
924
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
925 925
 		}
926 926
 		if (empty($all)) {
927
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
927
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
928 928
 			if ($filter_name != '') {
929
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
929
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
930 930
 			}
931 931
 			$Spotter = new Spotter($this->db);
932 932
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -935,69 +935,69 @@  discard block
 block discarded – undo
935 935
 		return $all;
936 936
 	}
937 937
 
938
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
938
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
939 939
 		if ($filter_name == '') $filter_name = $this->filter_name;
940 940
 		$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";
941
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
941
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
942 942
                  try {
943 943
                         $sth = $this->db->prepare($query);
944 944
                         $sth->execute($query_values);
945
-                } catch(PDOException $e) {
945
+                } catch (PDOException $e) {
946 946
                         echo "error : ".$e->getMessage();
947 947
                 }
948 948
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
949 949
                 return $all;
950 950
 	}
951
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
951
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
952 952
 		if ($filter_name == '') $filter_name = $this->filter_name;
953 953
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
954
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
954
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
955 955
                  try {
956 956
                         $sth = $this->db->prepare($query);
957 957
                         $sth->execute($query_values);
958
-                } catch(PDOException $e) {
958
+                } catch (PDOException $e) {
959 959
                         echo "error : ".$e->getMessage();
960 960
                 }
961 961
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
962 962
                 return $all;
963 963
         }
964
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
964
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
965 965
 		if ($filter_name == '') $filter_name = $this->filter_name;
966 966
                 $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
967
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
967
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
968 968
                  try {
969 969
                         $sth = $this->db->prepare($query);
970 970
                         $sth->execute($query_values);
971
-                } catch(PDOException $e) {
971
+                } catch (PDOException $e) {
972 972
                         echo "error : ".$e->getMessage();
973 973
                 }
974 974
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
975 975
                 return $all;
976 976
         }
977
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
977
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
978 978
 		if ($filter_name == '') $filter_name = $this->filter_name;
979 979
     		global $globalArchiveMonths, $globalDBdriver;
980 980
     		if ($globalDBdriver == 'mysql') {
981 981
     			if ($month == '') {
982 982
 				$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";
983
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
983
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
984 984
 			} else {
985 985
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
986
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
986
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
987 987
 			}
988 988
 		} else {
989 989
 			if ($month == '') {
990 990
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
991
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
991
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
992 992
 			} else {
993 993
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
994
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
994
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
995 995
 			}
996 996
                 }
997 997
                  try {
998 998
                         $sth = $this->db->prepare($query);
999 999
                         $sth->execute($query_values);
1000
-                } catch(PDOException $e) {
1000
+                } catch (PDOException $e) {
1001 1001
                         echo "error : ".$e->getMessage();
1002 1002
                 }
1003 1003
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
                  try {
1016 1016
                         $sth = $this->db->prepare($query);
1017 1017
                         $sth->execute($query_values);
1018
-                } catch(PDOException $e) {
1018
+                } catch (PDOException $e) {
1019 1019
                         echo "error : ".$e->getMessage();
1020 1020
                 }
1021 1021
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
                  try {
1033 1033
                         $sth = $this->db->prepare($query);
1034 1034
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1035
-                } catch(PDOException $e) {
1035
+                } catch (PDOException $e) {
1036 1036
                         echo "error : ".$e->getMessage();
1037 1037
                 }
1038 1038
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
                  try {
1050 1050
                         $sth = $this->db->prepare($query);
1051 1051
                         $sth->execute(array(':filter_name' => $filter_name));
1052
-                } catch(PDOException $e) {
1052
+                } catch (PDOException $e) {
1053 1053
                         echo "error : ".$e->getMessage();
1054 1054
                 }
1055 1055
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1066,20 +1066,20 @@  discard block
 block discarded – undo
1066 1066
                  try {
1067 1067
                         $sth = $this->db->prepare($query);
1068 1068
                         $sth->execute(array(':filter_name' => $filter_name));
1069
-                } catch(PDOException $e) {
1069
+                } catch (PDOException $e) {
1070 1070
                         echo "error : ".$e->getMessage();
1071 1071
                 }
1072 1072
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1073 1073
                 return $all[0]['total'];
1074 1074
         }
1075
-	public function getStatsOwner($owner_name,$filter_name = '') {
1075
+	public function getStatsOwner($owner_name, $filter_name = '') {
1076 1076
     		global $globalArchiveMonths, $globalDBdriver;
1077 1077
 		if ($filter_name == '') $filter_name = $this->filter_name;
1078 1078
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1079 1079
                  try {
1080 1080
                         $sth = $this->db->prepare($query);
1081
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1082
-                } catch(PDOException $e) {
1081
+                        $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1082
+                } catch (PDOException $e) {
1083 1083
                         echo "error : ".$e->getMessage();
1084 1084
                 }
1085 1085
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1097,20 +1097,20 @@  discard block
 block discarded – undo
1097 1097
                  try {
1098 1098
                         $sth = $this->db->prepare($query);
1099 1099
                         $sth->execute(array(':filter_name' => $filter_name));
1100
-                } catch(PDOException $e) {
1100
+                } catch (PDOException $e) {
1101 1101
                         echo "error : ".$e->getMessage();
1102 1102
                 }
1103 1103
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1104 1104
                 return $all[0]['total'];
1105 1105
         }
1106
-	public function getStatsPilot($pilot,$filter_name = '') {
1106
+	public function getStatsPilot($pilot, $filter_name = '') {
1107 1107
     		global $globalArchiveMonths, $globalDBdriver;
1108 1108
 		if ($filter_name == '') $filter_name = $this->filter_name;
1109 1109
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1110 1110
                  try {
1111 1111
                         $sth = $this->db->prepare($query);
1112
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1113
-                } catch(PDOException $e) {
1112
+                        $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1113
+                } catch (PDOException $e) {
1114 1114
                         echo "error : ".$e->getMessage();
1115 1115
                 }
1116 1116
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
                 else return 0;
1119 1119
         }
1120 1120
 
1121
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1121
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1122 1122
 		global $globalDBdriver;
1123 1123
 		if ($filter_name == '') $filter_name = $this->filter_name;
1124 1124
 		if ($globalDBdriver == 'mysql') {
@@ -1126,15 +1126,15 @@  discard block
 block discarded – undo
1126 1126
                 } else {
1127 1127
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1128 1128
 		}
1129
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1129
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1130 1130
                  try {
1131 1131
                         $sth = $this->db->prepare($query);
1132 1132
                         $sth->execute($query_values);
1133
-                } catch(PDOException $e) {
1133
+                } catch (PDOException $e) {
1134 1134
                         return "error : ".$e->getMessage();
1135 1135
                 }
1136 1136
         }
1137
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1137
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1138 1138
 		global $globalDBdriver;
1139 1139
 		if ($filter_name == '') $filter_name = $this->filter_name;
1140 1140
 		if ($globalDBdriver == 'mysql') {
@@ -1143,11 +1143,11 @@  discard block
 block discarded – undo
1143 1143
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1144 1144
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1145 1145
                 }
1146
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1146
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1147 1147
                  try {
1148 1148
                         $sth = $this->db->prepare($query);
1149 1149
                         $sth->execute($query_values);
1150
-                } catch(PDOException $e) {
1150
+                } catch (PDOException $e) {
1151 1151
                         return "error : ".$e->getMessage();
1152 1152
                 }
1153 1153
         }
@@ -1171,75 +1171,75 @@  discard block
 block discarded – undo
1171 1171
         }
1172 1172
         */
1173 1173
 
1174
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1174
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1175 1175
 		global $globalDBdriver;
1176 1176
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1177 1177
 		$query_values = array();
1178 1178
 		if ($globalDBdriver == 'mysql') {
1179 1179
 			if ($year != '') {
1180 1180
 				$query .= ' AND YEAR(stats_date) = :year';
1181
-				$query_values = array_merge($query_values,array(':year' => $year));
1181
+				$query_values = array_merge($query_values, array(':year' => $year));
1182 1182
 			}
1183 1183
 			if ($month != '') {
1184 1184
 				$query .= ' AND MONTH(stats_date) = :month';
1185
-				$query_values = array_merge($query_values,array(':month' => $month));
1185
+				$query_values = array_merge($query_values, array(':month' => $month));
1186 1186
 			}
1187 1187
 			if ($day != '') {
1188 1188
 				$query .= ' AND DAY(stats_date) = :day';
1189
-				$query_values = array_merge($query_values,array(':day' => $day));
1189
+				$query_values = array_merge($query_values, array(':day' => $day));
1190 1190
 			}
1191 1191
 		} else {
1192 1192
 			if ($year != '') {
1193 1193
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1194
-				$query_values = array_merge($query_values,array(':year' => $year));
1194
+				$query_values = array_merge($query_values, array(':year' => $year));
1195 1195
 			}
1196 1196
 			if ($month != '') {
1197 1197
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1198
-				$query_values = array_merge($query_values,array(':month' => $month));
1198
+				$query_values = array_merge($query_values, array(':month' => $month));
1199 1199
 			}
1200 1200
 			if ($day != '') {
1201 1201
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1202
-				$query_values = array_merge($query_values,array(':day' => $day));
1202
+				$query_values = array_merge($query_values, array(':day' => $day));
1203 1203
 			}
1204 1204
 		}
1205 1205
 		$query .= " ORDER BY source_name";
1206
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1206
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1207 1207
 		try {
1208 1208
 			$sth = $this->db->prepare($query);
1209 1209
 			$sth->execute($query_values);
1210
-		} catch(PDOException $e) {
1210
+		} catch (PDOException $e) {
1211 1211
 			echo "error : ".$e->getMessage();
1212 1212
 		}
1213 1213
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1214 1214
 		return $all;
1215 1215
 	}
1216 1216
 
1217
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1217
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1218 1218
 		global $globalDBdriver;
1219 1219
 		if ($globalDBdriver == 'mysql') {
1220 1220
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1221 1221
 		} else {
1222 1222
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1223 1223
                 }
1224
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1224
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1225 1225
                  try {
1226 1226
                         $sth = $this->db->prepare($query);
1227 1227
                         $sth->execute($query_values);
1228
-                } catch(PDOException $e) {
1228
+                } catch (PDOException $e) {
1229 1229
                         return "error : ".$e->getMessage();
1230 1230
                 }
1231 1231
         }
1232
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1232
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1233 1233
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1234
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1234
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1235 1235
                  try {
1236 1236
                         $sth = $this->db->prepare($query);
1237 1237
                         $sth->execute($query_values);
1238
-                } catch(PDOException $e) {
1238
+                } catch (PDOException $e) {
1239 1239
                         return "error : ".$e->getMessage();
1240 1240
                 }
1241 1241
         }
1242
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1242
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1243 1243
 		global $globalDBdriver;
1244 1244
 		if ($globalDBdriver == 'mysql') {
1245 1245
 			if ($reset) {
@@ -1254,15 +1254,15 @@  discard block
 block discarded – undo
1254 1254
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1255 1255
 			}
1256 1256
 		}
1257
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1257
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1258 1258
                  try {
1259 1259
                         $sth = $this->db->prepare($query);
1260 1260
                         $sth->execute($query_values);
1261
-                } catch(PDOException $e) {
1261
+                } catch (PDOException $e) {
1262 1262
                         return "error : ".$e->getMessage();
1263 1263
                 }
1264 1264
         }
1265
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1265
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1266 1266
 		global $globalDBdriver;
1267 1267
 		if ($globalDBdriver == 'mysql') {
1268 1268
 			if ($reset) {
@@ -1277,15 +1277,15 @@  discard block
 block discarded – undo
1277 1277
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1278 1278
 			}
1279 1279
 		}
1280
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1280
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1281 1281
                  try {
1282 1282
                         $sth = $this->db->prepare($query);
1283 1283
                         $sth->execute($query_values);
1284
-                } catch(PDOException $e) {
1284
+                } catch (PDOException $e) {
1285 1285
                         return "error : ".$e->getMessage();
1286 1286
                 }
1287 1287
         }
1288
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1288
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1289 1289
 		global $globalDBdriver;
1290 1290
 		if ($globalDBdriver == 'mysql') {
1291 1291
 			if ($reset) {
@@ -1300,15 +1300,15 @@  discard block
 block discarded – undo
1300 1300
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
1301 1301
 			}
1302 1302
 		}
1303
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1303
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1304 1304
                  try {
1305 1305
                         $sth = $this->db->prepare($query);
1306 1306
                         $sth->execute($query_values);
1307
-                } catch(PDOException $e) {
1307
+                } catch (PDOException $e) {
1308 1308
                         return "error : ".$e->getMessage();
1309 1309
                 }
1310 1310
         }
1311
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1311
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1312 1312
 		global $globalDBdriver;
1313 1313
 		if ($globalDBdriver == 'mysql') {
1314 1314
 			if ($reset) {
@@ -1323,15 +1323,15 @@  discard block
 block discarded – undo
1323 1323
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1324 1324
 			}
1325 1325
 		}
1326
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1326
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1327 1327
                  try {
1328 1328
                         $sth = $this->db->prepare($query);
1329 1329
                         $sth->execute($query_values);
1330
-                } catch(PDOException $e) {
1330
+                } catch (PDOException $e) {
1331 1331
                         return "error : ".$e->getMessage();
1332 1332
                 }
1333 1333
         }
1334
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1334
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1335 1335
 		global $globalDBdriver;
1336 1336
 		if ($globalDBdriver == 'mysql') {
1337 1337
 			if ($reset) {
@@ -1346,15 +1346,15 @@  discard block
 block discarded – undo
1346 1346
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1347 1347
 			}
1348 1348
 		}
1349
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1349
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1350 1350
                  try {
1351 1351
                         $sth = $this->db->prepare($query);
1352 1352
                         $sth->execute($query_values);
1353
-                } catch(PDOException $e) {
1353
+                } catch (PDOException $e) {
1354 1354
                         return "error : ".$e->getMessage();
1355 1355
                 }
1356 1356
         }
1357
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1357
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1358 1358
 		global $globalDBdriver;
1359 1359
 		if ($globalDBdriver == 'mysql') {
1360 1360
 			if ($reset) {
@@ -1369,15 +1369,15 @@  discard block
 block discarded – undo
1369 1369
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1370 1370
 			}
1371 1371
 		}
1372
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1372
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1373 1373
                  try {
1374 1374
                         $sth = $this->db->prepare($query);
1375 1375
                         $sth->execute($query_values);
1376
-                } catch(PDOException $e) {
1376
+                } catch (PDOException $e) {
1377 1377
                         return "error : ".$e->getMessage();
1378 1378
                 }
1379 1379
         }
1380
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1380
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1381 1381
 		global $globalDBdriver;
1382 1382
 		if ($globalDBdriver == 'mysql') {
1383 1383
 			if ($reset) {
@@ -1392,15 +1392,15 @@  discard block
 block discarded – undo
1392 1392
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1393 1393
 			}
1394 1394
 		}
1395
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1395
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
1396 1396
                  try {
1397 1397
                         $sth = $this->db->prepare($query);
1398 1398
                         $sth->execute($query_values);
1399
-                } catch(PDOException $e) {
1399
+                } catch (PDOException $e) {
1400 1400
                         return "error : ".$e->getMessage();
1401 1401
                 }
1402 1402
         }
1403
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1403
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1404 1404
 		global $globalDBdriver;
1405 1405
 		if ($airport_icao != '') {
1406 1406
 			if ($globalDBdriver == 'mysql') {
@@ -1416,16 +1416,16 @@  discard block
 block discarded – undo
1416 1416
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1417 1417
 				}
1418 1418
 			}
1419
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1419
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1420 1420
 			try {
1421 1421
 				$sth = $this->db->prepare($query);
1422 1422
 				$sth->execute($query_values);
1423
-			} catch(PDOException $e) {
1423
+			} catch (PDOException $e) {
1424 1424
 				return "error : ".$e->getMessage();
1425 1425
 			}
1426 1426
                 }
1427 1427
         }
1428
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1428
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1429 1429
 		global $globalDBdriver;
1430 1430
 		if ($airport_icao != '') {
1431 1431
 			if ($globalDBdriver == 'mysql') {
@@ -1433,16 +1433,16 @@  discard block
 block discarded – undo
1433 1433
 			} else {
1434 1434
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1435 1435
 			}
1436
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1436
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1437 1437
 			 try {
1438 1438
 				$sth = $this->db->prepare($query);
1439 1439
 				$sth->execute($query_values);
1440
-			} catch(PDOException $e) {
1440
+			} catch (PDOException $e) {
1441 1441
 				return "error : ".$e->getMessage();
1442 1442
 			}
1443 1443
                 }
1444 1444
         }
1445
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1445
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1446 1446
 		global $globalDBdriver;
1447 1447
 		if ($airport_icao != '') {
1448 1448
 			if ($globalDBdriver == 'mysql') {
@@ -1458,16 +1458,16 @@  discard block
 block discarded – undo
1458 1458
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1459 1459
 				}
1460 1460
 			}
1461
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1461
+	                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1462 1462
 			 try {
1463 1463
                     		$sth = $this->db->prepare($query);
1464 1464
 	                        $sth->execute($query_values);
1465
-    		        } catch(PDOException $e) {
1465
+    		        } catch (PDOException $e) {
1466 1466
             		        return "error : ".$e->getMessage();
1467 1467
 	                }
1468 1468
 	        }
1469 1469
         }
1470
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1470
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1471 1471
 		global $globalDBdriver;
1472 1472
 		if ($airport_icao != '') {
1473 1473
 			if ($globalDBdriver == 'mysql') {
@@ -1475,11 +1475,11 @@  discard block
 block discarded – undo
1475 1475
 			} else {
1476 1476
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1477 1477
 			}
1478
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1478
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1479 1479
 			try {
1480 1480
 				$sth = $this->db->prepare($query);
1481 1481
 				$sth->execute($query_values);
1482
-			} catch(PDOException $e) {
1482
+			} catch (PDOException $e) {
1483 1483
 				return "error : ".$e->getMessage();
1484 1484
 			}
1485 1485
                 }
@@ -1491,7 +1491,7 @@  discard block
 block discarded – undo
1491 1491
                  try {
1492 1492
                         $sth = $this->db->prepare($query);
1493 1493
                         $sth->execute($query_values);
1494
-                } catch(PDOException $e) {
1494
+                } catch (PDOException $e) {
1495 1495
                         return "error : ".$e->getMessage();
1496 1496
                 }
1497 1497
         }
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
                  try {
1502 1502
                         $sth = $this->db->prepare($query);
1503 1503
                         $sth->execute($query_values);
1504
-                } catch(PDOException $e) {
1504
+                } catch (PDOException $e) {
1505 1505
                         return "error : ".$e->getMessage();
1506 1506
                 }
1507 1507
         }
@@ -1511,13 +1511,13 @@  discard block
 block discarded – undo
1511 1511
                  try {
1512 1512
                         $sth = $this->db->prepare($query);
1513 1513
                         $sth->execute($query_values);
1514
-                } catch(PDOException $e) {
1514
+                } catch (PDOException $e) {
1515 1515
                         return "error : ".$e->getMessage();
1516 1516
                 }
1517 1517
         }
1518 1518
         
1519 1519
         public function addOldStats() {
1520
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1520
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear;
1521 1521
     		$Common = new Common();
1522 1522
     		$Connection = new Connection();
1523 1523
     		date_default_timezone_set('UTC');
@@ -1535,40 +1535,40 @@  discard block
 block discarded – undo
1535 1535
 			$Spotter = new Spotter($this->db);
1536 1536
 
1537 1537
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1538
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1538
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1539 1539
 			foreach ($alldata as $number) {
1540
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1540
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
1541 1541
 			}
1542 1542
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1543
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1543
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1544 1544
 			foreach ($alldata as $number) {
1545
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1545
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1546 1546
 			}
1547 1547
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1548
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1548
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1549 1549
 			foreach ($alldata as $number) {
1550
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1550
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1551 1551
 			}
1552 1552
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1553
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1553
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1554 1554
 			foreach ($alldata as $number) {
1555
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1555
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1556 1556
 			}
1557 1557
 			if ($globalDebug) echo 'Count all owners...'."\n";
1558
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1558
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1559 1559
 			foreach ($alldata as $number) {
1560
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1560
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1561 1561
 			}
1562 1562
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1563
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1563
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1564 1564
 			foreach ($alldata as $number) {
1565
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1565
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1566 1566
 			}
1567 1567
 			
1568 1568
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1569
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1569
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1570 1570
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1571
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1571
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1572 1572
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1573 1573
 	        	$alldata = array();
1574 1574
 	        	
@@ -1586,14 +1586,14 @@  discard block
 block discarded – undo
1586 1586
     			foreach ($alldata as $key => $row) {
1587 1587
     				$count[$key] = $row['airport_departure_icao_count'];
1588 1588
         		}
1589
-			array_multisort($count,SORT_DESC,$alldata);
1589
+			array_multisort($count, SORT_DESC, $alldata);
1590 1590
 			foreach ($alldata as $number) {
1591
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1591
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset);
1592 1592
 			}
1593 1593
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1594
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1594
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1595 1595
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1596
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1596
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1597 1597
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1598 1598
 	        	$alldata = array();
1599 1599
     			foreach ($pall as $value) {
@@ -1610,16 +1610,16 @@  discard block
 block discarded – undo
1610 1610
         		foreach ($alldata as $key => $row) {
1611 1611
         			$count[$key] = $row['airport_arrival_icao_count'];
1612 1612
 	        	}
1613
-    			array_multisort($count,SORT_DESC,$alldata);
1613
+    			array_multisort($count, SORT_DESC, $alldata);
1614 1614
                         foreach ($alldata as $number) {
1615
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1615
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset);
1616 1616
 			}
1617 1617
 			if ($Connection->tableExists('countries')) {
1618 1618
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1619 1619
 				$SpotterArchive = new SpotterArchive();
1620
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1620
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1621 1621
 				foreach ($alldata as $number) {
1622
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
1622
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
1623 1623
 				}
1624 1624
 			}
1625 1625
 			
@@ -1628,12 +1628,12 @@  discard block
 block discarded – undo
1628 1628
 			$this->deleteStatsByType('fatalities_byyear');
1629 1629
 			$alldata = $Accident->countFatalitiesByYear();
1630 1630
 			foreach ($alldata as $number) {
1631
-				$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
1631
+				$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
1632 1632
 			}
1633 1633
 			$this->deleteStatsByType('fatalities_bymonth');
1634 1634
 			$alldata = $Accident->countFatalitiesLast12Months();
1635 1635
 			foreach ($alldata as $number) {
1636
-				$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
1636
+				$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
1637 1637
 			}
1638 1638
 
1639 1639
 
@@ -1646,37 +1646,37 @@  discard block
 block discarded – undo
1646 1646
 			$lastyear = false;
1647 1647
 			foreach ($alldata as $number) {
1648 1648
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1649
-				$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'])));
1649
+				$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'])));
1650 1650
 			}
1651 1651
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1652 1652
 			$alldata = $Spotter->countAllMilitaryMonths();
1653 1653
 			foreach ($alldata as $number) {
1654
-				$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'])));
1654
+				$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'])));
1655 1655
 			}
1656 1656
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1657 1657
 			$alldata = $Spotter->countAllMonthsOwners();
1658 1658
 			foreach ($alldata as $number) {
1659
-				$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'])));
1659
+				$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'])));
1660 1660
 			}
1661 1661
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1662 1662
 			$alldata = $Spotter->countAllMonthsPilots();
1663 1663
 			foreach ($alldata as $number) {
1664
-				$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'])));
1664
+				$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'])));
1665 1665
 			}
1666 1666
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1667 1667
 			$alldata = $Spotter->countAllMonthsAirlines();
1668 1668
 			foreach ($alldata as $number) {
1669
-				$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'])));
1669
+				$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'])));
1670 1670
 			}
1671 1671
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1672 1672
 			$alldata = $Spotter->countAllMonthsAircrafts();
1673 1673
 			foreach ($alldata as $number) {
1674
-				$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'])));
1674
+				$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'])));
1675 1675
 			}
1676 1676
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1677 1677
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1678 1678
 			foreach ($alldata as $number) {
1679
-				$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'])));
1679
+				$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'])));
1680 1680
 			}
1681 1681
 			if ($globalDebug) echo 'Airports data...'."\n";
1682 1682
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
     			}
1722 1722
     			$alldata = $pall;
1723 1723
 			foreach ($alldata as $number) {
1724
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1724
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1725 1725
 			}
1726 1726
 			echo '...Arrival'."\n";
1727 1727
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1763,7 +1763,7 @@  discard block
 block discarded – undo
1763 1763
     			}
1764 1764
     			$alldata = $pall;
1765 1765
 			foreach ($alldata as $number) {
1766
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1766
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1767 1767
 			}
1768 1768
 
1769 1769
 			echo 'Flights data...'."\n";
@@ -1771,28 +1771,28 @@  discard block
 block discarded – undo
1771 1771
 			echo '-> countAllDatesLastMonth...'."\n";
1772 1772
 			$alldata = $Spotter->countAllDatesLastMonth();
1773 1773
 			foreach ($alldata as $number) {
1774
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1774
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1775 1775
 			}
1776 1776
 			echo '-> countAllDates...'."\n";
1777 1777
 			$previousdata = $this->countAllDates();
1778 1778
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1779 1779
 			$this->deleteStatFlight('date');
1780
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1780
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1781 1781
 			$values = array();
1782 1782
 			foreach ($alldata as $cnt) {
1783 1783
 				$values[] = $cnt['date_count'];
1784 1784
 			}
1785
-			array_multisort($values,SORT_DESC,$alldata);
1786
-			array_splice($alldata,11);
1785
+			array_multisort($values, SORT_DESC, $alldata);
1786
+			array_splice($alldata, 11);
1787 1787
 			foreach ($alldata as $number) {
1788
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1788
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1789 1789
 			}
1790 1790
 			
1791 1791
 			$this->deleteStatFlight('hour');
1792 1792
 			echo '-> countAllHours...'."\n";
1793 1793
 			$alldata = $Spotter->countAllHours('hour');
1794 1794
 			foreach ($alldata as $number) {
1795
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1795
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1796 1796
 			}
1797 1797
 
1798 1798
 
@@ -1802,41 +1802,41 @@  discard block
 block discarded – undo
1802 1802
 			if ($Connection->tableExists('countries')) {
1803 1803
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1804 1804
 				$SpotterArchive = new SpotterArchive();
1805
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1805
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
1806 1806
 				foreach ($alldata as $number) {
1807
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1807
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
1808 1808
 				}
1809 1809
 			}
1810 1810
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1811 1811
 			$Spotter = new Spotter($this->db);
1812
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1812
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1813 1813
 			foreach ($alldata as $number) {
1814
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1814
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1815 1815
 			}
1816 1816
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1817
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1817
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1818 1818
 			foreach ($alldata as $number) {
1819
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1819
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1820 1820
 			}
1821 1821
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1822
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1822
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1823 1823
 			foreach ($alldata as $number) {
1824
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1824
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1825 1825
 			}
1826 1826
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1827
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1827
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1828 1828
 			foreach ($alldata as $number) {
1829
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1829
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1830 1830
 			}
1831 1831
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1832
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1832
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1833 1833
 			foreach ($alldata as $number) {
1834
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1834
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1835 1835
 			}
1836 1836
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1837
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1837
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1838 1838
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1839
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1839
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1840 1840
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1841 1841
 	        	//$alldata = array();
1842 1842
     			foreach ($dall as $value) {
@@ -1856,12 +1856,12 @@  discard block
 block discarded – undo
1856 1856
     			}
1857 1857
     			$alldata = $pall;
1858 1858
 			foreach ($alldata as $number) {
1859
-				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'],'',$reset);
1859
+				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'], '', $reset);
1860 1860
 			}
1861 1861
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1862
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1862
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1863 1863
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1864
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1864
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1865 1865
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1866 1866
 	        	//$alldata = array();
1867 1867
     			foreach ($dall as $value) {
@@ -1881,7 +1881,7 @@  discard block
 block discarded – undo
1881 1881
     			}
1882 1882
     			$alldata = $pall;
1883 1883
                         foreach ($alldata as $number) {
1884
-				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'],'',$reset);
1884
+				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'], '', $reset);
1885 1885
 			}
1886 1886
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1887 1887
 			$Spotter = new Spotter($this->db);
@@ -1889,27 +1889,27 @@  discard block
 block discarded – undo
1889 1889
 			$lastyear = false;
1890 1890
 			foreach ($alldata as $number) {
1891 1891
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1892
-				$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']);
1892
+				$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']);
1893 1893
 			}
1894 1894
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1895 1895
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1896 1896
 			foreach ($alldata as $number) {
1897
-				$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']);
1897
+				$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']);
1898 1898
 			}
1899 1899
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1900 1900
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1901 1901
 			foreach ($alldata as $number) {
1902
-				$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']);
1902
+				$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']);
1903 1903
 			}
1904 1904
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1905 1905
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1906 1906
 			foreach ($alldata as $number) {
1907
-				$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']);
1907
+				$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']);
1908 1908
 			}
1909 1909
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1910 1910
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1911 1911
 			foreach ($alldata as $number) {
1912
-				$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']);
1912
+				$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']);
1913 1913
 			}
1914 1914
 			if ($globalDebug) echo '...Departure'."\n";
1915 1915
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1932,7 +1932,7 @@  discard block
 block discarded – undo
1932 1932
     			}
1933 1933
     			$alldata = $pall;
1934 1934
 			foreach ($alldata as $number) {
1935
-				$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']);
1935
+				$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']);
1936 1936
 			}
1937 1937
 			if ($globalDebug) echo '...Arrival'."\n";
1938 1938
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1955,32 +1955,32 @@  discard block
 block discarded – undo
1955 1955
     			}
1956 1956
     			$alldata = $pall;
1957 1957
 			foreach ($alldata as $number) {
1958
-				$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']);
1958
+				$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']);
1959 1959
 			}
1960 1960
 
1961 1961
 			if ($globalDebug) echo 'Flights data...'."\n";
1962 1962
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1963 1963
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1964 1964
 			foreach ($alldata as $number) {
1965
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1965
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1966 1966
 			}
1967 1967
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1968 1968
 			//$previousdata = $this->countAllDatesByAirlines();
1969
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1969
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1970 1970
 			$values = array();
1971 1971
 			foreach ($alldata as $cnt) {
1972 1972
 				$values[] = $cnt['date_count'];
1973 1973
 			}
1974
-			array_multisort($values,SORT_DESC,$alldata);
1975
-			array_splice($alldata,11);
1974
+			array_multisort($values, SORT_DESC, $alldata);
1975
+			array_splice($alldata, 11);
1976 1976
 			foreach ($alldata as $number) {
1977
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1977
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1978 1978
 			}
1979 1979
 			
1980 1980
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1981 1981
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1982 1982
 			foreach ($alldata as $number) {
1983
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1983
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1984 1984
 			}
1985 1985
 			
1986 1986
 
@@ -2004,7 +2004,7 @@  discard block
 block discarded – undo
2004 2004
 						$last_update_day = date('Y').'-01-01 00:00:00';
2005 2005
 					}
2006 2006
 				}
2007
-				if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
2007
+				if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
2008 2008
 					$last_update_day = date('Y').'-01-01 00:00:00';
2009 2009
 					$reset = true;
2010 2010
 				}
@@ -2013,32 +2013,32 @@  discard block
 block discarded – undo
2013 2013
 				// Count by filter
2014 2014
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2015 2015
 				$Spotter = new Spotter($this->db);
2016
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2016
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
2017 2017
 				foreach ($alldata as $number) {
2018
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2018
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
2019 2019
 				}
2020
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2020
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
2021 2021
 				foreach ($alldata as $number) {
2022
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2022
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
2023 2023
 				}
2024
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2024
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
2025 2025
 				foreach ($alldata as $number) {
2026
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2026
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
2027 2027
 				}
2028
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2028
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
2029 2029
 				foreach ($alldata as $number) {
2030
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2030
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
2031 2031
 				}
2032
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2032
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
2033 2033
 				foreach ($alldata as $number) {
2034
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2034
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
2035 2035
 				}
2036
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2036
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
2037 2037
 				foreach ($alldata as $number) {
2038
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2038
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
2039 2039
 				}
2040
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2041
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2040
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
2041
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
2042 2042
 		        	$alldata = array();
2043 2043
 	    			foreach ($pall as $value) {
2044 2044
 		        		$icao = $value['airport_departure_icao'];
@@ -2054,12 +2054,12 @@  discard block
 block discarded – undo
2054 2054
     				foreach ($alldata as $key => $row) {
2055 2055
     					$count[$key] = $row['airport_departure_icao_count'];
2056 2056
     				}
2057
-				array_multisort($count,SORT_DESC,$alldata);
2057
+				array_multisort($count, SORT_DESC, $alldata);
2058 2058
 				foreach ($alldata as $number) {
2059
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
2059
+    					echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
2060 2060
 				}
2061
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2062
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2061
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
2062
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
2063 2063
 				$alldata = array();
2064 2064
     				foreach ($pall as $value) {
2065 2065
 		        		$icao = $value['airport_arrival_icao'];
@@ -2075,40 +2075,40 @@  discard block
 block discarded – undo
2075 2075
         			foreach ($alldata as $key => $row) {
2076 2076
     					$count[$key] = $row['airport_arrival_icao_count'];
2077 2077
 		        	}
2078
-        			array_multisort($count,SORT_DESC,$alldata);
2078
+        			array_multisort($count, SORT_DESC, $alldata);
2079 2079
 				foreach ($alldata as $number) {
2080
-					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
2080
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
2081 2081
 				}
2082 2082
 				$Spotter = new Spotter($this->db);
2083 2083
 				$alldata = $Spotter->countAllMonths($filter);
2084 2084
 				$lastyear = false;
2085 2085
 				foreach ($alldata as $number) {
2086 2086
 					if ($number['year_name'] != date('Y')) $lastyear = true;
2087
-					$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);
2087
+					$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);
2088 2088
 				}
2089 2089
 				$alldata = $Spotter->countAllMonthsOwners($filter);
2090 2090
 				foreach ($alldata as $number) {
2091
-					$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'])),'',$filter_name);
2091
+					$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'])), '', $filter_name);
2092 2092
 				}
2093 2093
 				$alldata = $Spotter->countAllMonthsPilots($filter);
2094 2094
 				foreach ($alldata as $number) {
2095
-					$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'])),'',$filter_name);
2095
+					$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'])), '', $filter_name);
2096 2096
 				}
2097 2097
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
2098 2098
 				foreach ($alldata as $number) {
2099
-					$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'])),'',$filter_name);
2099
+					$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'])), '', $filter_name);
2100 2100
 				}
2101 2101
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
2102 2102
 				foreach ($alldata as $number) {
2103
-					$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'])),'',$filter_name);
2103
+					$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'])), '', $filter_name);
2104 2104
 				}
2105 2105
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2106 2106
 				foreach ($alldata as $number) {
2107
-					$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'])),'',$filter_name);
2107
+					$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'])), '', $filter_name);
2108 2108
 				}
2109 2109
 				echo '...Departure'."\n";
2110
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
2111
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2110
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
2111
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
2112 2112
 				foreach ($dall as $value) {
2113 2113
     					$icao = $value['departure_airport_icao'];
2114 2114
     					$ddate = $value['date'];
@@ -2126,11 +2126,11 @@  discard block
 block discarded – undo
2126 2126
     				}
2127 2127
 	    			$alldata = $pall;
2128 2128
 				foreach ($alldata as $number) {
2129
-					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
2129
+					$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name);
2130 2130
 				}
2131 2131
 				echo '...Arrival'."\n";
2132
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2133
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2132
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
2133
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
2134 2134
 				foreach ($dall as $value) {
2135 2135
 					$icao = $value['arrival_airport_icao'];
2136 2136
 					$ddate = $value['date'];
@@ -2148,40 +2148,40 @@  discard block
 block discarded – undo
2148 2148
     				}
2149 2149
     				$alldata = $pall;
2150 2150
 				foreach ($alldata as $number) {
2151
-					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
2151
+					$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name);
2152 2152
 				}
2153 2153
     
2154 2154
 				echo 'Flights data...'."\n";
2155 2155
 				echo '-> countAllDatesLastMonth...'."\n";
2156 2156
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
2157 2157
 				foreach ($alldata as $number) {
2158
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
2158
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
2159 2159
 				}
2160 2160
 				echo '-> countAllDates...'."\n";
2161
-				$previousdata = $this->countAllDates('',$filter_name);
2162
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
2161
+				$previousdata = $this->countAllDates('', $filter_name);
2162
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
2163 2163
 				$values = array();
2164 2164
 				foreach ($alldata as $cnt) {
2165 2165
 					$values[] = $cnt['date_count'];
2166 2166
 				}
2167
-				array_multisort($values,SORT_DESC,$alldata);
2168
-				array_splice($alldata,11);
2167
+				array_multisort($values, SORT_DESC, $alldata);
2168
+				array_splice($alldata, 11);
2169 2169
 				foreach ($alldata as $number) {
2170
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
2170
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
2171 2171
 				}
2172 2172
 				
2173 2173
 				echo '-> countAllHours...'."\n";
2174
-				$alldata = $Spotter->countAllHours('hour',$filter);
2174
+				$alldata = $Spotter->countAllHours('hour', $filter);
2175 2175
 				foreach ($alldata as $number) {
2176
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
2176
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
2177 2177
 				}
2178 2178
 				echo 'Insert last stats update date...'."\n";
2179 2179
 				date_default_timezone_set('UTC');
2180
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
2180
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
2181 2181
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
2182
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
2182
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
2183 2183
 						$this->deleteOldStats($filter_name);
2184
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
2184
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2185 2185
 					}
2186 2186
 				}
2187 2187
 
@@ -2194,16 +2194,16 @@  discard block
 block discarded – undo
2194 2194
 				// SUM all previous month to put as year
2195 2195
 				$previous_year = date('Y');
2196 2196
 				$previous_year--;
2197
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2198
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2199
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2200
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2197
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2198
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2199
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2200
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2201 2201
 				$allairlines = $this->getAllAirlineNames();
2202 2202
 				foreach ($allairlines as $data) {
2203
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2204
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2205
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2206
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2203
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2204
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2205
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2206
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2207 2207
 				}
2208 2208
 				
2209 2209
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2212,7 +2212,7 @@  discard block
 block discarded – undo
2212 2212
 						try {
2213 2213
 							$sth = $this->db->prepare($query);
2214 2214
 							$sth->execute();
2215
-						} catch(PDOException $e) {
2215
+						} catch (PDOException $e) {
2216 2216
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2217 2217
 						}
2218 2218
 					}
@@ -2221,15 +2221,15 @@  discard block
 block discarded – undo
2221 2221
 					try {
2222 2222
 						$sth = $this->db->prepare($query);
2223 2223
 						$sth->execute();
2224
-					} catch(PDOException $e) {
2224
+					} catch (PDOException $e) {
2225 2225
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2226 2226
 					}
2227 2227
 				}
2228 2228
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2229 2229
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2230
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2230
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2231 2231
 						$this->deleteOldStats();
2232
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2232
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2233 2233
 						$lastyearupdate = true;
2234 2234
 					}
2235 2235
 				}
@@ -2251,7 +2251,7 @@  discard block
 block discarded – undo
2251 2251
 					try {
2252 2252
 						$sth = $this->db->prepare($query);
2253 2253
 						$sth->execute();
2254
-					} catch(PDOException $e) {
2254
+					} catch (PDOException $e) {
2255 2255
 						return "error : ".$e->getMessage();
2256 2256
 					}
2257 2257
 				}
@@ -2265,14 +2265,14 @@  discard block
 block discarded – undo
2265 2265
 				try {
2266 2266
 					$sth = $this->db->prepare($query);
2267 2267
 					$sth->execute();
2268
-				} catch(PDOException $e) {
2268
+				} catch (PDOException $e) {
2269 2269
 					return "error : ".$e->getMessage();
2270 2270
 				}
2271 2271
 			}
2272 2272
 			if (!isset($lastyearupdate)) {
2273 2273
 				echo 'Insert last stats update date...'."\n";
2274 2274
 				date_default_timezone_set('UTC');
2275
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2275
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2276 2276
 			}
2277 2277
 			if ($globalStatsResetYear) {
2278 2278
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +482 added lines, -167 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 	
14 14
 	public function __construct($dbc = null) {
15 15
 		global $globalFilterName;
16
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16
+		if (isset($globalFilterName)) {
17
+			$this->filter_name = $globalFilterName;
18
+		}
17 19
 		$Connection = new Connection($dbc);
18 20
 		$this->db = $Connection->db();
19 21
         }
@@ -81,7 +83,9 @@  discard block
 block discarded – undo
81 83
                 }
82 84
         }
83 85
 	public function getAllAirlineNames($filter_name = '') {
84
-		if ($filter_name == '') $filter_name = $this->filter_name;
86
+		if ($filter_name == '') {
87
+			$filter_name = $this->filter_name;
88
+		}
85 89
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
86 90
                  try {
87 91
                         $sth = $this->db->prepare($query);
@@ -93,7 +97,9 @@  discard block
 block discarded – undo
93 97
                 return $all;
94 98
         }
95 99
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
96
-		if ($filter_name == '') $filter_name = $this->filter_name;
100
+		if ($filter_name == '') {
101
+			$filter_name = $this->filter_name;
102
+		}
97 103
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
98 104
                  try {
99 105
                         $sth = $this->db->prepare($query);
@@ -105,7 +111,9 @@  discard block
 block discarded – undo
105 111
                 return $all;
106 112
         }
107 113
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
108
-		if ($filter_name == '') $filter_name = $this->filter_name;
114
+		if ($filter_name == '') {
115
+			$filter_name = $this->filter_name;
116
+		}
109 117
                 $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";
110 118
                  try {
111 119
                         $sth = $this->db->prepare($query);
@@ -117,7 +125,9 @@  discard block
 block discarded – undo
117 125
                 return $all;
118 126
         }
119 127
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
120
-		if ($filter_name == '') $filter_name = $this->filter_name;
128
+		if ($filter_name == '') {
129
+			$filter_name = $this->filter_name;
130
+		}
121 131
                 $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";
122 132
                  try {
123 133
                         $sth = $this->db->prepare($query);
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
         }
131 141
 
132 142
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
133
-		if ($filter_name == '') $filter_name = $this->filter_name;
143
+		if ($filter_name == '') {
144
+			$filter_name = $this->filter_name;
145
+		}
134 146
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
135 147
                  try {
136 148
                         $sth = $this->db->prepare($query);
@@ -143,7 +155,9 @@  discard block
 block discarded – undo
143 155
         }
144 156
 
145 157
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
146
-		if ($filter_name == '') $filter_name = $this->filter_name;
158
+		if ($filter_name == '') {
159
+			$filter_name = $this->filter_name;
160
+		}
147 161
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
148 162
                  try {
149 163
                         $sth = $this->db->prepare($query);
@@ -158,10 +172,15 @@  discard block
 block discarded – undo
158 172
 
159 173
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
160 174
 		global $globalStatsFilters;
161
-		if ($filter_name == '') $filter_name = $this->filter_name;
175
+		if ($filter_name == '') {
176
+			$filter_name = $this->filter_name;
177
+		}
162 178
 		if ($year == '' && $month == '') {
163
-			if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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";
164
-			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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";
179
+			if ($limit) {
180
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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";
181
+			} else {
182
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer 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";
183
+			}
165 184
 			try {
166 185
 				$sth = $this->db->prepare($query);
167 186
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -169,7 +188,9 @@  discard block
 block discarded – undo
169 188
 				echo "error : ".$e->getMessage();
170 189
 			}
171 190
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
172
-		} else $all = array();
191
+		} else {
192
+			$all = array();
193
+		}
173 194
                 if (empty($all)) {
174 195
             	    $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
175 196
             	    if ($filter_name != '') {
@@ -183,10 +204,15 @@  discard block
 block discarded – undo
183 204
 	}
184 205
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
185 206
 		global $globalStatsFilters;
186
-		if ($filter_name == '') $filter_name = $this->filter_name;
207
+		if ($filter_name == '') {
208
+			$filter_name = $this->filter_name;
209
+		}
187 210
 		if ($year == '' && $month == '') {
188
-			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";
189
-			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";
211
+			if ($limit) {
212
+				$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";
213
+			} else {
214
+				$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";
215
+			}
190 216
 			try {
191 217
 				$sth = $this->db->prepare($query);
192 218
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -194,7 +220,9 @@  discard block
 block discarded – undo
194 220
 				echo "error : ".$e->getMessage();
195 221
 			}
196 222
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
197
-		} else $all = array();
223
+		} else {
224
+			$all = array();
225
+		}
198 226
                 if (empty($all)) {
199 227
             		$Spotter = new Spotter($this->db);
200 228
             		$filters = array();
@@ -209,10 +237,15 @@  discard block
 block discarded – undo
209 237
 	}
210 238
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
211 239
 		global $globalStatsFilters;
212
-		if ($filter_name == '') $filter_name = $this->filter_name;
240
+		if ($filter_name == '') {
241
+			$filter_name = $this->filter_name;
242
+		}
213 243
 		if ($year == '' && $month == '') {
214
-			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";
215
-			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";
244
+			if ($limit) {
245
+				$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";
246
+			} else {
247
+				$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";
248
+			}
216 249
 			try {
217 250
 				$sth = $this->db->prepare($query);
218 251
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -220,7 +253,9 @@  discard block
 block discarded – undo
220 253
 				echo "error : ".$e->getMessage();
221 254
 			}
222 255
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
223
-		} else $all = array();
256
+		} else {
257
+			$all = array();
258
+		}
224 259
 		if (empty($all)) {
225 260
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
226 261
 			if ($filter_name != '') {
@@ -235,10 +270,15 @@  discard block
 block discarded – undo
235 270
 
236 271
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
237 272
 		global $globalStatsFilters;
238
-		if ($filter_name == '') $filter_name = $this->filter_name;
273
+		if ($filter_name == '') {
274
+			$filter_name = $this->filter_name;
275
+		}
239 276
 		if ($year == '' && $month == '') {
240
-			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";
241
-			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";
277
+			if ($limit) {
278
+				$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";
279
+			} else {
280
+				$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";
281
+			}
242 282
 			try {
243 283
 				$sth = $this->db->prepare($query);
244 284
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -246,7 +286,9 @@  discard block
 block discarded – undo
246 286
 				echo "error : ".$e->getMessage();
247 287
 			}
248 288
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
249
-		} else $all = array();
289
+		} else {
290
+			$all = array();
291
+		}
250 292
                 if (empty($all)) {
251 293
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
252 294
 			if ($filter_name != '') {
@@ -260,9 +302,14 @@  discard block
 block discarded – undo
260 302
 	}
261 303
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
262 304
 		global $globalStatsFilters;
263
-		if ($filter_name == '') $filter_name = $this->filter_name;
264
-		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";
265
-		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";
305
+		if ($filter_name == '') {
306
+			$filter_name = $this->filter_name;
307
+		}
308
+		if ($limit) {
309
+			$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";
310
+		} else {
311
+			$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";
312
+		}
266 313
                  try {
267 314
                         $sth = $this->db->prepare($query);
268 315
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -284,17 +331,29 @@  discard block
 block discarded – undo
284 331
 
285 332
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
286 333
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
287
-		if ($filter_name == '') $filter_name = $this->filter_name;
334
+		if ($filter_name == '') {
335
+			$filter_name = $this->filter_name;
336
+		}
288 337
 		if ($year == '' && $month == '') {
289
-			if ($globalVATSIM) $forsource = 'vatsim';
290
-			if ($globalIVAO) $forsource = 'ivao';
338
+			if ($globalVATSIM) {
339
+				$forsource = 'vatsim';
340
+			}
341
+			if ($globalIVAO) {
342
+				$forsource = 'ivao';
343
+			}
291 344
 			if (isset($forsource)) {
292
-				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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
293
-				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 AND airlines.forsource = :forsource ORDER BY airline_count DESC";
345
+				if ($limit) {
346
+					$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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
347
+				} else {
348
+					$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 AND airlines.forsource = :forsource ORDER BY airline_count DESC";
349
+				}
294 350
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
295 351
 			} else {
296
-				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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
297
-				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 AND airlines.forsource IS NULL ORDER BY airline_count DESC";
352
+				if ($limit) {
353
+					$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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
354
+				} else {
355
+					$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 AND airlines.forsource IS NULL ORDER BY airline_count DESC";
356
+				}
298 357
 				$query_values = array(':filter_name' => $filter_name);
299 358
 			}
300 359
 			try {
@@ -304,7 +363,9 @@  discard block
 block discarded – undo
304 363
 				echo "error : ".$e->getMessage();
305 364
 			}
306 365
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
307
-		} else $all = array();
366
+		} else {
367
+			$all = array();
368
+		}
308 369
                 if (empty($all)) {
309 370
 	                $Spotter = new Spotter($this->db);
310 371
             		$filters = array();
@@ -319,10 +380,15 @@  discard block
 block discarded – undo
319 380
 	}
320 381
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
321 382
 		global $globalStatsFilters;
322
-		if ($filter_name == '') $filter_name = $this->filter_name;
383
+		if ($filter_name == '') {
384
+			$filter_name = $this->filter_name;
385
+		}
323 386
 		if ($year == '' && $month == '') {
324
-			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";
325
-			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";
387
+			if ($limit) {
388
+				$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";
389
+			} else {
390
+				$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";
391
+			}
326 392
 			try {
327 393
 				$sth = $this->db->prepare($query);
328 394
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -330,7 +396,9 @@  discard block
 block discarded – undo
330 396
 				echo "error : ".$e->getMessage();
331 397
 			}
332 398
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
333
-		} else $all = array();
399
+		} else {
400
+			$all = array();
401
+		}
334 402
                 if (empty($all)) {
335 403
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
336 404
 			if ($filter_name != '') {
@@ -344,10 +412,15 @@  discard block
 block discarded – undo
344 412
 	}
345 413
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
346 414
 		global $globalStatsFilters;
347
-		if ($filter_name == '') $filter_name = $this->filter_name;
415
+		if ($filter_name == '') {
416
+			$filter_name = $this->filter_name;
417
+		}
348 418
 		if ($year == '' && $month == '') {
349
-			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";
350
-			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";
419
+			if ($limit) {
420
+				$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";
421
+			} else {
422
+				$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";
423
+			}
351 424
 			 try {
352 425
 				$sth = $this->db->prepare($query);
353 426
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -355,7 +428,9 @@  discard block
 block discarded – undo
355 428
 				echo "error : ".$e->getMessage();
356 429
 			}
357 430
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
358
-		} else $all = array();
431
+		} else {
432
+			$all = array();
433
+		}
359 434
 		if (empty($all)) {
360 435
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
361 436
 			if ($filter_name != '') {
@@ -369,11 +444,16 @@  discard block
 block discarded – undo
369 444
 	}
370 445
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
371 446
 		$Connection = new Connection();
372
-		if ($filter_name == '') $filter_name = $this->filter_name;
447
+		if ($filter_name == '') {
448
+			$filter_name = $this->filter_name;
449
+		}
373 450
 		if ($Connection->tableExists('countries')) {
374 451
 			if ($year == '' && $month == '') {
375
-				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";
376
-				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";
452
+				if ($limit) {
453
+					$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";
454
+				} else {
455
+					$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";
456
+				}
377 457
 				 try {
378 458
 					$sth = $this->db->prepare($query);
379 459
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -388,17 +468,24 @@  discard block
 block discarded – undo
388 468
                 }
389 469
                 */
390 470
 				return $all;
391
-			} else return array();
471
+			} else {
472
+				return array();
473
+			}
392 474
 		} else {
393 475
 			return array();
394 476
 		}
395 477
 	}
396 478
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
397 479
 		global $globalStatsFilters;
398
-		if ($filter_name == '') $filter_name = $this->filter_name;
480
+		if ($filter_name == '') {
481
+			$filter_name = $this->filter_name;
482
+		}
399 483
 		if ($year == '' && $month == '') {
400
-			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";
401
-			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";
484
+			if ($limit) {
485
+				$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";
486
+			} else {
487
+				$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";
488
+			}
402 489
 			try {
403 490
 				$sth = $this->db->prepare($query);
404 491
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -406,7 +493,9 @@  discard block
 block discarded – undo
406 493
 				echo "error : ".$e->getMessage();
407 494
 			}
408 495
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
409
-		} else $all = array();
496
+		} else {
497
+			$all = array();
498
+		}
410 499
 		if (empty($all)) {
411 500
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
412 501
 			if ($filter_name != '') {
@@ -421,10 +510,15 @@  discard block
 block discarded – undo
421 510
 
422 511
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
423 512
 		global $globalStatsFilters;
424
-		if ($filter_name == '') $filter_name = $this->filter_name;
513
+		if ($filter_name == '') {
514
+			$filter_name = $this->filter_name;
515
+		}
425 516
 		if ($year == '' && $month == '') {
426
-			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";
427
-			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";
517
+			if ($limit) {
518
+				$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";
519
+			} else {
520
+				$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";
521
+			}
428 522
 			try {
429 523
 				$sth = $this->db->prepare($query);
430 524
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -432,7 +526,9 @@  discard block
 block discarded – undo
432 526
 				echo "error : ".$e->getMessage();
433 527
 			}
434 528
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
435
-		} else $all = array();
529
+		} else {
530
+			$all = array();
531
+		}
436 532
                 if (empty($all)) {
437 533
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
438 534
 			if ($filter_name != '') {
@@ -446,10 +542,15 @@  discard block
 block discarded – undo
446 542
 	}
447 543
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
448 544
 		global $globalStatsFilters;
449
-		if ($filter_name == '') $filter_name = $this->filter_name;
545
+		if ($filter_name == '') {
546
+			$filter_name = $this->filter_name;
547
+		}
450 548
 		if ($year == '' && $month == '') {
451
-			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";
452
-			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";
549
+			if ($limit) {
550
+				$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";
551
+			} else {
552
+				$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";
553
+			}
453 554
 			try {
454 555
 				$sth = $this->db->prepare($query);
455 556
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -457,7 +558,9 @@  discard block
 block discarded – undo
457 558
 				echo "error : ".$e->getMessage();
458 559
 			}
459 560
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
460
-		} else $all = array();
561
+		} else {
562
+			$all = array();
563
+		}
461 564
                 if (empty($all)) {
462 565
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
463 566
             		if ($filter_name != '') {
@@ -478,7 +581,9 @@  discard block
 block discarded – undo
478 581
         			$icao = $value['airport_departure_icao'];
479 582
         			if (isset($all[$icao])) {
480 583
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
481
-        			} else $all[$icao] = $value;
584
+        			} else {
585
+        				$all[$icao] = $value;
586
+        			}
482 587
         		}
483 588
         		$count = array();
484 589
         		foreach ($all as $key => $row) {
@@ -490,10 +595,15 @@  discard block
 block discarded – undo
490 595
 	}
491 596
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
492 597
 		global $globalStatsFilters;
493
-		if ($filter_name == '') $filter_name = $this->filter_name;
598
+		if ($filter_name == '') {
599
+			$filter_name = $this->filter_name;
600
+		}
494 601
 		if ($year == '' && $month == '') {
495
-			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";
496
-			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";
602
+			if ($limit) {
603
+				$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";
604
+			} else {
605
+				$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";
606
+			}
497 607
 			try {
498 608
 				$sth = $this->db->prepare($query);
499 609
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -501,7 +611,9 @@  discard block
 block discarded – undo
501 611
 				echo "error : ".$e->getMessage();
502 612
 			}
503 613
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
504
-		} else $all = array();
614
+		} else {
615
+			$all = array();
616
+		}
505 617
 		if (empty($all)) {
506 618
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
507 619
 			if ($filter_name != '') {
@@ -522,7 +634,9 @@  discard block
 block discarded – undo
522 634
         			$icao = $value['airport_arrival_icao'];
523 635
         			if (isset($all[$icao])) {
524 636
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
525
-        			} else $all[$icao] = $value;
637
+        			} else {
638
+        				$all[$icao] = $value;
639
+        			}
526 640
         		}
527 641
         		$count = array();
528 642
         		foreach ($all as $key => $row) {
@@ -535,13 +649,21 @@  discard block
 block discarded – undo
535 649
 	}
536 650
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
537 651
 		global $globalDBdriver, $globalStatsFilters;
538
-		if ($filter_name == '') $filter_name = $this->filter_name;
652
+		if ($filter_name == '') {
653
+			$filter_name = $this->filter_name;
654
+		}
539 655
 		if ($globalDBdriver == 'mysql') {
540
-			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";
541
-			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";
656
+			if ($limit) {
657
+				$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";
658
+			} else {
659
+				$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";
660
+			}
542 661
 		} else {
543
-			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";
544
-			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";
662
+			if ($limit) {
663
+				$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";
664
+			} else {
665
+				$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";
666
+			}
545 667
 		}
546 668
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
547 669
                  try {
@@ -565,7 +687,9 @@  discard block
 block discarded – undo
565 687
 	
566 688
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
567 689
 		global $globalStatsFilters;
568
-		if ($filter_name == '') $filter_name = $this->filter_name;
690
+		if ($filter_name == '') {
691
+			$filter_name = $this->filter_name;
692
+		}
569 693
 		$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";
570 694
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
571 695
                  try {
@@ -587,7 +711,9 @@  discard block
 block discarded – undo
587 711
 	}
588 712
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
589 713
 		global $globalDBdriver, $globalStatsFilters;
590
-		if ($filter_name == '') $filter_name = $this->filter_name;
714
+		if ($filter_name == '') {
715
+			$filter_name = $this->filter_name;
716
+		}
591 717
 		if ($globalDBdriver == 'mysql') {
592 718
 			$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";
593 719
 		} else {
@@ -613,7 +739,9 @@  discard block
 block discarded – undo
613 739
 	}
614 740
 	public function countAllDates($stats_airline = '',$filter_name = '') {
615 741
 		global $globalStatsFilters;
616
-		if ($filter_name == '') $filter_name = $this->filter_name;
742
+		if ($filter_name == '') {
743
+			$filter_name = $this->filter_name;
744
+		}
617 745
 		$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";
618 746
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
619 747
                  try {
@@ -635,7 +763,9 @@  discard block
 block discarded – undo
635 763
 	}
636 764
 	public function countAllDatesByAirlines($filter_name = '') {
637 765
 		global $globalStatsFilters;
638
-		if ($filter_name == '') $filter_name = $this->filter_name;
766
+		if ($filter_name == '') {
767
+			$filter_name = $this->filter_name;
768
+		}
639 769
 		$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";
640 770
 		$query_data = array('filter_name' => $filter_name);
641 771
                  try {
@@ -657,7 +787,9 @@  discard block
 block discarded – undo
657 787
 	}
658 788
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
659 789
 		global $globalStatsFilters, $globalDBdriver;
660
-		if ($filter_name == '') $filter_name = $this->filter_name;
790
+		if ($filter_name == '') {
791
+			$filter_name = $this->filter_name;
792
+		}
661 793
 		if ($globalDBdriver == 'mysql') {
662 794
 			$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";
663 795
 		} else {
@@ -726,7 +858,9 @@  discard block
 block discarded – undo
726 858
 	}
727 859
 	public function countAllMilitaryMonths($filter_name = '') {
728 860
 		global $globalStatsFilters;
729
-		if ($filter_name == '') $filter_name = $this->filter_name;
861
+		if ($filter_name == '') {
862
+			$filter_name = $this->filter_name;
863
+		}
730 864
 	    	$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";
731 865
                  try {
732 866
                         $sth = $this->db->prepare($query);
@@ -747,9 +881,14 @@  discard block
 block discarded – undo
747 881
 	}
748 882
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
749 883
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
750
-		if ($filter_name == '') $filter_name = $this->filter_name;
751
-		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";
752
-		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";
884
+		if ($filter_name == '') {
885
+			$filter_name = $this->filter_name;
886
+		}
887
+		if ($limit) {
888
+			$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";
889
+		} else {
890
+			$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";
891
+		}
753 892
 		if ($orderby == 'hour') {
754 893
 			/*
755 894
 			if ($globalDBdriver == 'mysql') {
@@ -758,7 +897,9 @@  discard block
 block discarded – undo
758 897
 			*/
759 898
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
760 899
 		}
761
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
900
+		if ($orderby == 'count') {
901
+			$query .= " ORDER BY hour_count DESC";
902
+		}
762 903
                  try {
763 904
                         $sth = $this->db->prepare($query);
764 905
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -779,8 +920,12 @@  discard block
 block discarded – undo
779 920
 	
780 921
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
781 922
 		global $globalStatsFilters;
782
-		if ($filter_name == '') $filter_name = $this->filter_name;
783
-		if ($year == '') $year = date('Y');
923
+		if ($filter_name == '') {
924
+			$filter_name = $this->filter_name;
925
+		}
926
+		if ($year == '') {
927
+			$year = date('Y');
928
+		}
784 929
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
785 930
 		if (empty($all)) {
786 931
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
@@ -795,8 +940,12 @@  discard block
 block discarded – undo
795 940
 	}
796 941
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
797 942
 		global $globalStatsFilters;
798
-		if ($filter_name == '') $filter_name = $this->filter_name;
799
-		if ($year == '') $year = date('Y');
943
+		if ($filter_name == '') {
944
+			$filter_name = $this->filter_name;
945
+		}
946
+		if ($year == '') {
947
+			$year = date('Y');
948
+		}
800 949
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
801 950
 		if (empty($all)) {
802 951
 		        $filters = array();
@@ -812,8 +961,12 @@  discard block
 block discarded – undo
812 961
 	}
813 962
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
814 963
 		global $globalStatsFilters;
815
-		if ($filter_name == '') $filter_name = $this->filter_name;
816
-		if ($year == '') $year = date('Y');
964
+		if ($filter_name == '') {
965
+			$filter_name = $this->filter_name;
966
+		}
967
+		if ($year == '') {
968
+			$year = date('Y');
969
+		}
817 970
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
818 971
 		if (empty($all)) {
819 972
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
@@ -828,7 +981,9 @@  discard block
 block discarded – undo
828 981
 	}
829 982
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
830 983
 		global $globalStatsFilters;
831
-		if ($filter_name == '') $filter_name = $this->filter_name;
984
+		if ($filter_name == '') {
985
+			$filter_name = $this->filter_name;
986
+		}
832 987
 		if ($year == '' && $month == '') {
833 988
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
834 989
 			try {
@@ -839,7 +994,9 @@  discard block
 block discarded – undo
839 994
 			}
840 995
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
841 996
 			$all = $result[0]['nb'];
842
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
997
+		} else {
998
+			$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
999
+		}
843 1000
 		if (empty($all)) {
844 1001
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
845 1002
 			if ($filter_name != '') {
@@ -853,7 +1010,9 @@  discard block
 block discarded – undo
853 1010
 	}
854 1011
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
855 1012
 		global $globalStatsFilters;
856
-		if ($filter_name == '') $filter_name = $this->filter_name;
1013
+		if ($filter_name == '') {
1014
+			$filter_name = $this->filter_name;
1015
+		}
857 1016
 		if ($year == '' && $month == '') {
858 1017
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
859 1018
 			try {
@@ -864,7 +1023,9 @@  discard block
 block discarded – undo
864 1023
 			}
865 1024
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
866 1025
 			$all = $result[0]['nb_airline'];
867
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1026
+		} else {
1027
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1028
+		}
868 1029
 		if (empty($all)) {
869 1030
             		$filters = array();
870 1031
 			$filters = array('year' => $year,'month' => $month);
@@ -879,7 +1040,9 @@  discard block
 block discarded – undo
879 1040
 	}
880 1041
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
881 1042
 		global $globalStatsFilters;
882
-		if ($filter_name == '') $filter_name = $this->filter_name;
1043
+		if ($filter_name == '') {
1044
+			$filter_name = $this->filter_name;
1045
+		}
883 1046
 		if ($year == '' && $month == '') {
884 1047
 			$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
885 1048
 			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
@@ -907,7 +1070,9 @@  discard block
 block discarded – undo
907 1070
 	}
908 1071
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
909 1072
 		global $globalStatsFilters;
910
-		if ($filter_name == '') $filter_name = $this->filter_name;
1073
+		if ($filter_name == '') {
1074
+			$filter_name = $this->filter_name;
1075
+		}
911 1076
 		//if ($year == '') $year = date('Y');
912 1077
 		if ($year == '' && $month == '') {
913 1078
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -936,7 +1101,9 @@  discard block
 block discarded – undo
936 1101
 	}
937 1102
 
938 1103
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
939
-		if ($filter_name == '') $filter_name = $this->filter_name;
1104
+		if ($filter_name == '') {
1105
+			$filter_name = $this->filter_name;
1106
+		}
940 1107
 		$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";
941 1108
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
942 1109
                  try {
@@ -949,7 +1116,9 @@  discard block
 block discarded – undo
949 1116
                 return $all;
950 1117
 	}
951 1118
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
952
-		if ($filter_name == '') $filter_name = $this->filter_name;
1119
+		if ($filter_name == '') {
1120
+			$filter_name = $this->filter_name;
1121
+		}
953 1122
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
954 1123
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
955 1124
                  try {
@@ -962,7 +1131,9 @@  discard block
 block discarded – undo
962 1131
                 return $all;
963 1132
         }
964 1133
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
965
-		if ($filter_name == '') $filter_name = $this->filter_name;
1134
+		if ($filter_name == '') {
1135
+			$filter_name = $this->filter_name;
1136
+		}
966 1137
                 $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
967 1138
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
968 1139
                  try {
@@ -975,7 +1146,9 @@  discard block
 block discarded – undo
975 1146
                 return $all;
976 1147
         }
977 1148
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
978
-		if ($filter_name == '') $filter_name = $this->filter_name;
1149
+		if ($filter_name == '') {
1150
+			$filter_name = $this->filter_name;
1151
+		}
979 1152
     		global $globalArchiveMonths, $globalDBdriver;
980 1153
     		if ($globalDBdriver == 'mysql') {
981 1154
     			if ($month == '') {
@@ -1005,7 +1178,9 @@  discard block
 block discarded – undo
1005 1178
         }
1006 1179
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1007 1180
     		global $globalArchiveMonths, $globalDBdriver;
1008
-		if ($filter_name == '') $filter_name = $this->filter_name;
1181
+		if ($filter_name == '') {
1182
+			$filter_name = $this->filter_name;
1183
+		}
1009 1184
     		if ($globalDBdriver == 'mysql') {
1010 1185
 			$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";
1011 1186
 		} else {
@@ -1023,7 +1198,9 @@  discard block
 block discarded – undo
1023 1198
         }
1024 1199
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1025 1200
     		global $globalArchiveMonths, $globalDBdriver;
1026
-		if ($filter_name == '') $filter_name = $this->filter_name;
1201
+		if ($filter_name == '') {
1202
+			$filter_name = $this->filter_name;
1203
+		}
1027 1204
     		if ($globalDBdriver == 'mysql') {
1028 1205
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1029 1206
                 } else {
@@ -1040,7 +1217,9 @@  discard block
 block discarded – undo
1040 1217
         }
1041 1218
 	public function getStatsAirlineTotal($filter_name = '') {
1042 1219
     		global $globalArchiveMonths, $globalDBdriver;
1043
-		if ($filter_name == '') $filter_name = $this->filter_name;
1220
+		if ($filter_name == '') {
1221
+			$filter_name = $this->filter_name;
1222
+		}
1044 1223
     		if ($globalDBdriver == 'mysql') {
1045 1224
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1046 1225
                 } else {
@@ -1057,7 +1236,9 @@  discard block
 block discarded – undo
1057 1236
         }
1058 1237
 	public function getStatsOwnerTotal($filter_name = '') {
1059 1238
     		global $globalArchiveMonths, $globalDBdriver;
1060
-		if ($filter_name == '') $filter_name = $this->filter_name;
1239
+		if ($filter_name == '') {
1240
+			$filter_name = $this->filter_name;
1241
+		}
1061 1242
     		if ($globalDBdriver == 'mysql') {
1062 1243
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1063 1244
 		} else {
@@ -1074,7 +1255,9 @@  discard block
 block discarded – undo
1074 1255
         }
1075 1256
 	public function getStatsOwner($owner_name,$filter_name = '') {
1076 1257
     		global $globalArchiveMonths, $globalDBdriver;
1077
-		if ($filter_name == '') $filter_name = $this->filter_name;
1258
+		if ($filter_name == '') {
1259
+			$filter_name = $this->filter_name;
1260
+		}
1078 1261
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1079 1262
                  try {
1080 1263
                         $sth = $this->db->prepare($query);
@@ -1083,12 +1266,17 @@  discard block
 block discarded – undo
1083 1266
                         echo "error : ".$e->getMessage();
1084 1267
                 }
1085 1268
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1086
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1087
-                else return 0;
1269
+                if (isset($all[0]['cnt'])) {
1270
+                	return $all[0]['cnt'];
1271
+                } else {
1272
+                	return 0;
1273
+                }
1088 1274
         }
1089 1275
 	public function getStatsPilotTotal($filter_name = '') {
1090 1276
     		global $globalArchiveMonths, $globalDBdriver;
1091
-		if ($filter_name == '') $filter_name = $this->filter_name;
1277
+		if ($filter_name == '') {
1278
+			$filter_name = $this->filter_name;
1279
+		}
1092 1280
     		if ($globalDBdriver == 'mysql') {
1093 1281
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1094 1282
             	} else {
@@ -1105,7 +1293,9 @@  discard block
 block discarded – undo
1105 1293
         }
1106 1294
 	public function getStatsPilot($pilot,$filter_name = '') {
1107 1295
     		global $globalArchiveMonths, $globalDBdriver;
1108
-		if ($filter_name == '') $filter_name = $this->filter_name;
1296
+		if ($filter_name == '') {
1297
+			$filter_name = $this->filter_name;
1298
+		}
1109 1299
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1110 1300
                  try {
1111 1301
                         $sth = $this->db->prepare($query);
@@ -1114,13 +1304,18 @@  discard block
 block discarded – undo
1114 1304
                         echo "error : ".$e->getMessage();
1115 1305
                 }
1116 1306
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1117
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1118
-                else return 0;
1307
+                if (isset($all[0]['cnt'])) {
1308
+                	return $all[0]['cnt'];
1309
+                } else {
1310
+                	return 0;
1311
+                }
1119 1312
         }
1120 1313
 
1121 1314
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1122 1315
 		global $globalDBdriver;
1123
-		if ($filter_name == '') $filter_name = $this->filter_name;
1316
+		if ($filter_name == '') {
1317
+			$filter_name = $this->filter_name;
1318
+		}
1124 1319
 		if ($globalDBdriver == 'mysql') {
1125 1320
 			$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";
1126 1321
                 } else {
@@ -1136,7 +1331,9 @@  discard block
 block discarded – undo
1136 1331
         }
1137 1332
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1138 1333
 		global $globalDBdriver;
1139
-		if ($filter_name == '') $filter_name = $this->filter_name;
1334
+		if ($filter_name == '') {
1335
+			$filter_name = $this->filter_name;
1336
+		}
1140 1337
 		if ($globalDBdriver == 'mysql') {
1141 1338
 			$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";
1142 1339
 		} else {
@@ -1522,10 +1719,14 @@  discard block
 block discarded – undo
1522 1719
     		$Connection = new Connection();
1523 1720
     		date_default_timezone_set('UTC');
1524 1721
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1525
-			if ($globalDebug) echo 'Update stats !'."\n";
1722
+			if ($globalDebug) {
1723
+				echo 'Update stats !'."\n";
1724
+			}
1526 1725
 			if (isset($last_update[0]['value'])) {
1527 1726
 				$last_update_day = $last_update[0]['value'];
1528
-			} else $last_update_day = '2012-12-12 12:12:12';
1727
+			} else {
1728
+				$last_update_day = '2012-12-12 12:12:12';
1729
+			}
1529 1730
 			$reset = false;
1530 1731
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
1531 1732
 			if ($globalStatsResetYear) {
@@ -1534,42 +1735,60 @@  discard block
 block discarded – undo
1534 1735
 			}
1535 1736
 			$Spotter = new Spotter($this->db);
1536 1737
 
1537
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1738
+			if ($globalDebug) {
1739
+				echo 'Count all aircraft types...'."\n";
1740
+			}
1538 1741
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1539 1742
 			foreach ($alldata as $number) {
1540 1743
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1541 1744
 			}
1542
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1745
+			if ($globalDebug) {
1746
+				echo 'Count all airlines...'."\n";
1747
+			}
1543 1748
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1544 1749
 			foreach ($alldata as $number) {
1545 1750
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1546 1751
 			}
1547
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1752
+			if ($globalDebug) {
1753
+				echo 'Count all registrations...'."\n";
1754
+			}
1548 1755
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1549 1756
 			foreach ($alldata as $number) {
1550 1757
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1551 1758
 			}
1552
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1759
+			if ($globalDebug) {
1760
+				echo 'Count all callsigns...'."\n";
1761
+			}
1553 1762
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1554 1763
 			foreach ($alldata as $number) {
1555 1764
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1556 1765
 			}
1557
-			if ($globalDebug) echo 'Count all owners...'."\n";
1766
+			if ($globalDebug) {
1767
+				echo 'Count all owners...'."\n";
1768
+			}
1558 1769
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1559 1770
 			foreach ($alldata as $number) {
1560 1771
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1561 1772
 			}
1562
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1773
+			if ($globalDebug) {
1774
+				echo 'Count all pilots...'."\n";
1775
+			}
1563 1776
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1564 1777
 			foreach ($alldata as $number) {
1565 1778
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1566 1779
 			}
1567 1780
 			
1568
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1781
+			if ($globalDebug) {
1782
+				echo 'Count all departure airports...'."\n";
1783
+			}
1569 1784
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1570
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1785
+			if ($globalDebug) {
1786
+				echo 'Count all detected departure airports...'."\n";
1787
+			}
1571 1788
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1572
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1789
+			if ($globalDebug) {
1790
+				echo 'Order departure airports...'."\n";
1791
+			}
1573 1792
 	        	$alldata = array();
1574 1793
 	        	
1575 1794
     			foreach ($pall as $value) {
@@ -1580,7 +1799,9 @@  discard block
 block discarded – undo
1580 1799
     				$icao = $value['airport_departure_icao'];
1581 1800
         			if (isset($alldata[$icao])) {
1582 1801
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1583
-        			} else $alldata[$icao] = $value;
1802
+        			} else {
1803
+        				$alldata[$icao] = $value;
1804
+        			}
1584 1805
 			}
1585 1806
     			$count = array();
1586 1807
     			foreach ($alldata as $key => $row) {
@@ -1590,11 +1811,17 @@  discard block
 block discarded – undo
1590 1811
 			foreach ($alldata as $number) {
1591 1812
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1592 1813
 			}
1593
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1814
+			if ($globalDebug) {
1815
+				echo 'Count all arrival airports...'."\n";
1816
+			}
1594 1817
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1595
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1818
+			if ($globalDebug) {
1819
+				echo 'Count all detected arrival airports...'."\n";
1820
+			}
1596 1821
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1597
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1822
+			if ($globalDebug) {
1823
+				echo 'Order arrival airports...'."\n";
1824
+			}
1598 1825
 	        	$alldata = array();
1599 1826
     			foreach ($pall as $value) {
1600 1827
 	        		$icao = $value['airport_arrival_icao'];
@@ -1604,7 +1831,9 @@  discard block
 block discarded – undo
1604 1831
     				$icao = $value['airport_arrival_icao'];
1605 1832
         			if (isset($alldata[$icao])) {
1606 1833
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1607
-	        		} else $alldata[$icao] = $value;
1834
+	        		} else {
1835
+	        			$alldata[$icao] = $value;
1836
+	        		}
1608 1837
     			}
1609 1838
         		$count = array();
1610 1839
         		foreach ($alldata as $key => $row) {
@@ -1615,7 +1844,9 @@  discard block
 block discarded – undo
1615 1844
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1616 1845
 			}
1617 1846
 			if ($Connection->tableExists('countries')) {
1618
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1847
+				if ($globalDebug) {
1848
+					echo 'Count all flights by countries...'."\n";
1849
+				}
1619 1850
 				$SpotterArchive = new SpotterArchive();
1620 1851
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1621 1852
 				foreach ($alldata as $number) {
@@ -1623,7 +1854,9 @@  discard block
 block discarded – undo
1623 1854
 				}
1624 1855
 			}
1625 1856
 			
1626
-			if ($globalDebug) echo 'Count fatalities stats...'."\n";
1857
+			if ($globalDebug) {
1858
+				echo 'Count fatalities stats...'."\n";
1859
+			}
1627 1860
 			$Accident = new Accident();
1628 1861
 			$this->deleteStatsByType('fatalities_byyear');
1629 1862
 			$alldata = $Accident->countFatalitiesByYear();
@@ -1640,46 +1873,66 @@  discard block
 block discarded – undo
1640 1873
 			// Add by month using getstat if month finish...
1641 1874
 
1642 1875
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1643
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1876
+			if ($globalDebug) {
1877
+				echo 'Count all flights by months...'."\n";
1878
+			}
1644 1879
 			$Spotter = new Spotter($this->db);
1645 1880
 			$alldata = $Spotter->countAllMonths();
1646 1881
 			$lastyear = false;
1647 1882
 			foreach ($alldata as $number) {
1648
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1883
+				if ($number['year_name'] != date('Y')) {
1884
+					$lastyear = true;
1885
+				}
1649 1886
 				$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'])));
1650 1887
 			}
1651
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1888
+			if ($globalDebug) {
1889
+				echo 'Count all military flights by months...'."\n";
1890
+			}
1652 1891
 			$alldata = $Spotter->countAllMilitaryMonths();
1653 1892
 			foreach ($alldata as $number) {
1654 1893
 				$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'])));
1655 1894
 			}
1656
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1895
+			if ($globalDebug) {
1896
+				echo 'Count all owners by months...'."\n";
1897
+			}
1657 1898
 			$alldata = $Spotter->countAllMonthsOwners();
1658 1899
 			foreach ($alldata as $number) {
1659 1900
 				$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'])));
1660 1901
 			}
1661
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1902
+			if ($globalDebug) {
1903
+				echo 'Count all pilots by months...'."\n";
1904
+			}
1662 1905
 			$alldata = $Spotter->countAllMonthsPilots();
1663 1906
 			foreach ($alldata as $number) {
1664 1907
 				$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'])));
1665 1908
 			}
1666
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1909
+			if ($globalDebug) {
1910
+				echo 'Count all airlines by months...'."\n";
1911
+			}
1667 1912
 			$alldata = $Spotter->countAllMonthsAirlines();
1668 1913
 			foreach ($alldata as $number) {
1669 1914
 				$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'])));
1670 1915
 			}
1671
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1916
+			if ($globalDebug) {
1917
+				echo 'Count all aircrafts by months...'."\n";
1918
+			}
1672 1919
 			$alldata = $Spotter->countAllMonthsAircrafts();
1673 1920
 			foreach ($alldata as $number) {
1674 1921
 				$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'])));
1675 1922
 			}
1676
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1923
+			if ($globalDebug) {
1924
+				echo 'Count all real arrivals by months...'."\n";
1925
+			}
1677 1926
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1678 1927
 			foreach ($alldata as $number) {
1679 1928
 				$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'])));
1680 1929
 			}
1681
-			if ($globalDebug) echo 'Airports data...'."\n";
1682
-			if ($globalDebug) echo '...Departure'."\n";
1930
+			if ($globalDebug) {
1931
+				echo 'Airports data...'."\n";
1932
+			}
1933
+			if ($globalDebug) {
1934
+				echo '...Departure'."\n";
1935
+			}
1683 1936
 			$this->deleteStatAirport('daily');
1684 1937
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1685 1938
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1800,44 +2053,62 @@  discard block
 block discarded – undo
1800 2053
 			// Count by airlines
1801 2054
 			echo '--- Stats by airlines ---'."\n";
1802 2055
 			if ($Connection->tableExists('countries')) {
1803
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2056
+				if ($globalDebug) {
2057
+					echo 'Count all flights by countries by airlines...'."\n";
2058
+				}
1804 2059
 				$SpotterArchive = new SpotterArchive();
1805 2060
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1806 2061
 				foreach ($alldata as $number) {
1807 2062
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1808 2063
 				}
1809 2064
 			}
1810
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2065
+			if ($globalDebug) {
2066
+				echo 'Count all aircraft types by airlines...'."\n";
2067
+			}
1811 2068
 			$Spotter = new Spotter($this->db);
1812 2069
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1813 2070
 			foreach ($alldata as $number) {
1814 2071
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1815 2072
 			}
1816
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2073
+			if ($globalDebug) {
2074
+				echo 'Count all aircraft registrations by airlines...'."\n";
2075
+			}
1817 2076
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1818 2077
 			foreach ($alldata as $number) {
1819 2078
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1820 2079
 			}
1821
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2080
+			if ($globalDebug) {
2081
+				echo 'Count all callsigns by airlines...'."\n";
2082
+			}
1822 2083
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1823 2084
 			foreach ($alldata as $number) {
1824 2085
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1825 2086
 			}
1826
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2087
+			if ($globalDebug) {
2088
+				echo 'Count all owners by airlines...'."\n";
2089
+			}
1827 2090
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1828 2091
 			foreach ($alldata as $number) {
1829 2092
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1830 2093
 			}
1831
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2094
+			if ($globalDebug) {
2095
+				echo 'Count all pilots by airlines...'."\n";
2096
+			}
1832 2097
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1833 2098
 			foreach ($alldata as $number) {
1834 2099
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1835 2100
 			}
1836
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2101
+			if ($globalDebug) {
2102
+				echo 'Count all departure airports by airlines...'."\n";
2103
+			}
1837 2104
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1838
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2105
+			if ($globalDebug) {
2106
+				echo 'Count all detected departure airports by airlines...'."\n";
2107
+			}
1839 2108
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1840
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2109
+			if ($globalDebug) {
2110
+				echo 'Order detected departure airports by airlines...'."\n";
2111
+			}
1841 2112
 	        	//$alldata = array();
1842 2113
     			foreach ($dall as $value) {
1843 2114
     				$icao = $value['airport_departure_icao'];
@@ -1858,11 +2129,17 @@  discard block
 block discarded – undo
1858 2129
 			foreach ($alldata as $number) {
1859 2130
 				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'],'',$reset);
1860 2131
 			}
1861
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2132
+			if ($globalDebug) {
2133
+				echo 'Count all arrival airports by airlines...'."\n";
2134
+			}
1862 2135
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1863
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2136
+			if ($globalDebug) {
2137
+				echo 'Count all detected arrival airports by airlines...'."\n";
2138
+			}
1864 2139
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1865
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2140
+			if ($globalDebug) {
2141
+				echo 'Order arrival airports by airlines...'."\n";
2142
+			}
1866 2143
 	        	//$alldata = array();
1867 2144
     			foreach ($dall as $value) {
1868 2145
     				$icao = $value['airport_arrival_icao'];
@@ -1881,37 +2158,53 @@  discard block
 block discarded – undo
1881 2158
     			}
1882 2159
     			$alldata = $pall;
1883 2160
                         foreach ($alldata as $number) {
1884
-				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'],'',$reset);
2161
+				if ($number['airline_icao'] != '') {
2162
+					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'],'',$reset);
2163
+				}
2164
+			}
2165
+			if ($globalDebug) {
2166
+				echo 'Count all flights by months by airlines...'."\n";
1885 2167
 			}
1886
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1887 2168
 			$Spotter = new Spotter($this->db);
1888 2169
 			$alldata = $Spotter->countAllMonthsByAirlines();
1889 2170
 			$lastyear = false;
1890 2171
 			foreach ($alldata as $number) {
1891
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2172
+				if ($number['year_name'] != date('Y')) {
2173
+					$lastyear = true;
2174
+				}
1892 2175
 				$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']);
1893 2176
 			}
1894
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2177
+			if ($globalDebug) {
2178
+				echo 'Count all owners by months by airlines...'."\n";
2179
+			}
1895 2180
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1896 2181
 			foreach ($alldata as $number) {
1897 2182
 				$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']);
1898 2183
 			}
1899
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2184
+			if ($globalDebug) {
2185
+				echo 'Count all pilots by months by airlines...'."\n";
2186
+			}
1900 2187
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1901 2188
 			foreach ($alldata as $number) {
1902 2189
 				$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']);
1903 2190
 			}
1904
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2191
+			if ($globalDebug) {
2192
+				echo 'Count all aircrafts by months by airlines...'."\n";
2193
+			}
1905 2194
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1906 2195
 			foreach ($alldata as $number) {
1907 2196
 				$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']);
1908 2197
 			}
1909
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2198
+			if ($globalDebug) {
2199
+				echo 'Count all real arrivals by months by airlines...'."\n";
2200
+			}
1910 2201
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1911 2202
 			foreach ($alldata as $number) {
1912 2203
 				$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']);
1913 2204
 			}
1914
-			if ($globalDebug) echo '...Departure'."\n";
2205
+			if ($globalDebug) {
2206
+				echo '...Departure'."\n";
2207
+			}
1915 2208
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1916 2209
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1917 2210
     			foreach ($dall as $value) {
@@ -1934,7 +2227,9 @@  discard block
 block discarded – undo
1934 2227
 			foreach ($alldata as $number) {
1935 2228
 				$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']);
1936 2229
 			}
1937
-			if ($globalDebug) echo '...Arrival'."\n";
2230
+			if ($globalDebug) {
2231
+				echo '...Arrival'."\n";
2232
+			}
1938 2233
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1939 2234
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1940 2235
     			foreach ($dall as $value) {
@@ -1958,13 +2253,19 @@  discard block
 block discarded – undo
1958 2253
 				$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']);
1959 2254
 			}
1960 2255
 
1961
-			if ($globalDebug) echo 'Flights data...'."\n";
1962
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2256
+			if ($globalDebug) {
2257
+				echo 'Flights data...'."\n";
2258
+			}
2259
+			if ($globalDebug) {
2260
+				echo '-> countAllDatesLastMonth...'."\n";
2261
+			}
1963 2262
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1964 2263
 			foreach ($alldata as $number) {
1965 2264
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1966 2265
 			}
1967
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2266
+			if ($globalDebug) {
2267
+				echo '-> countAllDates...'."\n";
2268
+			}
1968 2269
 			//$previousdata = $this->countAllDatesByAirlines();
1969 2270
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1970 2271
 			$values = array();
@@ -1977,7 +2278,9 @@  discard block
 block discarded – undo
1977 2278
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1978 2279
 			}
1979 2280
 			
1980
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2281
+			if ($globalDebug) {
2282
+				echo '-> countAllHours...'."\n";
2283
+			}
1981 2284
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1982 2285
 			foreach ($alldata as $number) {
1983 2286
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1985,14 +2288,18 @@  discard block
 block discarded – undo
1985 2288
 			
1986 2289
 
1987 2290
 			// Stats by filters
1988
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2291
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2292
+				$globalStatsFilters = array();
2293
+			}
1989 2294
 			foreach ($globalStatsFilters as $name => $filter) {
1990 2295
 				//$filter_name = $filter['name'];
1991 2296
 				$filter_name = $name;
1992 2297
 				$reset = false;
1993 2298
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1994 2299
 				if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
1995
-					if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
2300
+					if ($globalDebug) {
2301
+						echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
2302
+					}
1996 2303
 					$this->deleteOldStats($filter_name);
1997 2304
 					unset($last_update);
1998 2305
 				}
@@ -2011,7 +2318,9 @@  discard block
 block discarded – undo
2011 2318
 				
2012 2319
 
2013 2320
 				// Count by filter
2014
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2321
+				if ($globalDebug) {
2322
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2323
+				}
2015 2324
 				$Spotter = new Spotter($this->db);
2016 2325
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2017 2326
 				foreach ($alldata as $number) {
@@ -2048,7 +2357,9 @@  discard block
 block discarded – undo
2048 2357
 	    				$icao = $value['airport_departure_icao'];
2049 2358
         				if (isset($alldata[$icao])) {
2050 2359
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2051
-        				} else $alldata[$icao] = $value;
2360
+        				} else {
2361
+        					$alldata[$icao] = $value;
2362
+        				}
2052 2363
 				}
2053 2364
 	    			$count = array();
2054 2365
     				foreach ($alldata as $key => $row) {
@@ -2069,7 +2380,9 @@  discard block
 block discarded – undo
2069 2380
 	    				$icao = $value['airport_arrival_icao'];
2070 2381
         				if (isset($alldata[$icao])) {
2071 2382
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2072
-		        		} else $alldata[$icao] = $value;
2383
+		        		} else {
2384
+		        			$alldata[$icao] = $value;
2385
+		        		}
2073 2386
 	    			}
2074 2387
         			$count = array();
2075 2388
         			foreach ($alldata as $key => $row) {
@@ -2083,7 +2396,9 @@  discard block
 block discarded – undo
2083 2396
 				$alldata = $Spotter->countAllMonths($filter);
2084 2397
 				$lastyear = false;
2085 2398
 				foreach ($alldata as $number) {
2086
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2399
+					if ($number['year_name'] != date('Y')) {
2400
+						$lastyear = true;
2401
+					}
2087 2402
 					$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);
2088 2403
 				}
2089 2404
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.
Indentation   +822 added lines, -822 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
17 17
 		$Connection = new Connection($dbc);
18 18
 		$this->db = $Connection->db();
19
-        }
19
+		}
20 20
               
21 21
 	public function addLastStatsUpdate($type,$stats_date) {
22
-                $query = "DELETE FROM config WHERE name = :type;
22
+				$query = "DELETE FROM config WHERE name = :type;
23 23
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
24
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
25
-                 try {
26
-                        $sth = $this->db->prepare($query);
27
-                        $sth->execute($query_values);
28
-                } catch(PDOException $e) {
29
-                        return "error : ".$e->getMessage();
30
-                }
31
-        }
24
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
25
+				 try {
26
+						$sth = $this->db->prepare($query);
27
+						$sth->execute($query_values);
28
+				} catch(PDOException $e) {
29
+						return "error : ".$e->getMessage();
30
+				}
31
+		}
32 32
 
33 33
 	public function getLastStatsUpdate($type = 'last_update_stats') {
34
-                $query = "SELECT value FROM config WHERE name = :type";
35
-                 try {
36
-                        $sth = $this->db->prepare($query);
37
-                        $sth->execute(array(':type' => $type));
38
-                } catch(PDOException $e) {
39
-                        echo "error : ".$e->getMessage();
40
-                }
41
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
42
-                return $all;
43
-        }
44
-        public function deleteStats($filter_name = '') {
45
-        	/*
34
+				$query = "SELECT value FROM config WHERE name = :type";
35
+				 try {
36
+						$sth = $this->db->prepare($query);
37
+						$sth->execute(array(':type' => $type));
38
+				} catch(PDOException $e) {
39
+						echo "error : ".$e->getMessage();
40
+				}
41
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
42
+				return $all;
43
+		}
44
+		public function deleteStats($filter_name = '') {
45
+			/*
46 46
         	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
47 47
                  try {
48 48
                         $sth = $this->db->prepare($query);
@@ -51,109 +51,109 @@  discard block
 block discarded – undo
51 51
                         return "error : ".$e->getMessage();
52 52
                 }
53 53
                 */
54
-        	$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
55
-                 try {
56
-                        $sth = $this->db->prepare($query);
57
-                        $sth->execute(array(':filter_name' => $filter_name));
58
-                } catch(PDOException $e) {
59
-                        return "error : ".$e->getMessage();
60
-                }
61
-        }
62
-        public function deleteOldStats($filter_name = '') {
63
-        	if ($filter_name == '') {
64
-        		$query = "DELETE FROM config WHERE name = 'last_update_stats'";
65
-        	} else {
66
-        		$query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'";
67
-        	}
68
-                 try {
69
-                        $sth = $this->db->prepare($query);
70
-                        $sth->execute();
71
-                } catch(PDOException $e) {
72
-                        return "error : ".$e->getMessage();
73
-                }
54
+			$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
55
+				 try {
56
+						$sth = $this->db->prepare($query);
57
+						$sth->execute(array(':filter_name' => $filter_name));
58
+				} catch(PDOException $e) {
59
+						return "error : ".$e->getMessage();
60
+				}
61
+		}
62
+		public function deleteOldStats($filter_name = '') {
63
+			if ($filter_name == '') {
64
+				$query = "DELETE FROM config WHERE name = 'last_update_stats'";
65
+			} else {
66
+				$query = "DELETE FROM config WHERE name = 'last_update_stats_".$filter_name."'";
67
+			}
68
+				 try {
69
+						$sth = $this->db->prepare($query);
70
+						$sth->execute();
71
+				} catch(PDOException $e) {
72
+						return "error : ".$e->getMessage();
73
+				}
74 74
                 
75
-        	$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
76
-                 try {
77
-                        $sth = $this->db->prepare($query);
78
-                        $sth->execute(array(':filter_name' => $filter_name));
79
-                } catch(PDOException $e) {
80
-                        return "error : ".$e->getMessage();
81
-                }
82
-        }
75
+			$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
76
+				 try {
77
+						$sth = $this->db->prepare($query);
78
+						$sth->execute(array(':filter_name' => $filter_name));
79
+				} catch(PDOException $e) {
80
+						return "error : ".$e->getMessage();
81
+				}
82
+		}
83 83
 	public function getAllAirlineNames($filter_name = '') {
84 84
 		if ($filter_name == '') $filter_name = $this->filter_name;
85
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
86
-                 try {
87
-                        $sth = $this->db->prepare($query);
88
-                        $sth->execute(array(':filter_name' => $filter_name));
89
-                } catch(PDOException $e) {
90
-                        echo "error : ".$e->getMessage();
91
-                }
92
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
93
-                return $all;
94
-        }
85
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
86
+				 try {
87
+						$sth = $this->db->prepare($query);
88
+						$sth->execute(array(':filter_name' => $filter_name));
89
+				} catch(PDOException $e) {
90
+						echo "error : ".$e->getMessage();
91
+				}
92
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
93
+				return $all;
94
+		}
95 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
96 96
 		if ($filter_name == '') $filter_name = $this->filter_name;
97
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
98
-                 try {
99
-                        $sth = $this->db->prepare($query);
100
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
101
-                } catch(PDOException $e) {
102
-                        echo "error : ".$e->getMessage();
103
-                }
104
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
105
-                return $all;
106
-        }
97
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
98
+				 try {
99
+						$sth = $this->db->prepare($query);
100
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
101
+				} catch(PDOException $e) {
102
+						echo "error : ".$e->getMessage();
103
+				}
104
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
105
+				return $all;
106
+		}
107 107
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
108 108
 		if ($filter_name == '') $filter_name = $this->filter_name;
109
-                $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";
110
-                 try {
111
-                        $sth = $this->db->prepare($query);
112
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
113
-                } catch(PDOException $e) {
114
-                        echo "error : ".$e->getMessage();
115
-                }
116
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
117
-                return $all;
118
-        }
109
+				$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";
110
+				 try {
111
+						$sth = $this->db->prepare($query);
112
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
113
+				} catch(PDOException $e) {
114
+						echo "error : ".$e->getMessage();
115
+				}
116
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
117
+				return $all;
118
+		}
119 119
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
120 120
 		if ($filter_name == '') $filter_name = $this->filter_name;
121
-                $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";
122
-                 try {
123
-                        $sth = $this->db->prepare($query);
124
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
125
-                } catch(PDOException $e) {
126
-                        echo "error : ".$e->getMessage();
127
-                }
128
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
129
-                return $all;
130
-        }
121
+				$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";
122
+				 try {
123
+						$sth = $this->db->prepare($query);
124
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
125
+				} catch(PDOException $e) {
126
+						echo "error : ".$e->getMessage();
127
+				}
128
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
129
+				return $all;
130
+		}
131 131
 
132 132
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
133 133
 		if ($filter_name == '') $filter_name = $this->filter_name;
134
-                $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
135
-                 try {
136
-                        $sth = $this->db->prepare($query);
137
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
138
-                } catch(PDOException $e) {
139
-                        echo "error : ".$e->getMessage();
140
-                }
141
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
142
-                return $all;
143
-        }
134
+				$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
135
+				 try {
136
+						$sth = $this->db->prepare($query);
137
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
138
+				} catch(PDOException $e) {
139
+						echo "error : ".$e->getMessage();
140
+				}
141
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
142
+				return $all;
143
+		}
144 144
 
145 145
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
146 146
 		if ($filter_name == '') $filter_name = $this->filter_name;
147
-                $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
148
-                 try {
149
-                        $sth = $this->db->prepare($query);
150
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
151
-                } catch(PDOException $e) {
152
-                        echo "error : ".$e->getMessage();
153
-                }
154
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
155
-                return $all;
156
-        }
147
+				$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
148
+				 try {
149
+						$sth = $this->db->prepare($query);
150
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
151
+				} catch(PDOException $e) {
152
+						echo "error : ".$e->getMessage();
153
+				}
154
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
155
+				return $all;
156
+		}
157 157
 
158 158
 
159 159
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
 			}
171 171
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
172 172
 		} else $all = array();
173
-                if (empty($all)) {
174
-            	    $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
175
-            	    if ($filter_name != '') {
176
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
177
-            	    }
178
-            	    $Spotter = new Spotter($this->db);
179
-            	    //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
180
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
181
-                }
182
-                return $all;
173
+				if (empty($all)) {
174
+					$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
175
+					if ($filter_name != '') {
176
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
177
+					}
178
+					$Spotter = new Spotter($this->db);
179
+					//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
180
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
181
+				}
182
+				return $all;
183 183
 	}
184 184
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
185 185
 		global $globalStatsFilters;
@@ -195,17 +195,17 @@  discard block
 block discarded – undo
195 195
 			}
196 196
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
197 197
 		} else $all = array();
198
-                if (empty($all)) {
199
-            		$Spotter = new Spotter($this->db);
200
-            		$filters = array();
201
-            		$filters = array('year' => $year,'month' => $month);
202
-            		if ($filter_name != '') {
203
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
204
-			}
205
-            		//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
206
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
207
-                }
208
-                return $all;
198
+				if (empty($all)) {
199
+					$Spotter = new Spotter($this->db);
200
+					$filters = array();
201
+					$filters = array('year' => $year,'month' => $month);
202
+					if ($filter_name != '') {
203
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
204
+			}
205
+					//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
206
+					$all = $Spotter->countAllAirlineCountries($limit,$filters);
207
+				}
208
+				return $all;
209 209
 	}
210 210
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
211 211
 		global $globalStatsFilters;
@@ -247,39 +247,39 @@  discard block
 block discarded – undo
247 247
 			}
248 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
249 249
 		} else $all = array();
250
-                if (empty($all)) {
250
+				if (empty($all)) {
251 251
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
252 252
 			if ($filter_name != '') {
253
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
253
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
254 254
 			}
255 255
 			$Spotter = new Spotter($this->db);
256 256
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
257 257
 			$all = $Spotter->countAllArrivalCountries($limit,$filters);
258
-                }
259
-                return $all;
258
+				}
259
+				return $all;
260 260
 	}
261 261
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
262 262
 		global $globalStatsFilters;
263 263
 		if ($filter_name == '') $filter_name = $this->filter_name;
264 264
 		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";
265 265
 		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";
266
-                 try {
267
-                        $sth = $this->db->prepare($query);
268
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
269
-                } catch(PDOException $e) {
270
-                        echo "error : ".$e->getMessage();
271
-                }
272
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
273
-                if (empty($all)) {
266
+				 try {
267
+						$sth = $this->db->prepare($query);
268
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
269
+				} catch(PDOException $e) {
270
+						echo "error : ".$e->getMessage();
271
+				}
272
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
273
+				if (empty($all)) {
274 274
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
275 275
 			if ($filter_name != '') {
276
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
276
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
277 277
 			}
278 278
 			$Spotter = new Spotter($this->db);
279 279
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
280 280
 			$all = $Spotter->countAllDepartureCountries($filters);
281
-                }
282
-                return $all;
281
+				}
282
+				return $all;
283 283
 	}
284 284
 
285 285
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
@@ -305,17 +305,17 @@  discard block
 block discarded – undo
305 305
 			}
306 306
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
307 307
 		} else $all = array();
308
-                if (empty($all)) {
309
-	                $Spotter = new Spotter($this->db);
310
-            		$filters = array();
308
+				if (empty($all)) {
309
+					$Spotter = new Spotter($this->db);
310
+					$filters = array();
311 311
 			$filters = array('year' => $year,'month' => $month);
312
-            		if ($filter_name != '') {
313
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
312
+					if ($filter_name != '') {
313
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
314 314
 			}
315 315
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
316
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
317
-                }
318
-                return $all;
316
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters);
317
+				}
318
+				return $all;
319 319
 	}
320 320
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
321 321
 		global $globalStatsFilters;
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 			}
332 332
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
333 333
 		} else $all = array();
334
-                if (empty($all)) {
334
+				if (empty($all)) {
335 335
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
336 336
 			if ($filter_name != '') {
337 337
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
338 338
 			}
339
-	                $Spotter = new Spotter($this->db);
340
-    		        //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
341
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
342
-                }
343
-                return $all;
339
+					$Spotter = new Spotter($this->db);
340
+					//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
341
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
342
+				}
343
+				return $all;
344 344
 	}
345 345
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
346 346
 		global $globalStatsFilters;
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 					echo "error : ".$e->getMessage();
382 382
 				}
383 383
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
384
-                /*
384
+				/*
385 385
                 if (empty($all)) {
386 386
 	                $Spotter = new Spotter($this->db);
387 387
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -433,16 +433,16 @@  discard block
 block discarded – undo
433 433
 			}
434 434
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
435 435
 		} else $all = array();
436
-                if (empty($all)) {
436
+				if (empty($all)) {
437 437
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
438 438
 			if ($filter_name != '') {
439 439
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
440 440
 			}
441
-            		$Spotter = new Spotter($this->db);
442
-            		//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
443
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
444
-                }
445
-                return $all;
441
+					$Spotter = new Spotter($this->db);
442
+					//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
443
+					$all = $Spotter->countAllOwners($limit,0,'',$filters);
444
+				}
445
+				return $all;
446 446
 	}
447 447
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
448 448
 		global $globalStatsFilters;
@@ -458,35 +458,35 @@  discard block
 block discarded – undo
458 458
 			}
459 459
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
460 460
 		} else $all = array();
461
-                if (empty($all)) {
461
+				if (empty($all)) {
462 462
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
463
-            		if ($filter_name != '') {
464
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
463
+					if ($filter_name != '') {
464
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
465 465
 			}
466
-            		$Spotter = new Spotter($this->db);
466
+					$Spotter = new Spotter($this->db);
467 467
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
468 468
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
469
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
470
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
471
-        		$all = array();
472
-        		foreach ($pall as $value) {
473
-        			$icao = $value['airport_departure_icao'];
474
-        			$all[$icao] = $value;
475
-        		}
469
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
470
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
471
+				$all = array();
472
+				foreach ($pall as $value) {
473
+					$icao = $value['airport_departure_icao'];
474
+					$all[$icao] = $value;
475
+				}
476 476
         		
477
-        		foreach ($dall as $value) {
478
-        			$icao = $value['airport_departure_icao'];
479
-        			if (isset($all[$icao])) {
480
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
481
-        			} else $all[$icao] = $value;
482
-        		}
483
-        		$count = array();
484
-        		foreach ($all as $key => $row) {
485
-        			$count[$key] = $row['airport_departure_icao_count'];
486
-        		}
487
-        		array_multisort($count,SORT_DESC,$all);
488
-                }
489
-                return $all;
477
+				foreach ($dall as $value) {
478
+					$icao = $value['airport_departure_icao'];
479
+					if (isset($all[$icao])) {
480
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
481
+					} else $all[$icao] = $value;
482
+				}
483
+				$count = array();
484
+				foreach ($all as $key => $row) {
485
+					$count[$key] = $row['airport_departure_icao_count'];
486
+				}
487
+				array_multisort($count,SORT_DESC,$all);
488
+				}
489
+				return $all;
490 490
 	}
491 491
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
492 492
 		global $globalStatsFilters;
@@ -512,26 +512,26 @@  discard block
 block discarded – undo
512 512
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
513 513
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
514 514
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
515
-        		$all = array();
516
-        		foreach ($pall as $value) {
517
-        			$icao = $value['airport_arrival_icao'];
518
-        			$all[$icao] = $value;
519
-        		}
515
+				$all = array();
516
+				foreach ($pall as $value) {
517
+					$icao = $value['airport_arrival_icao'];
518
+					$all[$icao] = $value;
519
+				}
520 520
         		
521
-        		foreach ($dall as $value) {
522
-        			$icao = $value['airport_arrival_icao'];
523
-        			if (isset($all[$icao])) {
524
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
525
-        			} else $all[$icao] = $value;
526
-        		}
527
-        		$count = array();
528
-        		foreach ($all as $key => $row) {
529
-        			$count[$key] = $row['airport_arrival_icao_count'];
530
-        		}
531
-        		array_multisort($count,SORT_DESC,$all);
532
-                }
521
+				foreach ($dall as $value) {
522
+					$icao = $value['airport_arrival_icao'];
523
+					if (isset($all[$icao])) {
524
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
525
+					} else $all[$icao] = $value;
526
+				}
527
+				$count = array();
528
+				foreach ($all as $key => $row) {
529
+					$count[$key] = $row['airport_arrival_icao_count'];
530
+				}
531
+				array_multisort($count,SORT_DESC,$all);
532
+				}
533 533
  
534
-                return $all;
534
+				return $all;
535 535
 	}
536 536
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
537 537
 		global $globalDBdriver, $globalStatsFilters;
@@ -544,23 +544,23 @@  discard block
 block discarded – undo
544 544
 			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";
545 545
 		}
546 546
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
547
-                 try {
548
-                        $sth = $this->db->prepare($query);
549
-                        $sth->execute($query_data);
550
-                } catch(PDOException $e) {
551
-                        echo "error : ".$e->getMessage();
552
-                }
553
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
554
-                if (empty($all)) {
547
+				 try {
548
+						$sth = $this->db->prepare($query);
549
+						$sth->execute($query_data);
550
+				} catch(PDOException $e) {
551
+						echo "error : ".$e->getMessage();
552
+				}
553
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
554
+				if (empty($all)) {
555 555
 			$filters = array('airlines' => array($stats_airline));
556 556
 			if ($filter_name != '') {
557 557
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
558 558
 			}
559
-            		$Spotter = new Spotter($this->db);
560
-            		$all = $Spotter->countAllMonthsLastYear($filters);
561
-                }
559
+					$Spotter = new Spotter($this->db);
560
+					$all = $Spotter->countAllMonthsLastYear($filters);
561
+				}
562 562
                 
563
-                return $all;
563
+				return $all;
564 564
 	}
565 565
 	
566 566
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -568,22 +568,22 @@  discard block
 block discarded – undo
568 568
 		if ($filter_name == '') $filter_name = $this->filter_name;
569 569
 		$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";
570 570
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
571
-                 try {
572
-                        $sth = $this->db->prepare($query);
573
-                        $sth->execute($query_data);
574
-                } catch(PDOException $e) {
575
-                        echo "error : ".$e->getMessage();
576
-                }
577
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
578
-                if (empty($all)) {
571
+				 try {
572
+						$sth = $this->db->prepare($query);
573
+						$sth->execute($query_data);
574
+				} catch(PDOException $e) {
575
+						echo "error : ".$e->getMessage();
576
+				}
577
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
578
+				if (empty($all)) {
579 579
 			$filters = array('airlines' => array($stats_airline));
580 580
 			if ($filter_name != '') {
581 581
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
582 582
 			}
583
-            		$Spotter = new Spotter($this->db);
584
-            		$all = $Spotter->countAllDatesLastMonth($filters);
585
-                }
586
-                return $all;
583
+					$Spotter = new Spotter($this->db);
584
+					$all = $Spotter->countAllDatesLastMonth($filters);
585
+				}
586
+				return $all;
587 587
 	}
588 588
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
589 589
 		global $globalDBdriver, $globalStatsFilters;
@@ -594,66 +594,66 @@  discard block
 block discarded – undo
594 594
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
595 595
 		}
596 596
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
597
-                 try {
598
-                        $sth = $this->db->prepare($query);
599
-                        $sth->execute($query_data);
600
-                } catch(PDOException $e) {
601
-                        echo "error : ".$e->getMessage();
602
-                }
603
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
604
-                if (empty($all)) {
597
+				 try {
598
+						$sth = $this->db->prepare($query);
599
+						$sth->execute($query_data);
600
+				} catch(PDOException $e) {
601
+						echo "error : ".$e->getMessage();
602
+				}
603
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
604
+				if (empty($all)) {
605 605
 			$filters = array('airlines' => array($stats_airline));
606 606
 			if ($filter_name != '') {
607 607
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
608 608
 			}
609
-            		$Spotter = new Spotter($this->db);
610
-            		$all = $Spotter->countAllDatesLast7Days($filters);
611
-                }
612
-                return $all;
609
+					$Spotter = new Spotter($this->db);
610
+					$all = $Spotter->countAllDatesLast7Days($filters);
611
+				}
612
+				return $all;
613 613
 	}
614 614
 	public function countAllDates($stats_airline = '',$filter_name = '') {
615 615
 		global $globalStatsFilters;
616 616
 		if ($filter_name == '') $filter_name = $this->filter_name;
617 617
 		$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";
618 618
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
619
-                 try {
620
-                        $sth = $this->db->prepare($query);
621
-                        $sth->execute($query_data);
622
-                } catch(PDOException $e) {
623
-                        echo "error : ".$e->getMessage();
624
-                }
625
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
626
-                if (empty($all)) {
619
+				 try {
620
+						$sth = $this->db->prepare($query);
621
+						$sth->execute($query_data);
622
+				} catch(PDOException $e) {
623
+						echo "error : ".$e->getMessage();
624
+				}
625
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
626
+				if (empty($all)) {
627 627
 			$filters = array('airlines' => array($stats_airline));
628 628
 			if ($filter_name != '') {
629
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
629
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
630 630
 			}
631
-            		$Spotter = new Spotter($this->db);
632
-            		$all = $Spotter->countAllDates($filters);
633
-                }
634
-                return $all;
631
+					$Spotter = new Spotter($this->db);
632
+					$all = $Spotter->countAllDates($filters);
633
+				}
634
+				return $all;
635 635
 	}
636 636
 	public function countAllDatesByAirlines($filter_name = '') {
637 637
 		global $globalStatsFilters;
638 638
 		if ($filter_name == '') $filter_name = $this->filter_name;
639 639
 		$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";
640 640
 		$query_data = array('filter_name' => $filter_name);
641
-                 try {
642
-                        $sth = $this->db->prepare($query);
643
-                        $sth->execute($query_data);
644
-                } catch(PDOException $e) {
645
-                        echo "error : ".$e->getMessage();
646
-                }
647
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
648
-                if (empty($all)) {
649
-            		$filters = array();
650
-            		if ($filter_name != '') {
651
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
641
+				 try {
642
+						$sth = $this->db->prepare($query);
643
+						$sth->execute($query_data);
644
+				} catch(PDOException $e) {
645
+						echo "error : ".$e->getMessage();
646
+				}
647
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
648
+				if (empty($all)) {
649
+					$filters = array();
650
+					if ($filter_name != '') {
651
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
652 652
 			}
653
-            		$Spotter = new Spotter($this->db);
654
-            		$all = $Spotter->countAllDatesByAirlines($filters);
655
-                }
656
-                return $all;
653
+					$Spotter = new Spotter($this->db);
654
+					$all = $Spotter->countAllDatesByAirlines($filters);
655
+				}
656
+				return $all;
657 657
 	}
658 658
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
659 659
 		global $globalStatsFilters, $globalDBdriver;
@@ -663,24 +663,24 @@  discard block
 block discarded – undo
663 663
 		} else {
664 664
 			$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM 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";
665 665
 		}
666
-                 try {
667
-                        $sth = $this->db->prepare($query);
668
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
669
-                } catch(PDOException $e) {
670
-                        echo "error : ".$e->getMessage();
671
-                }
672
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
666
+				 try {
667
+						$sth = $this->db->prepare($query);
668
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
669
+				} catch(PDOException $e) {
670
+						echo "error : ".$e->getMessage();
671
+				}
672
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
673 673
                 
674
-                if (empty($all)) {
674
+				if (empty($all)) {
675 675
 			$filters = array('airlines' => array($stats_airline));
676 676
 			if ($filter_name != '') {
677 677
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
678 678
 			}
679
-            		$Spotter = new Spotter($this->db);
680
-            		$all = $Spotter->countAllMonths($filters);
681
-                }
679
+					$Spotter = new Spotter($this->db);
680
+					$all = $Spotter->countAllMonths($filters);
681
+				}
682 682
                 
683
-                return $all;
683
+				return $all;
684 684
 	}
685 685
 	public function countFatalitiesLast12Months() {
686 686
 		global $globalStatsFilters, $globalDBdriver;
@@ -689,19 +689,19 @@  discard block
 block discarded – undo
689 689
 		} else {
690 690
 			$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year, EXTRACT(MONTH FROM stats_date) as month,cnt as count FROM stats WHERE stats_type = 'fatalities_bymonth' ORDER BY stats_date";
691 691
 		}
692
-                 try {
693
-                        $sth = $this->db->prepare($query);
694
-                        $sth->execute();
695
-                } catch(PDOException $e) {
696
-                        echo "error : ".$e->getMessage();
697
-                }
698
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
692
+				 try {
693
+						$sth = $this->db->prepare($query);
694
+						$sth->execute();
695
+				} catch(PDOException $e) {
696
+						echo "error : ".$e->getMessage();
697
+				}
698
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
699 699
                 
700
-                if (empty($all)) {
701
-            		$Accident = new Accident($this->db);
702
-            		$all = $Accident->countFatalitiesLast12Months();
703
-                }
704
-                return $all;
700
+				if (empty($all)) {
701
+					$Accident = new Accident($this->db);
702
+					$all = $Accident->countFatalitiesLast12Months();
703
+				}
704
+				return $all;
705 705
 	}
706 706
 	public function countFatalitiesByYear() {
707 707
 		global $globalStatsFilters, $globalDBdriver;
@@ -710,40 +710,40 @@  discard block
 block discarded – undo
710 710
 		} else {
711 711
 			$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year, cnt as count FROM stats WHERE stats_type = 'fatalities_byyear' ORDER BY stats_date";
712 712
 		}
713
-                 try {
714
-                        $sth = $this->db->prepare($query);
715
-                        $sth->execute();
716
-                } catch(PDOException $e) {
717
-                        echo "error : ".$e->getMessage();
718
-                }
719
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
713
+				 try {
714
+						$sth = $this->db->prepare($query);
715
+						$sth->execute();
716
+				} catch(PDOException $e) {
717
+						echo "error : ".$e->getMessage();
718
+				}
719
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
720 720
                 
721
-                if (empty($all)) {
722
-            		$Accident = new Accident($this->db);
723
-            		$all = $Accident->countFatalitiesByYear();
724
-                }
725
-                return $all;
721
+				if (empty($all)) {
722
+					$Accident = new Accident($this->db);
723
+					$all = $Accident->countFatalitiesByYear();
724
+				}
725
+				return $all;
726 726
 	}
727 727
 	public function countAllMilitaryMonths($filter_name = '') {
728 728
 		global $globalStatsFilters;
729 729
 		if ($filter_name == '') $filter_name = $this->filter_name;
730
-	    	$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";
731
-                 try {
732
-                        $sth = $this->db->prepare($query);
733
-                        $sth->execute(array(':filter_name' => $filter_name));
734
-                } catch(PDOException $e) {
735
-                        echo "error : ".$e->getMessage();
736
-                }
737
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
738
-                if (empty($all)) {
739
-            		$filters = array();
740
-            		if ($filter_name != '') {
741
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
730
+			$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";
731
+				 try {
732
+						$sth = $this->db->prepare($query);
733
+						$sth->execute(array(':filter_name' => $filter_name));
734
+				} catch(PDOException $e) {
735
+						echo "error : ".$e->getMessage();
736
+				}
737
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
738
+				if (empty($all)) {
739
+					$filters = array();
740
+					if ($filter_name != '') {
741
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
742 742
 			}
743
-            		$Spotter = new Spotter($this->db);
744
-            		$all = $Spotter->countAllMilitaryMonths($filters);
745
-                }
746
-                return $all;
743
+					$Spotter = new Spotter($this->db);
744
+					$all = $Spotter->countAllMilitaryMonths($filters);
745
+				}
746
+				return $all;
747 747
 	}
748 748
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
749 749
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -759,22 +759,22 @@  discard block
 block discarded – undo
759 759
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
760 760
 		}
761 761
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
762
-                 try {
763
-                        $sth = $this->db->prepare($query);
764
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
765
-                } catch(PDOException $e) {
766
-                        echo "error : ".$e->getMessage();
767
-                }
768
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
769
-                if (empty($all)) {
762
+				 try {
763
+						$sth = $this->db->prepare($query);
764
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
765
+				} catch(PDOException $e) {
766
+						echo "error : ".$e->getMessage();
767
+				}
768
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
769
+				if (empty($all)) {
770 770
 			$filters = array('airlines' => array($stats_airline));
771 771
 			if ($filter_name != '') {
772
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
772
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
773 773
 			}
774
-            		$Spotter = new Spotter($this->db);
775
-            		$all = $Spotter->countAllHours($orderby,$filters);
776
-                }
777
-                return $all;
774
+					$Spotter = new Spotter($this->db);
775
+					$all = $Spotter->countAllHours($orderby,$filters);
776
+				}
777
+				return $all;
778 778
 	}
779 779
 	
780 780
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
@@ -799,10 +799,10 @@  discard block
 block discarded – undo
799 799
 		if ($year == '') $year = date('Y');
800 800
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
801 801
 		if (empty($all)) {
802
-		        $filters = array();
802
+				$filters = array();
803 803
 			$filters = array('year' => $year,'month' => $month);
804
-            		if ($filter_name != '') {
805
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
804
+					if ($filter_name != '') {
805
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
806 806
 			}
807 807
 			$Spotter = new Spotter($this->db);
808 808
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -866,10 +866,10 @@  discard block
 block discarded – undo
866 866
 			$all = $result[0]['nb_airline'];
867 867
 		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
868 868
 		if (empty($all)) {
869
-            		$filters = array();
869
+					$filters = array();
870 870
 			$filters = array('year' => $year,'month' => $month);
871
-            		if ($filter_name != '') {
872
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
871
+					if ($filter_name != '') {
872
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
873 873
 			}
874 874
 			$Spotter = new Spotter($this->db);
875 875
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -939,46 +939,46 @@  discard block
 block discarded – undo
939 939
 		if ($filter_name == '') $filter_name = $this->filter_name;
940 940
 		$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";
941 941
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
942
-                 try {
943
-                        $sth = $this->db->prepare($query);
944
-                        $sth->execute($query_values);
945
-                } catch(PDOException $e) {
946
-                        echo "error : ".$e->getMessage();
947
-                }
948
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
949
-                return $all;
942
+				 try {
943
+						$sth = $this->db->prepare($query);
944
+						$sth->execute($query_values);
945
+				} catch(PDOException $e) {
946
+						echo "error : ".$e->getMessage();
947
+				}
948
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
949
+				return $all;
950 950
 	}
951 951
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
952 952
 		if ($filter_name == '') $filter_name = $this->filter_name;
953
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
954
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
955
-                 try {
956
-                        $sth = $this->db->prepare($query);
957
-                        $sth->execute($query_values);
958
-                } catch(PDOException $e) {
959
-                        echo "error : ".$e->getMessage();
960
-                }
961
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
962
-                return $all;
963
-        }
953
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
954
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
955
+				 try {
956
+						$sth = $this->db->prepare($query);
957
+						$sth->execute($query_values);
958
+				} catch(PDOException $e) {
959
+						echo "error : ".$e->getMessage();
960
+				}
961
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
962
+				return $all;
963
+		}
964 964
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
965 965
 		if ($filter_name == '') $filter_name = $this->filter_name;
966
-                $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
967
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
968
-                 try {
969
-                        $sth = $this->db->prepare($query);
970
-                        $sth->execute($query_values);
971
-                } catch(PDOException $e) {
972
-                        echo "error : ".$e->getMessage();
973
-                }
974
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
975
-                return $all;
976
-        }
966
+				$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
967
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
968
+				 try {
969
+						$sth = $this->db->prepare($query);
970
+						$sth->execute($query_values);
971
+				} catch(PDOException $e) {
972
+						echo "error : ".$e->getMessage();
973
+				}
974
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
975
+				return $all;
976
+		}
977 977
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
978 978
 		if ($filter_name == '') $filter_name = $this->filter_name;
979
-    		global $globalArchiveMonths, $globalDBdriver;
980
-    		if ($globalDBdriver == 'mysql') {
981
-    			if ($month == '') {
979
+			global $globalArchiveMonths, $globalDBdriver;
980
+			if ($globalDBdriver == 'mysql') {
981
+				if ($month == '') {
982 982
 				$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";
983 983
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
984 984
 			} else {
@@ -993,165 +993,165 @@  discard block
 block discarded – undo
993 993
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
994 994
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
995 995
 			}
996
-                }
997
-                 try {
998
-                        $sth = $this->db->prepare($query);
999
-                        $sth->execute($query_values);
1000
-                } catch(PDOException $e) {
1001
-                        echo "error : ".$e->getMessage();
1002
-                }
1003
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1004
-                return $all[0]['total'];
1005
-        }
996
+				}
997
+				 try {
998
+						$sth = $this->db->prepare($query);
999
+						$sth->execute($query_values);
1000
+				} catch(PDOException $e) {
1001
+						echo "error : ".$e->getMessage();
1002
+				}
1003
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1004
+				return $all[0]['total'];
1005
+		}
1006 1006
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1007
-    		global $globalArchiveMonths, $globalDBdriver;
1007
+			global $globalArchiveMonths, $globalDBdriver;
1008 1008
 		if ($filter_name == '') $filter_name = $this->filter_name;
1009
-    		if ($globalDBdriver == 'mysql') {
1009
+			if ($globalDBdriver == 'mysql') {
1010 1010
 			$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";
1011 1011
 		} else {
1012 1012
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1013
-                }
1014
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1015
-                 try {
1016
-                        $sth = $this->db->prepare($query);
1017
-                        $sth->execute($query_values);
1018
-                } catch(PDOException $e) {
1019
-                        echo "error : ".$e->getMessage();
1020
-                }
1021
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1022
-                return $all[0]['total'];
1023
-        }
1013
+				}
1014
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1015
+				 try {
1016
+						$sth = $this->db->prepare($query);
1017
+						$sth->execute($query_values);
1018
+				} catch(PDOException $e) {
1019
+						echo "error : ".$e->getMessage();
1020
+				}
1021
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1022
+				return $all[0]['total'];
1023
+		}
1024 1024
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1025
-    		global $globalArchiveMonths, $globalDBdriver;
1025
+			global $globalArchiveMonths, $globalDBdriver;
1026 1026
 		if ($filter_name == '') $filter_name = $this->filter_name;
1027
-    		if ($globalDBdriver == 'mysql') {
1027
+			if ($globalDBdriver == 'mysql') {
1028 1028
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1029
-                } else {
1029
+				} else {
1030 1030
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1031
-                }
1032
-                 try {
1033
-                        $sth = $this->db->prepare($query);
1034
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1035
-                } catch(PDOException $e) {
1036
-                        echo "error : ".$e->getMessage();
1037
-                }
1038
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1039
-                return $all[0]['total'];
1040
-        }
1031
+				}
1032
+				 try {
1033
+						$sth = $this->db->prepare($query);
1034
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1035
+				} catch(PDOException $e) {
1036
+						echo "error : ".$e->getMessage();
1037
+				}
1038
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1039
+				return $all[0]['total'];
1040
+		}
1041 1041
 	public function getStatsAirlineTotal($filter_name = '') {
1042
-    		global $globalArchiveMonths, $globalDBdriver;
1042
+			global $globalArchiveMonths, $globalDBdriver;
1043 1043
 		if ($filter_name == '') $filter_name = $this->filter_name;
1044
-    		if ($globalDBdriver == 'mysql') {
1044
+			if ($globalDBdriver == 'mysql') {
1045 1045
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1046
-                } else {
1046
+				} else {
1047 1047
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1048
-                }
1049
-                 try {
1050
-                        $sth = $this->db->prepare($query);
1051
-                        $sth->execute(array(':filter_name' => $filter_name));
1052
-                } catch(PDOException $e) {
1053
-                        echo "error : ".$e->getMessage();
1054
-                }
1055
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1056
-                return $all[0]['total'];
1057
-        }
1048
+				}
1049
+				 try {
1050
+						$sth = $this->db->prepare($query);
1051
+						$sth->execute(array(':filter_name' => $filter_name));
1052
+				} catch(PDOException $e) {
1053
+						echo "error : ".$e->getMessage();
1054
+				}
1055
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1056
+				return $all[0]['total'];
1057
+		}
1058 1058
 	public function getStatsOwnerTotal($filter_name = '') {
1059
-    		global $globalArchiveMonths, $globalDBdriver;
1059
+			global $globalArchiveMonths, $globalDBdriver;
1060 1060
 		if ($filter_name == '') $filter_name = $this->filter_name;
1061
-    		if ($globalDBdriver == 'mysql') {
1061
+			if ($globalDBdriver == 'mysql') {
1062 1062
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1063 1063
 		} else {
1064 1064
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1065
-                }
1066
-                 try {
1067
-                        $sth = $this->db->prepare($query);
1068
-                        $sth->execute(array(':filter_name' => $filter_name));
1069
-                } catch(PDOException $e) {
1070
-                        echo "error : ".$e->getMessage();
1071
-                }
1072
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1073
-                return $all[0]['total'];
1074
-        }
1065
+				}
1066
+				 try {
1067
+						$sth = $this->db->prepare($query);
1068
+						$sth->execute(array(':filter_name' => $filter_name));
1069
+				} catch(PDOException $e) {
1070
+						echo "error : ".$e->getMessage();
1071
+				}
1072
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1073
+				return $all[0]['total'];
1074
+		}
1075 1075
 	public function getStatsOwner($owner_name,$filter_name = '') {
1076
-    		global $globalArchiveMonths, $globalDBdriver;
1076
+			global $globalArchiveMonths, $globalDBdriver;
1077 1077
 		if ($filter_name == '') $filter_name = $this->filter_name;
1078 1078
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1079
-                 try {
1080
-                        $sth = $this->db->prepare($query);
1081
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1082
-                } catch(PDOException $e) {
1083
-                        echo "error : ".$e->getMessage();
1084
-                }
1085
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1086
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1087
-                else return 0;
1088
-        }
1079
+				 try {
1080
+						$sth = $this->db->prepare($query);
1081
+						$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1082
+				} catch(PDOException $e) {
1083
+						echo "error : ".$e->getMessage();
1084
+				}
1085
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1086
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1087
+				else return 0;
1088
+		}
1089 1089
 	public function getStatsPilotTotal($filter_name = '') {
1090
-    		global $globalArchiveMonths, $globalDBdriver;
1090
+			global $globalArchiveMonths, $globalDBdriver;
1091 1091
 		if ($filter_name == '') $filter_name = $this->filter_name;
1092
-    		if ($globalDBdriver == 'mysql') {
1093
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1094
-            	} else {
1095
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1096
-            	}
1097
-                 try {
1098
-                        $sth = $this->db->prepare($query);
1099
-                        $sth->execute(array(':filter_name' => $filter_name));
1100
-                } catch(PDOException $e) {
1101
-                        echo "error : ".$e->getMessage();
1102
-                }
1103
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1104
-                return $all[0]['total'];
1105
-        }
1092
+			if ($globalDBdriver == 'mysql') {
1093
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1094
+				} else {
1095
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1096
+				}
1097
+				 try {
1098
+						$sth = $this->db->prepare($query);
1099
+						$sth->execute(array(':filter_name' => $filter_name));
1100
+				} catch(PDOException $e) {
1101
+						echo "error : ".$e->getMessage();
1102
+				}
1103
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1104
+				return $all[0]['total'];
1105
+		}
1106 1106
 	public function getStatsPilot($pilot,$filter_name = '') {
1107
-    		global $globalArchiveMonths, $globalDBdriver;
1107
+			global $globalArchiveMonths, $globalDBdriver;
1108 1108
 		if ($filter_name == '') $filter_name = $this->filter_name;
1109 1109
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1110
-                 try {
1111
-                        $sth = $this->db->prepare($query);
1112
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1113
-                } catch(PDOException $e) {
1114
-                        echo "error : ".$e->getMessage();
1115
-                }
1116
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1117
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1118
-                else return 0;
1119
-        }
1110
+				 try {
1111
+						$sth = $this->db->prepare($query);
1112
+						$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1113
+				} catch(PDOException $e) {
1114
+						echo "error : ".$e->getMessage();
1115
+				}
1116
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1117
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1118
+				else return 0;
1119
+		}
1120 1120
 
1121 1121
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1122 1122
 		global $globalDBdriver;
1123 1123
 		if ($filter_name == '') $filter_name = $this->filter_name;
1124 1124
 		if ($globalDBdriver == 'mysql') {
1125 1125
 			$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";
1126
-                } else {
1126
+				} else {
1127 1127
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1128 1128
 		}
1129
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1130
-                 try {
1131
-                        $sth = $this->db->prepare($query);
1132
-                        $sth->execute($query_values);
1133
-                } catch(PDOException $e) {
1134
-                        return "error : ".$e->getMessage();
1135
-                }
1136
-        }
1129
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1130
+				 try {
1131
+						$sth = $this->db->prepare($query);
1132
+						$sth->execute($query_values);
1133
+				} catch(PDOException $e) {
1134
+						return "error : ".$e->getMessage();
1135
+				}
1136
+		}
1137 1137
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1138 1138
 		global $globalDBdriver;
1139 1139
 		if ($filter_name == '') $filter_name = $this->filter_name;
1140 1140
 		if ($globalDBdriver == 'mysql') {
1141 1141
 			$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";
1142 1142
 		} else {
1143
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1143
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1144 1144
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1145
-                }
1146
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1147
-                 try {
1148
-                        $sth = $this->db->prepare($query);
1149
-                        $sth->execute($query_values);
1150
-                } catch(PDOException $e) {
1151
-                        return "error : ".$e->getMessage();
1152
-                }
1153
-        }
1154
-        /*
1145
+				}
1146
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1147
+				 try {
1148
+						$sth = $this->db->prepare($query);
1149
+						$sth->execute($query_values);
1150
+				} catch(PDOException $e) {
1151
+						return "error : ".$e->getMessage();
1152
+				}
1153
+		}
1154
+		/*
1155 1155
 	public function getStatsSource($date,$stats_type = '') {
1156 1156
 		if ($stats_type == '') {
1157 1157
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -1220,25 +1220,25 @@  discard block
 block discarded – undo
1220 1220
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1221 1221
 		} else {
1222 1222
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1223
-                }
1224
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1225
-                 try {
1226
-                        $sth = $this->db->prepare($query);
1227
-                        $sth->execute($query_values);
1228
-                } catch(PDOException $e) {
1229
-                        return "error : ".$e->getMessage();
1230
-                }
1231
-        }
1232
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1233
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1234
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1235
-                 try {
1236
-                        $sth = $this->db->prepare($query);
1237
-                        $sth->execute($query_values);
1238
-                } catch(PDOException $e) {
1239
-                        return "error : ".$e->getMessage();
1240
-                }
1241
-        }
1223
+				}
1224
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1225
+				 try {
1226
+						$sth = $this->db->prepare($query);
1227
+						$sth->execute($query_values);
1228
+				} catch(PDOException $e) {
1229
+						return "error : ".$e->getMessage();
1230
+				}
1231
+		}
1232
+	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1233
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1234
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1235
+				 try {
1236
+						$sth = $this->db->prepare($query);
1237
+						$sth->execute($query_values);
1238
+				} catch(PDOException $e) {
1239
+						return "error : ".$e->getMessage();
1240
+				}
1241
+		}
1242 1242
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1243 1243
 		global $globalDBdriver;
1244 1244
 		if ($globalDBdriver == 'mysql') {
@@ -1254,14 +1254,14 @@  discard block
 block discarded – undo
1254 1254
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1255 1255
 			}
1256 1256
 		}
1257
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1258
-                 try {
1259
-                        $sth = $this->db->prepare($query);
1260
-                        $sth->execute($query_values);
1261
-                } catch(PDOException $e) {
1262
-                        return "error : ".$e->getMessage();
1263
-                }
1264
-        }
1257
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1258
+				 try {
1259
+						$sth = $this->db->prepare($query);
1260
+						$sth->execute($query_values);
1261
+				} catch(PDOException $e) {
1262
+						return "error : ".$e->getMessage();
1263
+				}
1264
+		}
1265 1265
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1266 1266
 		global $globalDBdriver;
1267 1267
 		if ($globalDBdriver == 'mysql') {
@@ -1277,14 +1277,14 @@  discard block
 block discarded – undo
1277 1277
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1278 1278
 			}
1279 1279
 		}
1280
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1281
-                 try {
1282
-                        $sth = $this->db->prepare($query);
1283
-                        $sth->execute($query_values);
1284
-                } catch(PDOException $e) {
1285
-                        return "error : ".$e->getMessage();
1286
-                }
1287
-        }
1280
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1281
+				 try {
1282
+						$sth = $this->db->prepare($query);
1283
+						$sth->execute($query_values);
1284
+				} catch(PDOException $e) {
1285
+						return "error : ".$e->getMessage();
1286
+				}
1287
+		}
1288 1288
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1289 1289
 		global $globalDBdriver;
1290 1290
 		if ($globalDBdriver == 'mysql') {
@@ -1300,14 +1300,14 @@  discard block
 block discarded – undo
1300 1300
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
1301 1301
 			}
1302 1302
 		}
1303
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1304
-                 try {
1305
-                        $sth = $this->db->prepare($query);
1306
-                        $sth->execute($query_values);
1307
-                } catch(PDOException $e) {
1308
-                        return "error : ".$e->getMessage();
1309
-                }
1310
-        }
1303
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1304
+				 try {
1305
+						$sth = $this->db->prepare($query);
1306
+						$sth->execute($query_values);
1307
+				} catch(PDOException $e) {
1308
+						return "error : ".$e->getMessage();
1309
+				}
1310
+		}
1311 1311
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1312 1312
 		global $globalDBdriver;
1313 1313
 		if ($globalDBdriver == 'mysql') {
@@ -1323,14 +1323,14 @@  discard block
 block discarded – undo
1323 1323
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1324 1324
 			}
1325 1325
 		}
1326
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1327
-                 try {
1328
-                        $sth = $this->db->prepare($query);
1329
-                        $sth->execute($query_values);
1330
-                } catch(PDOException $e) {
1331
-                        return "error : ".$e->getMessage();
1332
-                }
1333
-        }
1326
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1327
+				 try {
1328
+						$sth = $this->db->prepare($query);
1329
+						$sth->execute($query_values);
1330
+				} catch(PDOException $e) {
1331
+						return "error : ".$e->getMessage();
1332
+				}
1333
+		}
1334 1334
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1335 1335
 		global $globalDBdriver;
1336 1336
 		if ($globalDBdriver == 'mysql') {
@@ -1346,14 +1346,14 @@  discard block
 block discarded – undo
1346 1346
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1347 1347
 			}
1348 1348
 		}
1349
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1350
-                 try {
1351
-                        $sth = $this->db->prepare($query);
1352
-                        $sth->execute($query_values);
1353
-                } catch(PDOException $e) {
1354
-                        return "error : ".$e->getMessage();
1355
-                }
1356
-        }
1349
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1350
+				 try {
1351
+						$sth = $this->db->prepare($query);
1352
+						$sth->execute($query_values);
1353
+				} catch(PDOException $e) {
1354
+						return "error : ".$e->getMessage();
1355
+				}
1356
+		}
1357 1357
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1358 1358
 		global $globalDBdriver;
1359 1359
 		if ($globalDBdriver == 'mysql') {
@@ -1369,14 +1369,14 @@  discard block
 block discarded – undo
1369 1369
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1370 1370
 			}
1371 1371
 		}
1372
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1373
-                 try {
1374
-                        $sth = $this->db->prepare($query);
1375
-                        $sth->execute($query_values);
1376
-                } catch(PDOException $e) {
1377
-                        return "error : ".$e->getMessage();
1378
-                }
1379
-        }
1372
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1373
+				 try {
1374
+						$sth = $this->db->prepare($query);
1375
+						$sth->execute($query_values);
1376
+				} catch(PDOException $e) {
1377
+						return "error : ".$e->getMessage();
1378
+				}
1379
+		}
1380 1380
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1381 1381
 		global $globalDBdriver;
1382 1382
 		if ($globalDBdriver == 'mysql') {
@@ -1392,14 +1392,14 @@  discard block
 block discarded – undo
1392 1392
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1393 1393
 			}
1394 1394
 		}
1395
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1396
-                 try {
1397
-                        $sth = $this->db->prepare($query);
1398
-                        $sth->execute($query_values);
1399
-                } catch(PDOException $e) {
1400
-                        return "error : ".$e->getMessage();
1401
-                }
1402
-        }
1395
+				$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1396
+				 try {
1397
+						$sth = $this->db->prepare($query);
1398
+						$sth->execute($query_values);
1399
+				} catch(PDOException $e) {
1400
+						return "error : ".$e->getMessage();
1401
+				}
1402
+		}
1403 1403
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1404 1404
 		global $globalDBdriver;
1405 1405
 		if ($airport_icao != '') {
@@ -1423,8 +1423,8 @@  discard block
 block discarded – undo
1423 1423
 			} catch(PDOException $e) {
1424 1424
 				return "error : ".$e->getMessage();
1425 1425
 			}
1426
-                }
1427
-        }
1426
+				}
1427
+		}
1428 1428
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1429 1429
 		global $globalDBdriver;
1430 1430
 		if ($airport_icao != '') {
@@ -1440,8 +1440,8 @@  discard block
 block discarded – undo
1440 1440
 			} catch(PDOException $e) {
1441 1441
 				return "error : ".$e->getMessage();
1442 1442
 			}
1443
-                }
1444
-        }
1443
+				}
1444
+		}
1445 1445
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1446 1446
 		global $globalDBdriver;
1447 1447
 		if ($airport_icao != '') {
@@ -1458,15 +1458,15 @@  discard block
 block discarded – undo
1458 1458
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1459 1459
 				}
1460 1460
 			}
1461
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1461
+					$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1462 1462
 			 try {
1463
-                    		$sth = $this->db->prepare($query);
1464
-	                        $sth->execute($query_values);
1465
-    		        } catch(PDOException $e) {
1466
-            		        return "error : ".$e->getMessage();
1467
-	                }
1468
-	        }
1469
-        }
1463
+							$sth = $this->db->prepare($query);
1464
+							$sth->execute($query_values);
1465
+					} catch(PDOException $e) {
1466
+							return "error : ".$e->getMessage();
1467
+					}
1468
+			}
1469
+		}
1470 1470
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1471 1471
 		global $globalDBdriver;
1472 1472
 		if ($airport_icao != '') {
@@ -1482,46 +1482,46 @@  discard block
 block discarded – undo
1482 1482
 			} catch(PDOException $e) {
1483 1483
 				return "error : ".$e->getMessage();
1484 1484
 			}
1485
-                }
1486
-        }
1485
+				}
1486
+		}
1487 1487
 
1488 1488
 	public function deleteStat($id) {
1489
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1490
-                $query_values = array(':id' => $id);
1491
-                 try {
1492
-                        $sth = $this->db->prepare($query);
1493
-                        $sth->execute($query_values);
1494
-                } catch(PDOException $e) {
1495
-                        return "error : ".$e->getMessage();
1496
-                }
1497
-        }
1489
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1490
+				$query_values = array(':id' => $id);
1491
+				 try {
1492
+						$sth = $this->db->prepare($query);
1493
+						$sth->execute($query_values);
1494
+				} catch(PDOException $e) {
1495
+						return "error : ".$e->getMessage();
1496
+				}
1497
+		}
1498 1498
 	public function deleteStatFlight($type) {
1499
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1500
-                $query_values = array(':type' => $type);
1501
-                 try {
1502
-                        $sth = $this->db->prepare($query);
1503
-                        $sth->execute($query_values);
1504
-                } catch(PDOException $e) {
1505
-                        return "error : ".$e->getMessage();
1506
-                }
1507
-        }
1499
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1500
+				$query_values = array(':type' => $type);
1501
+				 try {
1502
+						$sth = $this->db->prepare($query);
1503
+						$sth->execute($query_values);
1504
+				} catch(PDOException $e) {
1505
+						return "error : ".$e->getMessage();
1506
+				}
1507
+		}
1508 1508
 	public function deleteStatAirport($type) {
1509
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1510
-                $query_values = array(':type' => $type);
1511
-                 try {
1512
-                        $sth = $this->db->prepare($query);
1513
-                        $sth->execute($query_values);
1514
-                } catch(PDOException $e) {
1515
-                        return "error : ".$e->getMessage();
1516
-                }
1517
-        }
1509
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1510
+				$query_values = array(':type' => $type);
1511
+				 try {
1512
+						$sth = $this->db->prepare($query);
1513
+						$sth->execute($query_values);
1514
+				} catch(PDOException $e) {
1515
+						return "error : ".$e->getMessage();
1516
+				}
1517
+		}
1518 1518
         
1519
-        public function addOldStats() {
1520
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1521
-    		$Common = new Common();
1522
-    		$Connection = new Connection();
1523
-    		date_default_timezone_set('UTC');
1524
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1519
+		public function addOldStats() {
1520
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1521
+			$Common = new Common();
1522
+			$Connection = new Connection();
1523
+			date_default_timezone_set('UTC');
1524
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1525 1525
 			if ($globalDebug) echo 'Update stats !'."\n";
1526 1526
 			if (isset($last_update[0]['value'])) {
1527 1527
 				$last_update_day = $last_update[0]['value'];
@@ -1568,24 +1568,24 @@  discard block
 block discarded – undo
1568 1568
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1569 1569
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1570 1570
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1571
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1571
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1572 1572
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1573
-	        	$alldata = array();
1573
+				$alldata = array();
1574 1574
 	        	
1575
-    			foreach ($pall as $value) {
1576
-	        		$icao = $value['airport_departure_icao'];
1577
-    				$alldata[$icao] = $value;
1578
-	        	}
1579
-	        	foreach ($dall as $value) {
1580
-    				$icao = $value['airport_departure_icao'];
1581
-        			if (isset($alldata[$icao])) {
1582
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1583
-        			} else $alldata[$icao] = $value;
1584
-			}
1585
-    			$count = array();
1586
-    			foreach ($alldata as $key => $row) {
1587
-    				$count[$key] = $row['airport_departure_icao_count'];
1588
-        		}
1575
+				foreach ($pall as $value) {
1576
+					$icao = $value['airport_departure_icao'];
1577
+					$alldata[$icao] = $value;
1578
+				}
1579
+				foreach ($dall as $value) {
1580
+					$icao = $value['airport_departure_icao'];
1581
+					if (isset($alldata[$icao])) {
1582
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1583
+					} else $alldata[$icao] = $value;
1584
+			}
1585
+				$count = array();
1586
+				foreach ($alldata as $key => $row) {
1587
+					$count[$key] = $row['airport_departure_icao_count'];
1588
+				}
1589 1589
 			array_multisort($count,SORT_DESC,$alldata);
1590 1590
 			foreach ($alldata as $number) {
1591 1591
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
@@ -1593,25 +1593,25 @@  discard block
 block discarded – undo
1593 1593
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1594 1594
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1595 1595
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1596
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1596
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1597 1597
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1598
-	        	$alldata = array();
1599
-    			foreach ($pall as $value) {
1600
-	        		$icao = $value['airport_arrival_icao'];
1601
-    				$alldata[$icao] = $value;
1602
-	        	}
1603
-	        	foreach ($dall as $value) {
1604
-    				$icao = $value['airport_arrival_icao'];
1605
-        			if (isset($alldata[$icao])) {
1606
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1607
-	        		} else $alldata[$icao] = $value;
1608
-    			}
1609
-        		$count = array();
1610
-        		foreach ($alldata as $key => $row) {
1611
-        			$count[$key] = $row['airport_arrival_icao_count'];
1612
-	        	}
1613
-    			array_multisort($count,SORT_DESC,$alldata);
1614
-                        foreach ($alldata as $number) {
1598
+				$alldata = array();
1599
+				foreach ($pall as $value) {
1600
+					$icao = $value['airport_arrival_icao'];
1601
+					$alldata[$icao] = $value;
1602
+				}
1603
+				foreach ($dall as $value) {
1604
+					$icao = $value['airport_arrival_icao'];
1605
+					if (isset($alldata[$icao])) {
1606
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1607
+					} else $alldata[$icao] = $value;
1608
+				}
1609
+				$count = array();
1610
+				foreach ($alldata as $key => $row) {
1611
+					$count[$key] = $row['airport_arrival_icao_count'];
1612
+				}
1613
+				array_multisort($count,SORT_DESC,$alldata);
1614
+						foreach ($alldata as $number) {
1615 1615
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1616 1616
 			}
1617 1617
 			if ($Connection->tableExists('countries')) {
@@ -1684,8 +1684,8 @@  discard block
 block discarded – undo
1684 1684
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1685 1685
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1686 1686
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1687
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1688
-        		/*
1687
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1688
+				/*
1689 1689
 	        	$alldata = array();
1690 1690
     			foreach ($pall as $value) {
1691 1691
 	        		$icao = $value['departure_airport_icao'];
@@ -1704,29 +1704,29 @@  discard block
 block discarded – undo
1704 1704
 	        	}
1705 1705
     			array_multisort($count,SORT_DESC,$alldata);
1706 1706
     			*/
1707
-    			foreach ($dall as $value) {
1708
-    				$icao = $value['departure_airport_icao'];
1709
-    				$ddate = $value['date'];
1710
-    				$find = false;
1711
-    				foreach ($pall as $pvalue) {
1712
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1713
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1714
-    						$find = true;
1715
-    						break;
1716
-    					}
1717
-    				}
1718
-    				if ($find === false) {
1719
-    					$pall[] = $value;
1720
-    				}
1721
-    			}
1722
-    			$alldata = $pall;
1707
+				foreach ($dall as $value) {
1708
+					$icao = $value['departure_airport_icao'];
1709
+					$ddate = $value['date'];
1710
+					$find = false;
1711
+					foreach ($pall as $pvalue) {
1712
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1713
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1714
+							$find = true;
1715
+							break;
1716
+						}
1717
+					}
1718
+					if ($find === false) {
1719
+						$pall[] = $value;
1720
+					}
1721
+				}
1722
+				$alldata = $pall;
1723 1723
 			foreach ($alldata as $number) {
1724 1724
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1725 1725
 			}
1726 1726
 			echo '...Arrival'."\n";
1727 1727
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1728
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1729
-        		/*
1728
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1729
+				/*
1730 1730
 	        	$alldata = array();
1731 1731
     			foreach ($pall as $value) {
1732 1732
 	        		$icao = $value['arrival_airport_icao'];
@@ -1746,22 +1746,22 @@  discard block
 block discarded – undo
1746 1746
     			*/
1747 1747
 
1748 1748
 
1749
-    			foreach ($dall as $value) {
1750
-    				$icao = $value['arrival_airport_icao'];
1751
-    				$ddate = $value['date'];
1752
-    				$find = false;
1753
-    				foreach ($pall as $pvalue) {
1754
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1755
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1756
-    						$find = true;
1757
-    						break;
1758
-    					}
1759
-    				}
1760
-    				if ($find === false) {
1761
-    					$pall[] = $value;
1762
-    				}
1763
-    			}
1764
-    			$alldata = $pall;
1749
+				foreach ($dall as $value) {
1750
+					$icao = $value['arrival_airport_icao'];
1751
+					$ddate = $value['date'];
1752
+					$find = false;
1753
+					foreach ($pall as $pvalue) {
1754
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1755
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1756
+							$find = true;
1757
+							break;
1758
+						}
1759
+					}
1760
+					if ($find === false) {
1761
+						$pall[] = $value;
1762
+					}
1763
+				}
1764
+				$alldata = $pall;
1765 1765
 			foreach ($alldata as $number) {
1766 1766
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1767 1767
 			}
@@ -1836,51 +1836,51 @@  discard block
 block discarded – undo
1836 1836
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1837 1837
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1838 1838
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1839
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1839
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1840 1840
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1841
-	        	//$alldata = array();
1842
-    			foreach ($dall as $value) {
1843
-    				$icao = $value['airport_departure_icao'];
1844
-    				$dicao = $value['airline_icao'];
1845
-    				$find = false;
1846
-    				foreach ($pall as $pvalue) {
1847
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1848
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1849
-    						$find = true;
1850
-    						break;
1851
-    					}
1852
-    				}
1853
-    				if ($find === false) {
1854
-    					$pall[] = $value;
1855
-    				}
1856
-    			}
1857
-    			$alldata = $pall;
1841
+				//$alldata = array();
1842
+				foreach ($dall as $value) {
1843
+					$icao = $value['airport_departure_icao'];
1844
+					$dicao = $value['airline_icao'];
1845
+					$find = false;
1846
+					foreach ($pall as $pvalue) {
1847
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1848
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1849
+							$find = true;
1850
+							break;
1851
+						}
1852
+					}
1853
+					if ($find === false) {
1854
+						$pall[] = $value;
1855
+					}
1856
+				}
1857
+				$alldata = $pall;
1858 1858
 			foreach ($alldata as $number) {
1859 1859
 				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'],'',$reset);
1860 1860
 			}
1861 1861
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1862 1862
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1863 1863
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1864
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1864
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1865 1865
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1866
-	        	//$alldata = array();
1867
-    			foreach ($dall as $value) {
1868
-    				$icao = $value['airport_arrival_icao'];
1869
-    				$dicao = $value['airline_icao'];
1870
-    				$find = false;
1871
-    				foreach ($pall as $pvalue) {
1872
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1873
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1874
-    						$find = true;
1875
-    						break;
1876
-    					}
1877
-    				}
1878
-    				if ($find === false) {
1879
-    					$pall[] = $value;
1880
-    				}
1881
-    			}
1882
-    			$alldata = $pall;
1883
-                        foreach ($alldata as $number) {
1866
+				//$alldata = array();
1867
+				foreach ($dall as $value) {
1868
+					$icao = $value['airport_arrival_icao'];
1869
+					$dicao = $value['airline_icao'];
1870
+					$find = false;
1871
+					foreach ($pall as $pvalue) {
1872
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1873
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1874
+							$find = true;
1875
+							break;
1876
+						}
1877
+					}
1878
+					if ($find === false) {
1879
+						$pall[] = $value;
1880
+					}
1881
+				}
1882
+				$alldata = $pall;
1883
+						foreach ($alldata as $number) {
1884 1884
 				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'],'',$reset);
1885 1885
 			}
1886 1886
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1913,47 +1913,47 @@  discard block
 block discarded – undo
1913 1913
 			}
1914 1914
 			if ($globalDebug) echo '...Departure'."\n";
1915 1915
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1916
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1917
-    			foreach ($dall as $value) {
1918
-    				$icao = $value['departure_airport_icao'];
1919
-    				$airline = $value['airline_icao'];
1920
-    				$ddate = $value['date'];
1921
-    				$find = false;
1922
-    				foreach ($pall as $pvalue) {
1923
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1924
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1925
-    						$find = true;
1926
-    						break;
1927
-    					}
1928
-    				}
1929
-    				if ($find === false) {
1930
-    					$pall[] = $value;
1931
-    				}
1932
-    			}
1933
-    			$alldata = $pall;
1916
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1917
+				foreach ($dall as $value) {
1918
+					$icao = $value['departure_airport_icao'];
1919
+					$airline = $value['airline_icao'];
1920
+					$ddate = $value['date'];
1921
+					$find = false;
1922
+					foreach ($pall as $pvalue) {
1923
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1924
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1925
+							$find = true;
1926
+							break;
1927
+						}
1928
+					}
1929
+					if ($find === false) {
1930
+						$pall[] = $value;
1931
+					}
1932
+				}
1933
+				$alldata = $pall;
1934 1934
 			foreach ($alldata as $number) {
1935 1935
 				$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']);
1936 1936
 			}
1937 1937
 			if ($globalDebug) echo '...Arrival'."\n";
1938 1938
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1939
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1940
-    			foreach ($dall as $value) {
1941
-    				$icao = $value['arrival_airport_icao'];
1942
-    				$airline = $value['airline_icao'];
1943
-    				$ddate = $value['date'];
1944
-    				$find = false;
1945
-    				foreach ($pall as $pvalue) {
1946
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1947
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1948
-    						$find = true;
1949
-    						break;
1950
-    					}
1951
-    				}
1952
-    				if ($find === false) {
1953
-    					$pall[] = $value;
1954
-    				}
1955
-    			}
1956
-    			$alldata = $pall;
1939
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1940
+				foreach ($dall as $value) {
1941
+					$icao = $value['arrival_airport_icao'];
1942
+					$airline = $value['airline_icao'];
1943
+					$ddate = $value['date'];
1944
+					$find = false;
1945
+					foreach ($pall as $pvalue) {
1946
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1947
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1948
+							$find = true;
1949
+							break;
1950
+						}
1951
+					}
1952
+					if ($find === false) {
1953
+						$pall[] = $value;
1954
+					}
1955
+				}
1956
+				$alldata = $pall;
1957 1957
 			foreach ($alldata as $number) {
1958 1958
 				$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']);
1959 1959
 			}
@@ -2038,44 +2038,44 @@  discard block
 block discarded – undo
2038 2038
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2039 2039
 				}
2040 2040
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2041
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2042
-		        	$alldata = array();
2043
-	    			foreach ($pall as $value) {
2044
-		        		$icao = $value['airport_departure_icao'];
2045
-    					$alldata[$icao] = $value;
2046
-	    			}
2047
-		        	foreach ($dall as $value) {
2048
-	    				$icao = $value['airport_departure_icao'];
2049
-        				if (isset($alldata[$icao])) {
2050
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2051
-        				} else $alldata[$icao] = $value;
2052
-				}
2053
-	    			$count = array();
2054
-    				foreach ($alldata as $key => $row) {
2055
-    					$count[$key] = $row['airport_departure_icao_count'];
2056
-    				}
2041
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2042
+					$alldata = array();
2043
+					foreach ($pall as $value) {
2044
+						$icao = $value['airport_departure_icao'];
2045
+						$alldata[$icao] = $value;
2046
+					}
2047
+					foreach ($dall as $value) {
2048
+						$icao = $value['airport_departure_icao'];
2049
+						if (isset($alldata[$icao])) {
2050
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2051
+						} else $alldata[$icao] = $value;
2052
+				}
2053
+					$count = array();
2054
+					foreach ($alldata as $key => $row) {
2055
+						$count[$key] = $row['airport_departure_icao_count'];
2056
+					}
2057 2057
 				array_multisort($count,SORT_DESC,$alldata);
2058 2058
 				foreach ($alldata as $number) {
2059
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
2059
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
2060 2060
 				}
2061 2061
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2062
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2062
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2063 2063
 				$alldata = array();
2064
-    				foreach ($pall as $value) {
2065
-		        		$icao = $value['airport_arrival_icao'];
2066
-    					$alldata[$icao] = $value;
2067
-	    			}
2068
-		        	foreach ($dall as $value) {
2069
-	    				$icao = $value['airport_arrival_icao'];
2070
-        				if (isset($alldata[$icao])) {
2071
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2072
-		        		} else $alldata[$icao] = $value;
2073
-	    			}
2074
-        			$count = array();
2075
-        			foreach ($alldata as $key => $row) {
2076
-    					$count[$key] = $row['airport_arrival_icao_count'];
2077
-		        	}
2078
-        			array_multisort($count,SORT_DESC,$alldata);
2064
+					foreach ($pall as $value) {
2065
+						$icao = $value['airport_arrival_icao'];
2066
+						$alldata[$icao] = $value;
2067
+					}
2068
+					foreach ($dall as $value) {
2069
+						$icao = $value['airport_arrival_icao'];
2070
+						if (isset($alldata[$icao])) {
2071
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2072
+						} else $alldata[$icao] = $value;
2073
+					}
2074
+					$count = array();
2075
+					foreach ($alldata as $key => $row) {
2076
+						$count[$key] = $row['airport_arrival_icao_count'];
2077
+					}
2078
+					array_multisort($count,SORT_DESC,$alldata);
2079 2079
 				foreach ($alldata as $number) {
2080 2080
 					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
2081 2081
 				}
@@ -2108,45 +2108,45 @@  discard block
 block discarded – undo
2108 2108
 				}
2109 2109
 				echo '...Departure'."\n";
2110 2110
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
2111
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2111
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2112 2112
 				foreach ($dall as $value) {
2113
-    					$icao = $value['departure_airport_icao'];
2114
-    					$ddate = $value['date'];
2115
-    					$find = false;
2116
-    					foreach ($pall as $pvalue) {
2117
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2118
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
2119
-	    						$find = true;
2120
-    							break;
2121
-    						}
2122
-    					}
2123
-    					if ($find === false) {
2124
-    						$pall[] = $value;
2125
-	    				}
2126
-    				}
2127
-	    			$alldata = $pall;
2113
+						$icao = $value['departure_airport_icao'];
2114
+						$ddate = $value['date'];
2115
+						$find = false;
2116
+						foreach ($pall as $pvalue) {
2117
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2118
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
2119
+								$find = true;
2120
+								break;
2121
+							}
2122
+						}
2123
+						if ($find === false) {
2124
+							$pall[] = $value;
2125
+						}
2126
+					}
2127
+					$alldata = $pall;
2128 2128
 				foreach ($alldata as $number) {
2129 2129
 					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
2130 2130
 				}
2131 2131
 				echo '...Arrival'."\n";
2132 2132
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2133
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2133
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2134 2134
 				foreach ($dall as $value) {
2135 2135
 					$icao = $value['arrival_airport_icao'];
2136 2136
 					$ddate = $value['date'];
2137
-    					$find = false;
2137
+						$find = false;
2138 2138
 					foreach ($pall as $pvalue) {
2139
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2140
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2141
-    							$find = true;
2142
-    							break;
2143
-	    					}
2144
-    					}
2145
-    					if ($find === false) {
2146
-    						$pall[] = $value;
2147
-	    				}
2148
-    				}
2149
-    				$alldata = $pall;
2139
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2140
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2141
+								$find = true;
2142
+								break;
2143
+							}
2144
+						}
2145
+						if ($find === false) {
2146
+							$pall[] = $value;
2147
+						}
2148
+					}
2149
+					$alldata = $pall;
2150 2150
 				foreach ($alldata as $number) {
2151 2151
 					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
2152 2152
 				}
Please login to merge, or discard this patch.