Completed
Push — master ( 9276af...006240 )
by Yannick
06:15
created
statistics-sub-menu.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 		</form>
33 33
 	</div>
34 34
 <?php 
35
-    if (!isset($year) || (isset($year) && $year == '') && !isset($month) || (isset($month) && $month == '')) {
35
+	if (!isset($year) || (isset($year) && $year == '') && !isset($month) || (isset($month) && $month == '')) {
36 36
 ?>
37 37
 <div class="sub-menu sub-menu-container">
38 38
 	<ul class="nav">
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		    </ul>
88 88
 		</li>
89 89
 		<?php
90
-		    if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
90
+			if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
91 91
 		?>
92 92
 		<li class="dropdown">
93 93
 		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
 		    </ul>
100 100
 		</li>
101 101
 		<?php
102
-		    }
102
+			}
103 103
 		?>
104 104
 	</ul>
105 105
 </div>
106 106
 <?php
107
-    } else {
107
+	} else {
108 108
 ?>
109 109
 <div class="sub-menu sub-menu-container">
110 110
 	<ul class="nav">
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		</li>
164 164
 		-->
165 165
 		<?php
166
-		    if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
166
+			if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
167 167
 		?>
168 168
 		<!--
169 169
 		<li class="dropdown">
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 		</li>
178 178
 		-->
179 179
 		<?php
180
-		    }
180
+			}
181 181
 		?>
182 182
 	</ul>
183 183
 </div>
184 184
 <?php
185
-    }
185
+	}
186 186
 ?>
187 187
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 					} else {
21 21
 						print '<option value="all">All</option>';
22 22
 					}
23
-					foreach($airlines as $airline) {
23
+					foreach ($airlines as $airline) {
24 24
 						if (isset($airline_icao) && $airline_icao == $airline['airline_icao']) {
25 25
 							print '<option value="'.$airline['airline_icao'].'" selected>'.$airline['airline_name'].'</option>';
26 26
 						} else {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 <div class="sub-menu sub-menu-container">
38 38
 	<ul class="nav">
39 39
 		<li class="dropdown">
40
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" >
40
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" >
41 41
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
42 42
 		    </a>
43 43
 		    <ul class="dropdown-menu">
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		    </ul>
49 49
 		</li>
50 50
 		<li class="dropdown">
51
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
51
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#">
52 52
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
53 53
 		    </a>
54 54
 		    <ul class="dropdown-menu" role="menu">
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		    </ul>
59 59
 		</li>
60 60
 		<li class="dropdown">
61
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
61
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
62 62
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
63 63
 		    </a>
64 64
 		    <ul class="dropdown-menu" role="menu">
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		    </ul>
70 70
 		</li>
71 71
 		<li class="dropdown">
72
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
72
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#">
73 73
 		      <?php echo _("Route"); ?> <span class="caret"></span>
74 74
 		    </a>
75 75
 		    <ul class="dropdown-menu" role="menu">
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		    </ul>
79 79
 		</li>
80 80
 		<li class="dropdown">
81
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
81
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
82 82
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
83 83
 		    </a>
84 84
 		    <ul class="dropdown-menu" role="menu">
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		    if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
91 91
 		?>
92 92
 		<li class="dropdown">
93
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
93
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#">
94 94
 		      <?php echo _("Fatalities"); ?> <span class="caret"></span>
95 95
 		    </a>
96 96
 		    <ul class="dropdown-menu" role="menu">
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 <div class="sub-menu sub-menu-container">
110 110
 	<ul class="nav">
111 111
 		<li class="dropdown">
112
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" >
112
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" >
113 113
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
114 114
 		    </a>
115 115
 		    <ul class="dropdown-menu">
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		    </ul>
121 121
 		</li>
122 122
 		<li class="dropdown">
123
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
123
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#">
124 124
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
125 125
 		    </a>
126 126
 		    <ul class="dropdown-menu" role="menu">
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		    </ul>
131 131
 		</li>
132 132
 		<li class="dropdown">
133
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
133
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
134 134
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
135 135
 		    </a>
136 136
 		    <ul class="dropdown-menu" role="menu">
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		</li>
143 143
 		<!--
144 144
 		<li class="dropdown">
145
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
145
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#">
146 146
 		      <?php echo _("Route"); ?> <span class="caret"></span>
147 147
 		    </a>
148 148
 		    <ul class="dropdown-menu" role="menu">
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		-->
154 154
 		<!--
155 155
 		<li class="dropdown">
156
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
156
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
157 157
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
158 158
 		    </a>
159 159
 		    <ul class="dropdown-menu" role="menu">
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		?>
168 168
 		<!--
169 169
 		<li class="dropdown">
170
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
170
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#">
171 171
 		      <?php echo _("Fatalities"); ?> <span class="caret"></span>
172 172
 		    </a>
173 173
 		    <ul class="dropdown-menu" role="menu">
Please login to merge, or discard this patch.
Braces   +110 added lines, -27 removed lines patch added patch discarded remove patch
@@ -4,7 +4,13 @@  discard block
 block discarded – undo
4 4
 	<div class="stats_airline">
5 5
 	
6 6
 		<form id="changedate" method="post">
7
-			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') echo $year.'-'; ?><?php if (isset($month) && $month != '') echo $month; ?>" />
7
+			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') {
8
+	echo $year.'-';
9
+}
10
+?><?php if (isset($month) && $month != '') {
11
+	echo $month;
12
+}
13
+?>" />
8 14
 		</form>
9 15
 	
10 16
 		<form id="changeairline" method="post">
@@ -13,7 +19,9 @@  discard block
 block discarded – undo
13 19
 				<?php
14 20
 					require_once('require/class.Stats.php');
15 21
 					$Stats = new Stats();
16
-					if (!isset($filter_name)) $filter_name = '';
22
+					if (!isset($filter_name)) {
23
+						$filter_name = '';
24
+					}
17 25
 					$airlines = $Stats->getAllAirlineNames($filter_name);
18 26
 					if (isset($airline_icao) && ($airline_icao == '' || $airline_icao == 'all')) {
19 27
 						print '<option value="all" selected>All</option>';
@@ -41,10 +49,22 @@  discard block
 block discarded – undo
41 49
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
42 50
 		    </a>
43 51
 		    <ul class="dropdown-menu">
44
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Aircraft"); ?></a></li>
45
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Registration"); ?></a></li>
46
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Manufacturer"); ?></a></li>
47
-			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Country"); ?></a></li>
52
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
53
+	echo '/'.$airline_icao;
54
+}
55
+?>"><?php echo _("Aircraft"); ?></a></li>
56
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
57
+	echo '/'.$airline_icao;
58
+}
59
+?>"><?php echo _("Registration"); ?></a></li>
60
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
61
+	echo '/'.$airline_icao;
62
+}
63
+?>"><?php echo _("Manufacturer"); ?></a></li>
64
+			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
65
+	echo '/'.$airline_icao;
66
+}
67
+?>"><?php echo _("Country"); ?></a></li>
48 68
 		    </ul>
49 69
 		</li>
50 70
 		<li class="dropdown">
@@ -52,9 +72,18 @@  discard block
 block discarded – undo
52 72
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
53 73
 		    </a>
54 74
 		    <ul class="dropdown-menu" role="menu">
55
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline"); ?></a></li>
56
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline by Country"); ?></a></li>
57
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Callsign"); ?></a></li>
75
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
76
+	echo '/'.$airline_icao;
77
+}
78
+?>"><?php echo _("Airline"); ?></a></li>
79
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
80
+	echo '/'.$airline_icao;
81
+}
82
+?>"><?php echo _("Airline by Country"); ?></a></li>
83
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
84
+	echo '/'.$airline_icao;
85
+}
86
+?>"><?php echo _("Callsign"); ?></a></li>
58 87
 		    </ul>
59 88
 		</li>
60 89
 		<li class="dropdown">
@@ -62,10 +91,22 @@  discard block
 block discarded – undo
62 91
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
63 92
 		    </a>
64 93
 		    <ul class="dropdown-menu" role="menu">
65
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport"); ?></a></li>
66
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
67
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport"); ?></a></li>
68
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
94
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
95
+	echo '/'.$airline_icao;
96
+}
97
+?>"><?php echo _("Departure Airport"); ?></a></li>
98
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
99
+	echo '/'.$airline_icao;
100
+}
101
+?>"><?php echo _("Departure Airport by Country"); ?></a></li>
102
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
103
+	echo '/'.$airline_icao;
104
+}
105
+?>"><?php echo _("Arrival Airport"); ?></a></li>
106
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
107
+	echo '/'.$airline_icao;
108
+}
109
+?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
69 110
 		    </ul>
70 111
 		</li>
71 112
 		<li class="dropdown">
@@ -73,8 +114,14 @@  discard block
 block discarded – undo
73 114
 		      <?php echo _("Route"); ?> <span class="caret"></span>
74 115
 		    </a>
75 116
 		    <ul class="dropdown-menu" role="menu">
76
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Airport"); ?></a></li>
77
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Waypoint"); ?></a></li>
117
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
118
+	echo '/'.$airline_icao;
119
+}
120
+?>"><?php echo _("Route by Airport"); ?></a></li>
121
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
122
+	echo '/'.$airline_icao;
123
+}
124
+?>"><?php echo _("Route by Waypoint"); ?></a></li>
78 125
 		    </ul>
79 126
 		</li>
80 127
 		<li class="dropdown">
@@ -82,8 +129,14 @@  discard block
 block discarded – undo
82 129
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
83 130
 		    </a>
84 131
 		    <ul class="dropdown-menu" role="menu">
85
-		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Date"); ?></a></li>
86
-			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Time"); ?></a></li>
132
+		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
133
+	echo '/'.$airline_icao;
134
+}
135
+?>"><?php echo _("Date"); ?></a></li>
136
+			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
137
+	echo '/'.$airline_icao;
138
+}
139
+?>"><?php echo _("Time"); ?></a></li>
87 140
 		    </ul>
88 141
 		</li>
89 142
 		<?php
@@ -113,9 +166,18 @@  discard block
 block discarded – undo
113 166
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
114 167
 		    </a>
115 168
 		    <ul class="dropdown-menu">
116
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
117
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
118
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
169
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
170
+	echo '/'.$airline_icao;
171
+}
172
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
173
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
174
+	echo '/'.$airline_icao;
175
+}
176
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
177
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
178
+	echo '/'.$airline_icao;
179
+}
180
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
119 181
 			<!-- <li><a href="<?php print $globalURL; ?>/statistics/country"><?php echo _("Country"); ?></a></li> -->
120 182
 		    </ul>
121 183
 		</li>
@@ -124,9 +186,18 @@  discard block
 block discarded – undo
124 186
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
125 187
 		    </a>
126 188
 		    <ul class="dropdown-menu" role="menu">
127
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
128
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
129
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
189
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
190
+	echo '/'.$airline_icao;
191
+}
192
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
193
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
194
+	echo '/'.$airline_icao;
195
+}
196
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
197
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
198
+	echo '/'.$airline_icao;
199
+}
200
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
130 201
 		    </ul>
131 202
 		</li>
132 203
 		<li class="dropdown">
@@ -134,10 +205,22 @@  discard block
 block discarded – undo
134 205
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
135 206
 		    </a>
136 207
 		    <ul class="dropdown-menu" role="menu">
137
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
138
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
139
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
140
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
208
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
209
+	echo '/'.$airline_icao;
210
+}
211
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
212
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
213
+	echo '/'.$airline_icao;
214
+}
215
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
216
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
217
+	echo '/'.$airline_icao;
218
+}
219
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
220
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
221
+	echo '/'.$airline_icao;
222
+}
223
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
141 224
 		    </ul>
142 225
 		</li>
143 226
 		<!--
Please login to merge, or discard this patch.
statistics-pilot.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 if (!isset($filter_name)) $filter_name = '';
9 9
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
11
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/');
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
           function drawChart() {
31 31
             var data = google.visualization.arrayToDataTable([
32 32
             	["'._("Pilot").'", "'._("# of times").'"], ';
33
-            	$pilot_data = '';
33
+				$pilot_data = '';
34 34
 		foreach($pilot_array as $pilot_item)
35 35
 		{
36 36
 			$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
37 37
 		}
38 38
 		$pilot_data = substr($pilot_data, 0, -1);
39 39
 		print $pilot_data;
40
-            print ']);
40
+			print ']);
41 41
     
42 42
             var options = {
43 43
             	chartArea: {"width": "80%", "height": "60%"},
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Pilots");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11 11
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13
-setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/');
14
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
13
+setcookie('stats_airline_icao', $airline_icao, time() + 60*60*24, '/');
14
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
15
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
16 16
 require_once('header.php');
17 17
 include('statistics-sub-menu.php');
18 18
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	</div>
23 23
 	<p>'._("Below are the <strong>Top 10</strong> most common pilot.").'</p>';
24 24
 	  
25
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
25
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
26 26
 	print '<div id="chart" class="chart" width="100%"></div>
27 27
       	<script> 
28 28
       		google.load("visualization", "1", {packages:["corechart"]});
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
             var data = google.visualization.arrayToDataTable([
32 32
             	["'._("Pilot").'", "'._("# of times").'"], ';
33 33
             	$pilot_data = '';
34
-		foreach($pilot_array as $pilot_item)
34
+		foreach ($pilot_array as $pilot_item)
35 35
 		{
36 36
 			$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
37 37
 		}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	print '</thead>';
65 65
 	print '<tbody>';
66 66
 	$i = 1;
67
-	foreach($pilot_array as $pilot_item)
67
+	foreach ($pilot_array as $pilot_item)
68 68
 	{
69 69
 		print '<tr>';
70 70
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,11 +5,15 @@
 block discarded – undo
5 5
 $Stats = new Stats();
6 6
 $title = _("Statistics").' - '._("Most common Pilots");
7 7
 
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 12
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12
-}
13
+    if (isset($globalFilter['airline'])) {
14
+    	$airline_icao = $globalFilter['airline'][0];
15
+    }
16
+    }
13 17
 setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/');
14 18
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 19
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
require/class.METAR.php 3 patches
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -7,109 +7,109 @@  discard block
 block discarded – undo
7 7
 	public $db;
8 8
 	
9 9
 	protected $texts = Array(
10
-	    'MI' => 'Shallow',
11
-	    'PR' => 'Partial',
12
-	    'BC' => 'Low drifting',
13
-	    'BL' => 'Blowing',
14
-	    'SH' => 'Showers',
15
-	    'TS' => 'Thunderstorm',
16
-	    'FZ' => 'Freezing',
17
-	    'DZ' => 'Drizzle',
18
-	    'RA' => 'Rain',
19
-	    'SN' => 'Snow',
20
-	    'SG' => 'Snow Grains',
21
-	    'IC' => 'Ice crystals',
22
-	    'PL' => 'Ice pellets',
23
-	    'GR' => 'Hail',
24
-	    'GS' => 'Small hail',
25
-	    'UP' => 'Unknown',
26
-	    'BR' => 'Mist',
27
-	    'FG' => 'Fog',
28
-	    'FU' => 'Smoke',
29
-	    'VA' => 'Volcanic ash',
30
-	    'DU' => 'Widespread dust',
31
-	    'SA' => 'Sand',
32
-	    'HZ' => 'Haze',
33
-	    'PY' => 'Spray',
34
-	    'PO' => 'Well developed dust / sand whirls',
35
-	    'SQ' => 'Squalls',
36
-	    'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
-	    'SS' => 'Sandstorm',
38
-	    'DS' => 'Duststorm'
10
+		'MI' => 'Shallow',
11
+		'PR' => 'Partial',
12
+		'BC' => 'Low drifting',
13
+		'BL' => 'Blowing',
14
+		'SH' => 'Showers',
15
+		'TS' => 'Thunderstorm',
16
+		'FZ' => 'Freezing',
17
+		'DZ' => 'Drizzle',
18
+		'RA' => 'Rain',
19
+		'SN' => 'Snow',
20
+		'SG' => 'Snow Grains',
21
+		'IC' => 'Ice crystals',
22
+		'PL' => 'Ice pellets',
23
+		'GR' => 'Hail',
24
+		'GS' => 'Small hail',
25
+		'UP' => 'Unknown',
26
+		'BR' => 'Mist',
27
+		'FG' => 'Fog',
28
+		'FU' => 'Smoke',
29
+		'VA' => 'Volcanic ash',
30
+		'DU' => 'Widespread dust',
31
+		'SA' => 'Sand',
32
+		'HZ' => 'Haze',
33
+		'PY' => 'Spray',
34
+		'PO' => 'Well developed dust / sand whirls',
35
+		'SQ' => 'Squalls',
36
+		'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
+		'SS' => 'Sandstorm',
38
+		'DS' => 'Duststorm'
39 39
 	);
40 40
 	
41 41
 	public function __construct($dbc = null) {
42
-                $Connection = new Connection($dbc);
43
-                $this->db = $Connection->db;
44
-        }
42
+				$Connection = new Connection($dbc);
43
+				$this->db = $Connection->db;
44
+		}
45 45
 
46
-       public static function check_last_update() {
47
-    		global $globalDBdriver;
48
-    		if ($globalDBdriver == 'mysql') {
46
+	   public static function check_last_update() {
47
+			global $globalDBdriver;
48
+			if ($globalDBdriver == 'mysql') {
49 49
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(NOW(), INTERVAL 20 MINUTE)";
50 50
 		} else {
51 51
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '20 MINUTES'";
52 52
 		}
53
-                try {
54
-                        $Connection = new Connection();
55
-                        $sth = $Connection->db->prepare($query);
56
-                        $sth->execute();
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
61
-                $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
64
-        }
53
+				try {
54
+						$Connection = new Connection();
55
+						$sth = $Connection->db->prepare($query);
56
+						$sth->execute();
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
61
+				$sth->closeCursor();
62
+				if ($row['nb'] > 0) return false;
63
+				else return true;
64
+		}
65 65
 
66
-        public static function insert_last_update() {
67
-                $query = "DELETE FROM config WHERE name = 'last_update_metar';
66
+		public static function insert_last_update() {
67
+				$query = "DELETE FROM config WHERE name = 'last_update_metar';
68 68
                         INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());";
69
-                try {
70
-                        $Connection = new Connection();
71
-                        $sth = $Connection->db->prepare($query);
72
-                        $sth->execute();
73
-                } catch(PDOException $e) {
74
-                        return "error : ".$e->getMessage();
75
-                }
76
-        }
69
+				try {
70
+						$Connection = new Connection();
71
+						$sth = $Connection->db->prepare($query);
72
+						$sth->execute();
73
+				} catch(PDOException $e) {
74
+						return "error : ".$e->getMessage();
75
+				}
76
+		}
77 77
 
78 78
 
79 79
         
80
-        public function parse($data) {
81
-    		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
-    		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
-    		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
86
-    		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
-    		$result = array();
91
-    		$result['location'] = $pieces[$pos];
92
-    		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
95
-    		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
97
-    			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
101
-    			// Wind Speed
102
-    			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
80
+		public function parse($data) {
81
+			//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
+			$codes = implode('|', array_keys($this->texts));
83
+			$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
+			//$pieces = explode(' ',$data);
85
+			$pieces = preg_split('/\s/',$data);
86
+			$pos = 0;
87
+			if ($pieces[0] == 'METAR') $pos++;
88
+			elseif ($pieces[0] == 'SPECI') $pos++;
89
+			if (strlen($pieces[$pos]) != 4) $pos++;
90
+			$result = array();
91
+			$result['location'] = $pieces[$pos];
92
+			$pos++;
93
+			$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
+			$result['time'] = substr($pieces[$pos],2,4);
95
+			$c = count($pieces);
96
+			for($pos++; $pos < $c; $pos++) {
97
+				$piece = $pieces[$pos];
98
+				if ($piece == 'RMK') break;
99
+				if ($piece == 'AUTO') $result['auto'] = true;
100
+				if ($piece == 'COR') $result['correction'] = true;
101
+				// Wind Speed
102
+				if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
+					$result['wind']['direction'] = (float)$matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
105
+					if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
+					elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
+					elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108 108
 				$result['wind']['gust'] = (float)$matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110 110
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111 111
 				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
112
-    			}
112
+				}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
115 115
     				$result['wind_direction'] = (float)$matches[1];
@@ -126,35 +126,35 @@  discard block
 block discarded – undo
126 126
     				}
127 127
     			}
128 128
     			*/
129
-    			// Temperature
130
-    			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
129
+				// Temperature
130
+				if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
+					$temp = (float)$matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133 133
 					$temp = ((float)substr($matches[1], 1)) * -1;
134 134
 				}
135
-    				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
135
+					$result['temperature'] = $temp;
136
+					$dew = (float)$matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138 138
 					$dew = ((float)substr($matches[2], 1)) * -1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141
-    			}
142
-    			// QNH
143
-    			if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
-    			// #^(Q|A)(////|[0-9]{4})( )#
145
-    				if ($matches[1] == 'Q') {
146
-    					// hPa
147
-    					$result['QNH'] = $matches[2];
148
-    				} else {
149
-    					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151 141
 				}
152
-    				/*
142
+				// QNH
143
+				if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
+				// #^(Q|A)(////|[0-9]{4})( )#
145
+					if ($matches[1] == 'Q') {
146
+						// hPa
147
+						$result['QNH'] = $matches[2];
148
+					} else {
149
+						// inHg
150
+						$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151
+				}
152
+					/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
154 154
     				$result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg';
155 155
     				*/
156
-    			}
157
-                     /*
156
+				}
157
+					 /*
158 158
     			// Wind Direction
159 159
     			if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) {
160 160
     				$result['wind_direction'] = $matches[1];
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
     				$result['speed_variable'] = $matches[1];
166 166
     			}
167 167
     			*/
168
-    			// Visibility
169
-    			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
-    				if (isset($matches[3]) && strlen($matches[3]) > 0) {
168
+				// Visibility
169
+				if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
+					if (isset($matches[3]) && strlen($matches[3]) > 0) {
171 171
 					$result['visibility'] = (float)$matches[3] * 1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
@@ -180,28 +180,28 @@  discard block
 block discarded – undo
180 180
 					$result['visibility'] = '> 10000';
181 181
 					$result['weather'] = "CAVOK";
182 182
 				}
183
-    			}
184
-    			// Cloud Coverage
185
-    			if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
-    				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
-    				$type = $matches[1];
188
-    				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
-    				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
-    				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
-    				$result['cloud'][] = $cloud;
201
-    			}
202
-    			// RVR
203
-    			 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
-    				$rvr = array();
183
+				}
184
+				// Cloud Coverage
185
+				if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
+					//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
+					$type = $matches[1];
188
+					$cloud = array();
189
+					if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
+					elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
+					elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
+					elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
+					elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
+					elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
+					elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
+					elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
+					$cloud['type_code'] = $type;
198
+					$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
+					$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
+					$result['cloud'][] = $cloud;
201
+				}
202
+				// RVR
203
+				 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
+					$rvr = array();
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
@@ -210,33 +210,33 @@  discard block
 block discarded – undo
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
213
-    			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
-    			if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
-    				//print_r($matches);
216
-    				// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
-    				$result['RVR']['runway'] = $matches[1];
218
-        			$result['RVR']['deposits'] = $matches[2];
219
-        			$result['RVR']['extent'] = $matches[3];
220
-        			$result['RVR']['depth'] = $matches[4];
221
-        			$result['RVR']['friction'] = $matches[5];
222
-    			}
223
-    			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
-    				//echo $piece;
225
-    				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
213
+				//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
+				if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
+					//print_r($matches);
216
+					// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
+					$result['RVR']['runway'] = $matches[1];
218
+					$result['RVR']['deposits'] = $matches[2];
219
+					$result['RVR']['extent'] = $matches[3];
220
+					$result['RVR']['depth'] = $matches[4];
221
+					$result['RVR']['friction'] = $matches[5];
222
+				}
223
+				if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
+					//echo $piece;
225
+					//print_r($matches);
226
+					if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+					else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
232
-					    'unit' => $matches[5] ? 'FT' : 'M'
230
+						'from' => (float)$matches[2],
231
+						'to'   => (float)$matches[4],
232
+						'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
235 235
 				$result['RVR'] = $matches[1];
236 236
 				$result['RVR_range'] = $range;
237
-    			}
238
-    			// Weather
239
-    			if (preg_match($regWeather, $piece, $matches)) {
237
+				}
238
+				// Weather
239
+				if (preg_match($regWeather, $piece, $matches)) {
240 240
 				$text = Array();
241 241
 				switch ($matches[1]) {
242 242
 					case '+':
@@ -259,35 +259,35 @@  discard block
 block discarded – undo
259 259
 				}
260 260
 				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261 261
 				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
262
-    			}
263
-    		}
264
-    		return $result;
262
+				}
263
+			}
264
+			return $result;
265 265
         
266
-        }
266
+		}
267 267
         
268 268
 	public function getMETAR($icao) {
269
-    		global $globalMETARcycle, $globalDBdriver;
270
-    		if (isset($globalMETARcycle) && $globalMETARcycle) {
271
-            		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
-                } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
-                }
276
-                $query_values = array(':icao' => $icao);
277
-                 try {
278
-                        $sth = $this->db->prepare($query);
279
-                        $sth->execute($query_values);
280
-                } catch(PDOException $e) {
281
-                        return "error : ".$e->getMessage();
282
-                }
283
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
-                if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
-            		$all = $this->downloadMETAR($icao);
286
-                }
287
-                return $all;
288
-        }
269
+			global $globalMETARcycle, $globalDBdriver;
270
+			if (isset($globalMETARcycle) && $globalMETARcycle) {
271
+					$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
+				} else {
273
+					if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
+					else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
+				}
276
+				$query_values = array(':icao' => $icao);
277
+				 try {
278
+						$sth = $this->db->prepare($query);
279
+						$sth->execute($query_values);
280
+				} catch(PDOException $e) {
281
+						return "error : ".$e->getMessage();
282
+				}
283
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
+					$all = $this->downloadMETAR($icao);
286
+				}
287
+				return $all;
288
+		}
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+	   public function addMETAR($location,$metar,$date) {
291 291
 		global $globalDBdriver;
292 292
 		$date = date('Y-m-d H:i:s',strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
@@ -295,106 +295,106 @@  discard block
 block discarded – undo
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
-                 try {
300
-                        $sth = $this->db->prepare($query);
301
-                        $sth->execute($query_values);
302
-                } catch(PDOException $e) {
303
-                        return "error : ".$e->getMessage();
304
-                }
305
-        }
298
+				$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
+				 try {
300
+						$sth = $this->db->prepare($query);
301
+						$sth->execute($query_values);
302
+				} catch(PDOException $e) {
303
+						return "error : ".$e->getMessage();
304
+				}
305
+		}
306 306
 
307
-       public function deleteMETAR($id) {
308
-                $query = "DELETE FROM metar WHERE id = :id";
309
-                $query_values = array(':id' => $id);
310
-                 try {
311
-                        $sth = $this->db->prepare($query);
312
-                        $sth->execute($query_values);
313
-                } catch(PDOException $e) {
314
-                        return "error : ".$e->getMessage();
315
-                }
316
-        }
317
-       public function deleteAllMETARLocation() {
318
-                $query = "DELETE FROM metar";
319
-                 try {
320
-                        $sth = $this->db->prepare($query);
321
-                        $sth->execute();
322
-                } catch(PDOException $e) {
323
-                        return "error : ".$e->getMessage();
324
-                }
325
-        }
307
+	   public function deleteMETAR($id) {
308
+				$query = "DELETE FROM metar WHERE id = :id";
309
+				$query_values = array(':id' => $id);
310
+				 try {
311
+						$sth = $this->db->prepare($query);
312
+						$sth->execute($query_values);
313
+				} catch(PDOException $e) {
314
+						return "error : ".$e->getMessage();
315
+				}
316
+		}
317
+	   public function deleteAllMETARLocation() {
318
+				$query = "DELETE FROM metar";
319
+				 try {
320
+						$sth = $this->db->prepare($query);
321
+						$sth->execute();
322
+				} catch(PDOException $e) {
323
+						return "error : ".$e->getMessage();
324
+				}
325
+		}
326 326
         
327
-        public function addMETARCycle() {
328
-    		global $globalDebug, $globalIVAO, $globalTransaction;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
-    		date_default_timezone_set("UTC");
331
-    		$Common = new Common();
332
-    		if (isset($globalIVAO) && $globalIVAO) {
333
-        		//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
327
+		public function addMETARCycle() {
328
+			global $globalDebug, $globalIVAO, $globalTransaction;
329
+			if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
+			date_default_timezone_set("UTC");
331
+			$Common = new Common();
332
+			if (isset($globalIVAO) && $globalIVAO) {
333
+				//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334 334
 			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
336
-    		} else {
335
+				$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
336
+			} else {
337 337
 			//$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
338 338
 			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340
-    		}
341
-    		if ($handle) {
339
+				$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340
+			}
341
+			if ($handle) {
342 342
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
343 343
 			$date = '';
344
-    			//foreach(explode("\n",$cycle) as $line) {
345
-    			if ($globalTransaction) $this->db->beginTransaction();
346
-	    		while(($line = fgets($handle,4096)) !== false) {
344
+				//foreach(explode("\n",$cycle) as $line) {
345
+				if ($globalTransaction) $this->db->beginTransaction();
346
+				while(($line = fgets($handle,4096)) !== false) {
347 347
 				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
348 348
 					$date = $line;
349
-    				} elseif ($line != '') {
350
-    				    //$this->parse($line);
351
-    				    if ($date == '') $date = date('Y/m/d H:m');
352
-        			    $pos = 0;
353
-        			    $pieces = preg_split('/\s/',$line);
354
-        			    if ($pieces[0] == 'METAR') $pos++;
355
-        			    if (strlen($pieces[$pos]) != 4) $pos++;
356
-		        	    $location = $pieces[$pos];
357
-        	        	    echo $this->addMETAR($location,$line,$date);
358
-    				}
359
-    			}
360
-    			fclose($handle);
361
-    			if ($globalTransaction) $this->db->commit();
362
-    		}
363
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
349
+					} elseif ($line != '') {
350
+						//$this->parse($line);
351
+						if ($date == '') $date = date('Y/m/d H:m');
352
+						$pos = 0;
353
+						$pieces = preg_split('/\s/',$line);
354
+						if ($pieces[0] == 'METAR') $pos++;
355
+						if (strlen($pieces[$pos]) != 4) $pos++;
356
+						$location = $pieces[$pos];
357
+							echo $this->addMETAR($location,$line,$date);
358
+					}
359
+				}
360
+				fclose($handle);
361
+				if ($globalTransaction) $this->db->commit();
362
+			}
363
+			if (isset($globalDebug) && $globalDebug) echo "Done\n";
364 364
         
365
-        }
366
-        public function downloadMETAR($icao) {
367
-    		global $globalMETARurl;
368
-    		if ($globalMETARurl == '') return array();
369
-    		date_default_timezone_set("UTC");
370
-    		$Common = new Common();
371
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
372
-    		$cycle = $Common->getData($url);
373
-    		$date = '';
374
-    		foreach(explode("\n",$cycle) as $line) {
375
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
376
-    				//echo "date : ".$line."\n";
377
-    				$date = $line;
378
-    			} 
379
-    			if ($line != '') {
380
-    			    //$this->parse($line);
381
-    			    //echo $line;
382
-    			    if ($date == '') $date = date('Y/m/d H:m');
383
-    			    $pos = 0;
384
-    			    $pieces = preg_split('/\s/',$line);
385
-    			    if ($pieces[0] == 'METAR') $pos++;
386
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
387
-	        	    $location = $pieces[$pos];
388
-	        	    if (strlen($location == 4)) {
389
-	        		$this->addMETAR($location,$line,$date);
390
-	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
-	        	    } else return array();
392
-    			}
393
-    			//echo $line."\n";
394
-    		}
395
-    		return array();
365
+		}
366
+		public function downloadMETAR($icao) {
367
+			global $globalMETARurl;
368
+			if ($globalMETARurl == '') return array();
369
+			date_default_timezone_set("UTC");
370
+			$Common = new Common();
371
+			$url = str_replace('{icao}',$icao,$globalMETARurl);
372
+			$cycle = $Common->getData($url);
373
+			$date = '';
374
+			foreach(explode("\n",$cycle) as $line) {
375
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
376
+					//echo "date : ".$line."\n";
377
+					$date = $line;
378
+				} 
379
+				if ($line != '') {
380
+					//$this->parse($line);
381
+					//echo $line;
382
+					if ($date == '') $date = date('Y/m/d H:m');
383
+					$pos = 0;
384
+					$pieces = preg_split('/\s/',$line);
385
+					if ($pieces[0] == 'METAR') $pos++;
386
+					if (strlen($pieces[$pos]) != 4) $pos++;
387
+					$location = $pieces[$pos];
388
+					if (strlen($location == 4)) {
389
+					$this->addMETAR($location,$line,$date);
390
+					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
+					} else return array();
392
+				}
393
+				//echo $line."\n";
394
+			}
395
+			return array();
396 396
         
397
-        }
397
+		}
398 398
 }
399 399
 /*
400 400
 $METAR = new METAR();
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                         $Connection = new Connection();
55 55
                         $sth = $Connection->db->prepare($query);
56 56
                         $sth->execute();
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                         $Connection = new Connection();
71 71
                         $sth = $Connection->db->prepare($query);
72 72
                         $sth->execute();
73
-                } catch(PDOException $e) {
73
+                } catch (PDOException $e) {
74 74
                         return "error : ".$e->getMessage();
75 75
                 }
76 76
         }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         public function parse($data) {
81 81
     		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82 82
     		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
83
+    		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
84 84
     		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
85
+    		$pieces = preg_split('/\s/', $data);
86 86
     		$pos = 0;
87 87
     		if ($pieces[0] == 'METAR') $pos++;
88 88
     		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
     		$result = array();
91 91
     		$result['location'] = $pieces[$pos];
92 92
     		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
93
+    		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
94
+    		$result['time'] = substr($pieces[$pos], 2, 4);
95 95
     		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
96
+    		for ($pos++; $pos < $c; $pos++) {
97 97
     			$piece = $pieces[$pos];
98 98
     			if ($piece == 'RMK') break;
99 99
     			if ($piece == 'AUTO') $result['auto'] = true;
100 100
     			if ($piece == 'COR') $result['correction'] = true;
101 101
     			// Wind Speed
102 102
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
103
+    				$result['wind']['direction'] = (float) $matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108
-				$result['wind']['gust'] = (float)$matches[3];
105
+    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
106
+    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
107
+    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
108
+				$result['wind']['gust'] = (float) $matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
110
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
111
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
112 112
     			}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
     			*/
129 129
     			// Temperature
130 130
     			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
131
+    				$temp = (float) $matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133
-					$temp = ((float)substr($matches[1], 1)) * -1;
133
+					$temp = ((float) substr($matches[1], 1))*-1;
134 134
 				}
135 135
     				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
136
+    				$dew = (float) $matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138
-					$dew = ((float)substr($matches[2], 1)) * -1;
138
+					$dew = ((float) substr($matches[2], 1))*-1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141 141
     			}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     					$result['QNH'] = $matches[2];
148 148
     				} else {
149 149
     					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
150
+    					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
151 151
 				}
152 152
     				/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
     			// Visibility
169 169
     			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170 170
     				if (isset($matches[3]) && strlen($matches[3]) > 0) {
171
-					$result['visibility'] = (float)$matches[3] * 1609.34;
171
+					$result['visibility'] = (float) $matches[3]*1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
174 174
 						$result['visibility'] = '> 10000';
175 175
 					} else {
176
-						$result['visibility'] = (float)$matches[1];
176
+						$result['visibility'] = (float) $matches[1];
177 177
 					}
178 178
 				}
179 179
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196 196
     				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197 197
     				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
198
+    				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
199 199
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200 200
     				$result['cloud'][] = $cloud;
201 201
     			}
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
208
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
209
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
208
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
209
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 224
     				//echo $piece;
225 225
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
226
+    				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+    				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
230
+					    'from' => (float) $matches[2],
231
+					    'to'   => (float) $matches[4],
232 232
 					    'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                  try {
278 278
                         $sth = $this->db->prepare($query);
279 279
                         $sth->execute($query_values);
280
-                } catch(PDOException $e) {
280
+                } catch (PDOException $e) {
281 281
                         return "error : ".$e->getMessage();
282 282
                 }
283 283
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -287,19 +287,19 @@  discard block
 block discarded – undo
287 287
                 return $all;
288 288
         }
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+       public function addMETAR($location, $metar, $date) {
291 291
 		global $globalDBdriver;
292
-		$date = date('Y-m-d H:i:s',strtotime($date));
292
+		$date = date('Y-m-d H:i:s', strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
294 294
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
298
+                $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
299 299
                  try {
300 300
                         $sth = $this->db->prepare($query);
301 301
                         $sth->execute($query_values);
302
-                } catch(PDOException $e) {
302
+                } catch (PDOException $e) {
303 303
                         return "error : ".$e->getMessage();
304 304
                 }
305 305
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
                  try {
311 311
                         $sth = $this->db->prepare($query);
312 312
                         $sth->execute($query_values);
313
-                } catch(PDOException $e) {
313
+                } catch (PDOException $e) {
314 314
                         return "error : ".$e->getMessage();
315 315
                 }
316 316
         }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                  try {
320 320
                         $sth = $this->db->prepare($query);
321 321
                         $sth->execute();
322
-                } catch(PDOException $e) {
322
+                } catch (PDOException $e) {
323 323
                         return "error : ".$e->getMessage();
324 324
                 }
325 325
         }
@@ -331,30 +331,30 @@  discard block
 block discarded – undo
331 331
     		$Common = new Common();
332 332
     		if (isset($globalIVAO) && $globalIVAO) {
333 333
         		//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334
-			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
334
+			$Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r");
336 336
     		} else {
337 337
 			//$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
338
-			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
338
+			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r");
340 340
     		}
341 341
     		if ($handle) {
342 342
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
343 343
 			$date = '';
344 344
     			//foreach(explode("\n",$cycle) as $line) {
345 345
     			if ($globalTransaction) $this->db->beginTransaction();
346
-	    		while(($line = fgets($handle,4096)) !== false) {
347
-				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
346
+	    		while (($line = fgets($handle, 4096)) !== false) {
347
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
348 348
 					$date = $line;
349 349
     				} elseif ($line != '') {
350 350
     				    //$this->parse($line);
351 351
     				    if ($date == '') $date = date('Y/m/d H:m');
352 352
         			    $pos = 0;
353
-        			    $pieces = preg_split('/\s/',$line);
353
+        			    $pieces = preg_split('/\s/', $line);
354 354
         			    if ($pieces[0] == 'METAR') $pos++;
355 355
         			    if (strlen($pieces[$pos]) != 4) $pos++;
356 356
 		        	    $location = $pieces[$pos];
357
-        	        	    echo $this->addMETAR($location,$line,$date);
357
+        	        	    echo $this->addMETAR($location, $line, $date);
358 358
     				}
359 359
     			}
360 360
     			fclose($handle);
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
     		if ($globalMETARurl == '') return array();
369 369
     		date_default_timezone_set("UTC");
370 370
     		$Common = new Common();
371
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
371
+    		$url = str_replace('{icao}', $icao, $globalMETARurl);
372 372
     		$cycle = $Common->getData($url);
373 373
     		$date = '';
374
-    		foreach(explode("\n",$cycle) as $line) {
375
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
374
+    		foreach (explode("\n", $cycle) as $line) {
375
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
376 376
     				//echo "date : ".$line."\n";
377 377
     				$date = $line;
378 378
     			} 
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
     			    //echo $line;
382 382
     			    if ($date == '') $date = date('Y/m/d H:m');
383 383
     			    $pos = 0;
384
-    			    $pieces = preg_split('/\s/',$line);
384
+    			    $pieces = preg_split('/\s/', $line);
385 385
     			    if ($pieces[0] == 'METAR') $pos++;
386 386
     			    if (strlen($pieces[$pos]) != 4) $pos++;
387 387
 	        	    $location = $pieces[$pos];
388 388
 	        	    if (strlen($location == 4)) {
389
-	        		$this->addMETAR($location,$line,$date);
389
+	        		$this->addMETAR($location, $line, $date);
390 390
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391 391
 	        	    } else return array();
392 392
     			}
Please login to merge, or discard this patch.
Braces   +100 added lines, -38 removed lines patch added patch discarded remove patch
@@ -59,8 +59,11 @@  discard block
 block discarded – undo
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
61 61
                 $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
62
+                if ($row['nb'] > 0) {
63
+                	return false;
64
+                } else {
65
+                	return true;
66
+                }
64 67
         }
65 68
 
66 69
         public static function insert_last_update() {
@@ -84,9 +87,14 @@  discard block
 block discarded – undo
84 87
     		//$pieces = explode(' ',$data);
85 88
     		$pieces = preg_split('/\s/',$data);
86 89
     		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
+    		if ($pieces[0] == 'METAR') {
91
+    			$pos++;
92
+    		} elseif ($pieces[0] == 'SPECI') {
93
+    			$pos++;
94
+    		}
95
+    		if (strlen($pieces[$pos]) != 4) {
96
+    			$pos++;
97
+    		}
90 98
     		$result = array();
91 99
     		$result['location'] = $pieces[$pos];
92 100
     		$pos++;
@@ -95,16 +103,26 @@  discard block
 block discarded – undo
95 103
     		$c = count($pieces);
96 104
     		for($pos++; $pos < $c; $pos++) {
97 105
     			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
106
+    			if ($piece == 'RMK') {
107
+    				break;
108
+    			}
109
+    			if ($piece == 'AUTO') {
110
+    				$result['auto'] = true;
111
+    			}
112
+    			if ($piece == 'COR') {
113
+    				$result['correction'] = true;
114
+    			}
101 115
     			// Wind Speed
102 116
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103 117
     				$result['wind']['direction'] = (float)$matches[1];
104 118
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
119
+    				if ($result['wind']['unit'] == 'KT') {
120
+    					$result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
121
+    				} elseif ($result['wind']['unit'] == 'KPH') {
122
+    					$result['wind']['speed'] = round(((float)$matches[2])*1000,2);
123
+    				} elseif ($result['wind']['unit'] == 'MPS') {
124
+    					$result['wind']['speed'] = round(((float)$matches[2]),2);
125
+    				}
108 126
 				$result['wind']['gust'] = (float)$matches[3];
109 127
 				$result['wind']['unit'] = $matches[4];
110 128
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
@@ -186,14 +204,23 @@  discard block
 block discarded – undo
186 204
     				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187 205
     				$type = $matches[1];
188 206
     				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
207
+    				if ($type == 'SKC') {
208
+    					$cloud['type'] = 'No cloud/Sky clear';
209
+    				} elseif ($type == 'CLR') {
210
+    					$cloud['type'] = 'No cloud below 12,000ft (3700m)';
211
+    				} elseif ($type == 'NSC') {
212
+    					$cloud['type'] = 'No significant cloud';
213
+    				} elseif ($type == 'FEW') {
214
+    					$cloud['type'] = 'Few';
215
+    				} elseif ($type == 'SCT') {
216
+    					$cloud['type'] = 'Scattered';
217
+    				} elseif ($type == 'BKN') {
218
+    					$cloud['type'] = 'Broken';
219
+    				} elseif ($type == 'OVC') {
220
+    					$cloud['type'] = 'Overcast/Full cloud coverage';
221
+    				} elseif ($type == 'VV') {
222
+    					$cloud['type'] = 'Vertical visibility';
223
+    				}
197 224
     				$cloud['type_code'] = $type;
198 225
     				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199 226
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
@@ -223,8 +250,11 @@  discard block
 block discarded – undo
223 250
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 251
     				//echo $piece;
225 252
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
253
+    				if (isset($matches[5])) {
254
+    					$range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
255
+    				} else {
256
+    					$range = array('exact' => (float)$matches[2], 'unit' => 'M');
257
+    				}
228 258
 				if (isset($matches[3])) {
229 259
 					$range = Array(
230 260
 					    'from' => (float)$matches[2],
@@ -257,8 +287,11 @@  discard block
 block discarded – undo
257 287
 				if (isset($matches[3])) {
258 288
 					$text[] = $this->texts[$matches[3]];
259 289
 				}
260
-				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261
-				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
290
+				if (!isset($result['weather'])) {
291
+					$result['weather'] = implode(' ', $text);
292
+				} else {
293
+					$result['weather'] = $result['weather'].' / '.implode(' ', $text);
294
+				}
262 295
     			}
263 296
     		}
264 297
     		return $result;
@@ -270,8 +303,11 @@  discard block
 block discarded – undo
270 303
     		if (isset($globalMETARcycle) && $globalMETARcycle) {
271 304
             		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272 305
                 } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
306
+            		if ($globalDBdriver == 'mysql') {
307
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
308
+            		} else {
309
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
310
+            		}
275 311
                 }
276 312
                 $query_values = array(':icao' => $icao);
277 313
                  try {
@@ -326,7 +362,9 @@  discard block
 block discarded – undo
326 362
         
327 363
         public function addMETARCycle() {
328 364
     		global $globalDebug, $globalIVAO, $globalTransaction;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
365
+    		if (isset($globalDebug) && $globalDebug) {
366
+    			echo "Downloading METAR cycle...";
367
+    		}
330 368
     		date_default_timezone_set("UTC");
331 369
     		$Common = new Common();
332 370
     		if (isset($globalIVAO) && $globalIVAO) {
@@ -339,33 +377,49 @@  discard block
 block discarded – undo
339 377
     			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340 378
     		}
341 379
     		if ($handle) {
342
-			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
380
+			if (isset($globalDebug) && $globalDebug) {
381
+				echo "Done - Updating DB...";
382
+			}
343 383
 			$date = '';
344 384
     			//foreach(explode("\n",$cycle) as $line) {
345
-    			if ($globalTransaction) $this->db->beginTransaction();
385
+    			if ($globalTransaction) {
386
+    				$this->db->beginTransaction();
387
+    			}
346 388
 	    		while(($line = fgets($handle,4096)) !== false) {
347 389
 				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
348 390
 					$date = $line;
349 391
     				} elseif ($line != '') {
350 392
     				    //$this->parse($line);
351
-    				    if ($date == '') $date = date('Y/m/d H:m');
393
+    				    if ($date == '') {
394
+    				    	$date = date('Y/m/d H:m');
395
+    				    }
352 396
         			    $pos = 0;
353 397
         			    $pieces = preg_split('/\s/',$line);
354
-        			    if ($pieces[0] == 'METAR') $pos++;
355
-        			    if (strlen($pieces[$pos]) != 4) $pos++;
398
+        			    if ($pieces[0] == 'METAR') {
399
+        			    	$pos++;
400
+        			    }
401
+        			    if (strlen($pieces[$pos]) != 4) {
402
+        			    	$pos++;
403
+        			    }
356 404
 		        	    $location = $pieces[$pos];
357 405
         	        	    echo $this->addMETAR($location,$line,$date);
358 406
     				}
359 407
     			}
360 408
     			fclose($handle);
361
-    			if ($globalTransaction) $this->db->commit();
409
+    			if ($globalTransaction) {
410
+    				$this->db->commit();
411
+    			}
412
+    		}
413
+    		if (isset($globalDebug) && $globalDebug) {
414
+    			echo "Done\n";
362 415
     		}
363
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
364 416
         
365 417
         }
366 418
         public function downloadMETAR($icao) {
367 419
     		global $globalMETARurl;
368
-    		if ($globalMETARurl == '') return array();
420
+    		if ($globalMETARurl == '') {
421
+    			return array();
422
+    		}
369 423
     		date_default_timezone_set("UTC");
370 424
     		$Common = new Common();
371 425
     		$url = str_replace('{icao}',$icao,$globalMETARurl);
@@ -379,16 +433,24 @@  discard block
 block discarded – undo
379 433
     			if ($line != '') {
380 434
     			    //$this->parse($line);
381 435
     			    //echo $line;
382
-    			    if ($date == '') $date = date('Y/m/d H:m');
436
+    			    if ($date == '') {
437
+    			    	$date = date('Y/m/d H:m');
438
+    			    }
383 439
     			    $pos = 0;
384 440
     			    $pieces = preg_split('/\s/',$line);
385
-    			    if ($pieces[0] == 'METAR') $pos++;
386
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
441
+    			    if ($pieces[0] == 'METAR') {
442
+    			    	$pos++;
443
+    			    }
444
+    			    if (strlen($pieces[$pos]) != 4) {
445
+    			    	$pos++;
446
+    			    }
387 447
 	        	    $location = $pieces[$pos];
388 448
 	        	    if (strlen($location == 4)) {
389 449
 	        		$this->addMETAR($location,$line,$date);
390 450
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
-	        	    } else return array();
451
+	        	    } else {
452
+	        	    	return array();
453
+	        	    }
392 454
     			}
393 455
     			//echo $line."\n";
394 456
     		}
Please login to merge, or discard this patch.
statistics.php 3 patches
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
47 47
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
48 48
 	}
49
-    ?>
49
+	?>
50 50
     </div>
51 51
     <?php include('statistics-sub-menu.php'); ?>
52 52
     <p class="global-stats">
@@ -55,23 +55,23 @@  discard block
 block discarded – undo
55 55
         <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
56 56
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
57 57
 	<?php
58
-	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
58
+		if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
59 59
 	?>
60 60
     	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
61 61
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
62 62
         <?php
63
-    	    } else {
64
-    	?>
63
+			} else {
64
+		?>
65 65
     	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
66 66
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
67 67
     	<?php
68
-    	    }
69
-    	?>
68
+			}
69
+		?>
70 70
         <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
71 71
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
72 72
         <?php
73
-    		if ($airline_icao == '') {
74
-    	?>
73
+			if ($airline_icao == '') {
74
+		?>
75 75
         <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
76 76
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
77 77
 	<?php
@@ -94,25 +94,25 @@  discard block
 block discarded – undo
94 94
             <div class="col-md-6">
95 95
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
96 96
                  <?php
97
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
98
-		    if (count($aircraft_array) == 0) print _("No data available");
99
-		    else {
97
+				  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
98
+			if (count($aircraft_array) == 0) print _("No data available");
99
+			else {
100 100
 
101
-                    print '<div id="chart1" class="chart" width="100%"></div>
101
+					print '<div id="chart1" class="chart" width="100%"></div>
102 102
                     <script> 
103 103
                         google.load("visualization", "1", {packages:["corechart"]});
104 104
                       google.setOnLoadCallback(drawChart1);
105 105
                       function drawChart1() {
106 106
                         var data = google.visualization.arrayToDataTable([
107 107
                             ["'._("Aircraft").'", "'._("# of times").'"], ';
108
-                            $aircraft_data = '';
109
-                          foreach($aircraft_array as $aircraft_item)
110
-                                    {
111
-                                            $aircraft_data .= '[ "'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
112
-                                    }
113
-                                    $aircraft_data = substr($aircraft_data, 0, -1);
114
-                                    print $aircraft_data;
115
-                        print ']);
108
+							$aircraft_data = '';
109
+						  foreach($aircraft_array as $aircraft_item)
110
+									{
111
+											$aircraft_data .= '[ "'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
112
+									}
113
+									$aircraft_data = substr($aircraft_data, 0, -1);
114
+									print $aircraft_data;
115
+						print ']);
116 116
 
117 117
                         var options = {
118 118
                             chartArea: {"width": "80%", "height": "60%"},
@@ -127,45 +127,45 @@  discard block
 block discarded – undo
127 127
                               drawChart1();
128 128
                             });
129 129
                   </script>';
130
-                  }
131
-                  ?>
130
+				  }
131
+				  ?>
132 132
                 <div class="more">
133 133
             	    <?php
134
-            		if ($year != '' && $month != '') {
135
-            	    ?>
134
+					if ($year != '' && $month != '') {
135
+					?>
136 136
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
137 137
             	    <?php
138
-            		} else {
139
-            	    ?>
138
+					} else {
139
+					?>
140 140
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
141 141
             	    <?php
142
-            		}
143
-            	    ?>
142
+					}
143
+					?>
144 144
                 </div>
145 145
             </div>
146 146
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
147 147
 <?php
148 148
 //    echo $airline_icao;
149
-    if ($airline_icao == '' || $airline_icao == 'all') {
149
+	if ($airline_icao == '' || $airline_icao == 'all') {
150 150
 	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
151 151
 	if (count($airline_array) > 0) {
152
-            print '<div class="col-md-6">';
153
-	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
154
-	    print '<div id="chart2" class="chart" width="100%"></div>
152
+			print '<div class="col-md-6">';
153
+		print '<h2>'._("Top 10 Most Common Airline").'</h2>';
154
+		print '<div id="chart2" class="chart" width="100%"></div>
155 155
                     <script> 
156 156
                         google.load("visualization", "1", {packages:["corechart"]});
157 157
                       google.setOnLoadCallback(drawChart2);
158 158
                       function drawChart2() {
159 159
                         var data = google.visualization.arrayToDataTable([
160 160
                             ["'._("Airline").'", "'._("# of times").'"], ';
161
-	    $airline_data = '';
162
-	    foreach($airline_array as $airline_item)
163
-	    {
161
+		$airline_data = '';
162
+		foreach($airline_array as $airline_item)
163
+		{
164 164
 		$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
165
-	    }
166
-	    $airline_data = substr($airline_data, 0, -1);
167
-	    print $airline_data;
168
-	    print ']);
165
+		}
166
+		$airline_data = substr($airline_data, 0, -1);
167
+		print $airline_data;
168
+		print ']);
169 169
 
170 170
                         var options = {
171 171
                             chartArea: {"width": "80%", "height": "60%"},
@@ -180,31 +180,31 @@  discard block
 block discarded – undo
180 180
                               drawChart2();
181 181
                             });
182 182
                   </script>';
183
-	    if ($year != '' && $month != '') {
183
+		if ($year != '' && $month != '') {
184 184
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
185 185
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
186 186
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
187
-	    } else {
187
+		} else {
188 188
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
189 189
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
190 190
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
191
-	    }
192
-    	    print '</div>';
191
+		}
192
+			print '</div>';
193 193
 	}
194 194
 ?>
195 195
         </div>
196 196
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
197 197
 <?php
198
-    }
198
+	}
199 199
 ?>
200 200
         <div class="row column">
201 201
 <?php
202
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
203
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
202
+	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
203
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
204 204
 	if (empty($flightover_array)) {
205
-	    print '<div class="col-md-12">';
205
+		print '<div class="col-md-12">';
206 206
 	} else {
207
-            print '<div class="col-md-6">';
207
+			print '<div class="col-md-6">';
208 208
 	}
209 209
 ?>
210 210
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
@@ -212,21 +212,21 @@  discard block
 block discarded – undo
212 212
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
213 213
 	if (count($pilot_array) == 0) print _("No data available");
214 214
 	else {
215
-	    print '<div id="chart7" class="chart" width="100%"></div>
215
+		print '<div id="chart7" class="chart" width="100%"></div>
216 216
                     <script> 
217 217
                         google.load("visualization", "1", {packages:["corechart"]});
218 218
                       google.setOnLoadCallback(drawChart7);
219 219
                       function drawChart7() {
220 220
                         var data = google.visualization.arrayToDataTable([
221 221
                             ["'._("Pilots").'", "'._("# of times").'"], ';
222
-	    $pilot_data = '';
223
-	    foreach($pilot_array as $pilot_item)
224
-	    {
222
+		$pilot_data = '';
223
+		foreach($pilot_array as $pilot_item)
224
+		{
225 225
 		$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
226
-	    }
227
-	    $pilot_data = substr($pilot_data, 0, -1);
228
-	    print $pilot_data;
229
-	    print ']);
226
+		}
227
+		$pilot_data = substr($pilot_data, 0, -1);
228
+		print $pilot_data;
229
+		print ']);
230 230
 
231 231
                         var options = {
232 232
                             chartArea: {"width": "80%", "height": "60%"},
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
                               drawChart7();
242 242
                             });
243 243
                   </script>';
244
-        }
245
-        print '<div class="more">';
244
+		}
245
+		print '<div class="more">';
246 246
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
247 247
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
248 248
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         
253 253
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
254 254
 <?php
255
-    } else {
255
+	} else {
256 256
 ?>
257 257
             <div class="col-md-6">
258 258
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
@@ -260,21 +260,21 @@  discard block
 block discarded – undo
260 260
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
261 261
 	if (count($owner_array) == 0) print _("No data available");
262 262
 	else {
263
-	    print '<div id="chart7" class="chart" width="100%"></div>
263
+		print '<div id="chart7" class="chart" width="100%"></div>
264 264
                     <script> 
265 265
                         google.load("visualization", "1", {packages:["corechart"]});
266 266
                       google.setOnLoadCallback(drawChart7);
267 267
                       function drawChart7() {
268 268
                         var data = google.visualization.arrayToDataTable([
269 269
                             ["'._("Owner").'", "'._("# of times").'"], ';
270
-                            $owner_data = '';
271
-	    foreach($owner_array as $owner_item)
272
-	    {
270
+							$owner_data = '';
271
+		foreach($owner_array as $owner_item)
272
+		{
273 273
 		$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
274
-	    }
275
-	    $owner_data = substr($owner_data, 0, -1);
276
-	    print $owner_data;
277
-	    print ']);
274
+		}
275
+		$owner_data = substr($owner_data, 0, -1);
276
+		print $owner_data;
277
+		print ']);
278 278
 
279 279
                         var options = {
280 280
                             chartArea: {"width": "80%", "height": "60%"},
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
         
299 299
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
300 300
 <?php
301
-    }
302
-    if (!empty($flightover_array)) {
301
+	}
302
+	if (!empty($flightover_array)) {
303 303
 ?>
304 304
             <div class="col-md-6">
305 305
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
@@ -307,21 +307,21 @@  discard block
 block discarded – undo
307 307
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
308 308
 	if (count($flightover_array) == 0) print _("No data available");
309 309
 	else {
310
-	    print '<div id="chart10" class="chart" width="100%"></div>
310
+		print '<div id="chart10" class="chart" width="100%"></div>
311 311
                     <script> 
312 312
                         google.load("visualization", "1", {packages:["corechart"]});
313 313
                       google.setOnLoadCallback(drawChart10);
314 314
                       function drawChart10() {
315 315
                         var data = google.visualization.arrayToDataTable([
316 316
                             ["'._("Country").'", "'._("# of times").'"], ';
317
-                            $flightover_data = '';
318
-	    foreach($flightover_array as $flightover_item)
319
-	    {
317
+							$flightover_data = '';
318
+		foreach($flightover_array as $flightover_item)
319
+		{
320 320
 		$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
321
-	    }
322
-	    $flightover_data = substr($flightover_data, 0, -1);
323
-	    print $flightover_data;
324
-	    print ']);
321
+		}
322
+		$flightover_data = substr($flightover_data, 0, -1);
323
+		print $flightover_data;
324
+		print ']);
325 325
 
326 326
                         var options = {
327 327
                             chartArea: {"width": "80%", "height": "60%"},
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
                 </div>
346 346
             </div>
347 347
 <?php
348
-    }
348
+	}
349 349
 ?>
350 350
         </div>
351 351
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
         <div class="row column">
356 356
             <div class="col-md-6">
357 357
 <?php
358
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
359
-    if (count($airport_airport_array) > 0) {
358
+	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
359
+	if (count($airport_airport_array) > 0) {
360 360
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
361 361
 	print '<div id="chart3" class="chart" width="100%"></div>
362 362
                 <script>
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
 
370 370
                 var data = google.visualization.arrayToDataTable([ 
371 371
                     ["'._("Airport").'", "'._("# of times").'"],';
372
-                    $airport_data = '';
372
+					$airport_data = '';
373 373
 	foreach($airport_airport_array as $airport_item)
374 374
 	{
375
-	    $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
376
-	    $name = str_replace("'", "", $name);
377
-	    $name = str_replace('"', "", $name);
378
-	    $airport_data .= '[ "'.$name.'",'.$airport_item['airport_departure_icao_count'].'],';
375
+		$name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
376
+		$name = str_replace("'", "", $name);
377
+		$name = str_replace('"', "", $name);
378
+		$airport_data .= '[ "'.$name.'",'.$airport_item['airport_departure_icao_count'].'],';
379 379
 	}
380 380
 	$airport_data = substr($airport_data, 0, -1);
381 381
 	print $airport_data;
@@ -396,15 +396,15 @@  discard block
 block discarded – undo
396 396
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
397 397
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
398 398
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
399
-    }
399
+	}
400 400
 ?>
401 401
             </div>
402 402
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
403 403
 
404 404
             <div class="col-md-6">
405 405
 <?php
406
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
407
-    if (count($airport_airport_array2) > 0) {
406
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
407
+	if (count($airport_airport_array2) > 0) {
408 408
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
409 409
 	print '<div id="chart4" class="chart" width="100%"></div>
410 410
                 <script>
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 	$airport_data2 = '';
421 421
 	foreach($airport_airport_array2 as $airport_item2)
422 422
 	{
423
-	    $name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
424
-	    $name2 = str_replace(array("'",'"'), '', $name2);
425
-	    $airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
423
+		$name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
424
+		$name2 = str_replace(array("'",'"'), '', $name2);
425
+		$airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
426 426
 	}
427 427
 	$airport_data2 = substr($airport_data2, 0, -1);
428 428
 	print $airport_data2;
@@ -443,36 +443,36 @@  discard block
 block discarded – undo
443 443
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
444 444
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
445 445
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
446
-    }
446
+	}
447 447
 ?>
448 448
             </div>
449 449
         </div>
450 450
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
451 451
 <?php
452
-    if ($year == '' && $month == '') {
452
+	if ($year == '' && $month == '') {
453 453
 ?>
454 454
         <div class="row column">
455 455
             <div class="col-md-6">
456 456
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
457 457
                 <?php
458
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
459
-		    if (count($year_array) == 0) print _("No data available");
460
-		    else {
461
-                  print '<div id="chart8" class="chart" width="100%"></div>
458
+				  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
459
+			if (count($year_array) == 0) print _("No data available");
460
+			else {
461
+				  print '<div id="chart8" class="chart" width="100%"></div>
462 462
                     <script> 
463 463
                         google.load("visualization", "1", {packages:["corechart"]});
464 464
                       google.setOnLoadCallback(drawChart8);
465 465
                       function drawChart8() {
466 466
                         var data = google.visualization.arrayToDataTable([
467 467
                             ["'._("Month").'", "'._("# of Flights").'"], ';
468
-                            $year_data = '';
469
-                          foreach($year_array as $year_item)
470
-                                    {
471
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
472
-                                    }
473
-                                    $year_data = substr($year_data, 0, -1);
474
-                                    print $year_data;
475
-                        print ']);
468
+							$year_data = '';
469
+						  foreach($year_array as $year_item)
470
+									{
471
+										$year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
472
+									}
473
+									$year_data = substr($year_data, 0, -1);
474
+									print $year_data;
475
+						print ']);
476 476
 
477 477
                         var options = {
478 478
                             legend: {position: "none"},
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
                               drawChart8();
491 491
                             });
492 492
                   </script>';
493
-                  }
494
-                  ?>
493
+				  }
494
+				  ?>
495 495
                 <div class="more">
496 496
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 497
                 </div>
@@ -500,24 +500,24 @@  discard block
 block discarded – undo
500 500
             <div class="col-md-6">
501 501
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
502 502
                 <?php
503
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
504
-		    if (count($month_array) == 0) print _("No data available");
505
-		    else {
506
-                  print '<div id="chart9" class="chart" width="100%"></div>
503
+				  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
504
+			if (count($month_array) == 0) print _("No data available");
505
+			else {
506
+				  print '<div id="chart9" class="chart" width="100%"></div>
507 507
                     <script> 
508 508
                         google.load("visualization", "1", {packages:["corechart"]});
509 509
                       google.setOnLoadCallback(drawChart9);
510 510
                       function drawChart9() {
511 511
                         var data = google.visualization.arrayToDataTable([
512 512
                             ["'._("Day").'", "'._("# of Flights").'"], ';
513
-                            $month_data = '';
514
-                          foreach($month_array as $month_item)
515
-                                    {
516
-                                        $month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
517
-                                    }
518
-                                    $month_data = substr($month_data, 0, -1);
519
-                                    print $month_data;
520
-                        print ']);
513
+							$month_data = '';
514
+						  foreach($month_array as $month_item)
515
+									{
516
+										$month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
517
+									}
518
+									$month_data = substr($month_data, 0, -1);
519
+									print $month_data;
520
+						print ']);
521 521
 
522 522
                         var options = {
523 523
                             legend: {position: "none"},
@@ -535,8 +535,8 @@  discard block
 block discarded – undo
535 535
                               drawChart9();
536 536
                             });
537 537
                   </script>';
538
-                  }
539
-                  ?>
538
+				  }
539
+				  ?>
540 540
                 <div class="more">
541 541
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
542 542
                 </div>
@@ -546,25 +546,25 @@  discard block
 block discarded – undo
546 546
             <div class="col-md-6">
547 547
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
548 548
                 <?php
549
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
550
-		    if (empty($date_array)) print _("No data available");
551
-		    else {
552
-                  print '<div id="chart5" class="chart" width="100%"></div>
549
+					$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
550
+			if (empty($date_array)) print _("No data available");
551
+			else {
552
+				  print '<div id="chart5" class="chart" width="100%"></div>
553 553
                     <script> 
554 554
                         google.load("visualization", "1", {packages:["corechart"]});
555 555
                       google.setOnLoadCallback(drawChart5);
556 556
                       function drawChart5() {
557 557
                         var data = google.visualization.arrayToDataTable([
558 558
                             ["'._("Date").'", "'._("# of Flights").'"], ';
559
-                            $date_data = '';
559
+							$date_data = '';
560 560
                         
561
-                          foreach($date_array as $date_item)
562
-                                    {
563
-                                        $date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
564
-                                    }
565
-                                    $date_data = substr($date_data, 0, -1);
566
-                                    print $date_data;
567
-                        print ']);
561
+						  foreach($date_array as $date_item)
562
+									{
563
+										$date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
564
+									}
565
+									$date_data = substr($date_data, 0, -1);
566
+									print $date_data;
567
+						print ']);
568 568
 
569 569
                         var options = {
570 570
                             legend: {position: "none"},
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
                               drawChart5();
583 583
                             });
584 584
                   </script>';
585
-                  }
586
-                  ?>
585
+				  }
586
+				  ?>
587 587
                 <div class="more">
588 588
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
589 589
                 </div>
@@ -592,25 +592,25 @@  discard block
 block discarded – undo
592 592
             <div class="col-md-6">
593 593
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
594 594
                 <?php
595
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
596
-		    if (empty($hour_array)) print _("No data available");
597
-		    else {
595
+				  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
596
+			if (empty($hour_array)) print _("No data available");
597
+			else {
598 598
 
599
-                  print '<div id="chart6" class="chart" width="100%"></div>
599
+				  print '<div id="chart6" class="chart" width="100%"></div>
600 600
                     <script> 
601 601
                         google.load("visualization", "1", {packages:["corechart"]});
602 602
                       google.setOnLoadCallback(drawChart6);
603 603
                       function drawChart6() {
604 604
                         var data = google.visualization.arrayToDataTable([
605 605
                             ["'._("Hour").'", "'._("# of Flights").'"], ';
606
-                            $hour_data = '';
607
-                          foreach($hour_array as $hour_item)
608
-                                    {
609
-                                        $hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
610
-                                    }
611
-                                    $hour_data = substr($hour_data, 0, -1);
612
-                                    print $hour_data;
613
-                        print ']);
606
+							$hour_data = '';
607
+						  foreach($hour_array as $hour_item)
608
+									{
609
+										$hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
610
+									}
611
+									$hour_data = substr($hour_data, 0, -1);
612
+									print $hour_data;
613
+						print ']);
614 614
 
615 615
                         var options = {
616 616
                             legend: {position: "none"},
@@ -628,8 +628,8 @@  discard block
 block discarded – undo
628 628
                               drawChart6();
629 629
                             });
630 630
                   </script>';
631
-                  }
632
-                ?>
631
+				  }
632
+				?>
633 633
                 <div class="more">
634 634
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
635 635
                 </div>
@@ -637,36 +637,36 @@  discard block
 block discarded – undo
637 637
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
638 638
         </div>
639 639
 <?php
640
-    }
640
+	}
641 641
 ?>
642 642
 
643 643
 <?php
644
-    if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
644
+	if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
645 645
 ?>
646 646
         <div class="row column">
647 647
             <div class="col-md-6">
648 648
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
649 649
                 <?php
650
-		    require_once('require/class.Accident.php');
651
-            	    $Accident = new Accident();
652
-                  $year_array = $Accident->countFatalitiesByYear($filter_name);
653
-		    if (count($year_array) == 0) print _("No data available");
654
-		    else {
655
-                  print '<div id="chart32" class="chart" width="100%"></div>
650
+			require_once('require/class.Accident.php');
651
+					$Accident = new Accident();
652
+				  $year_array = $Accident->countFatalitiesByYear($filter_name);
653
+			if (count($year_array) == 0) print _("No data available");
654
+			else {
655
+				  print '<div id="chart32" class="chart" width="100%"></div>
656 656
                     <script> 
657 657
                         google.load("visualization", "1", {packages:["corechart"]});
658 658
                       google.setOnLoadCallback(drawChart32);
659 659
                       function drawChart32() {
660 660
                         var data = google.visualization.arrayToDataTable([
661 661
                             ["'._("Year").'", "'._("# of Fatalities").'"], ';
662
-                            $year_data = '';
663
-                          foreach($year_array as $year_item)
664
-                                    {
665
-                                        $year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],';
666
-                                    }
667
-                                    $year_data = substr($year_data, 0, -1);
668
-                                    print $year_data;
669
-                        print ']);
662
+							$year_data = '';
663
+						  foreach($year_array as $year_item)
664
+									{
665
+										$year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],';
666
+									}
667
+									$year_data = substr($year_data, 0, -1);
668
+									print $year_data;
669
+						print ']);
670 670
 
671 671
                         var options = {
672 672
                             legend: {position: "none"},
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
                               drawChart32();
685 685
                             });
686 686
                   </script>';
687
-                  }
688
-                  ?>
687
+				  }
688
+				  ?>
689 689
                 <div class="more">
690 690
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
691 691
                 </div>
@@ -696,26 +696,26 @@  discard block
 block discarded – undo
696 696
             <div class="col-md-6">
697 697
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
698 698
                 <?php
699
-		    require_once('require/class.Accident.php');
700
-            	    $Accident = new Accident();
701
-                  $year_array = $Accident->countFatalitiesLast12Months($filter_name);
702
-		    if (count($year_array) == 0) print _("No data available");
703
-		    else {
704
-                  print '<div id="chart33" class="chart" width="100%"></div>
699
+			require_once('require/class.Accident.php');
700
+					$Accident = new Accident();
701
+				  $year_array = $Accident->countFatalitiesLast12Months($filter_name);
702
+			if (count($year_array) == 0) print _("No data available");
703
+			else {
704
+				  print '<div id="chart33" class="chart" width="100%"></div>
705 705
                     <script> 
706 706
                         google.load("visualization", "1", {packages:["corechart"]});
707 707
                       google.setOnLoadCallback(drawChart33);
708 708
                       function drawChart33() {
709 709
                         var data = google.visualization.arrayToDataTable([
710 710
                             ["'._("Month").'", "'._("# of Fatalities").'"], ';
711
-                            $year_data = '';
712
-                          foreach($year_array as $year_item)
713
-                                    {
714
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
715
-                                    }
716
-                                    $year_data = substr($year_data, 0, -1);
717
-                                    print $year_data;
718
-                        print ']);
711
+							$year_data = '';
712
+						  foreach($year_array as $year_item)
713
+									{
714
+										$year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
715
+									}
716
+									$year_data = substr($year_data, 0, -1);
717
+									print $year_data;
718
+						print ']);
719 719
 
720 720
                         var options = {
721 721
                             legend: {position: "none"},
@@ -733,8 +733,8 @@  discard block
 block discarded – undo
733 733
                               drawChart33();
734 734
                             });
735 735
                   </script>';
736
-                  }
737
-                  ?>
736
+				  }
737
+				  ?>
738 738
                 <div class="more">
739 739
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
740 740
                 </div>
@@ -742,30 +742,30 @@  discard block
 block discarded – undo
742 742
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
743 743
 <br/>
744 744
 <?php
745
-    }
745
+	}
746 746
 ?>
747 747
 
748 748
 <?php
749
-    if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
749
+	if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
750 750
 ?>
751 751
         <div class="row column">
752 752
         	<?php
753
-        	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
754
-        	    if ($year == '' && $month == '') {
755
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
756
-		    } else {
757
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
758
-        	    }
759
-        	    if (!empty($polar)) {
760
-            		print '<h2>'._("Coverage pattern").'</h2>';
761
-        		foreach ($polar as $eachpolar) {
762
-        		    unset($polar_data);
763
-	        	    $Spotter = new Spotter();
764
-        		    $data = json_decode($eachpolar['source_data']);
765
-        		    foreach($data as $value => $key) {
766
-        			$direction = $Spotter->parseDirection(($value*22.5));
767
-        			$distance = $key;
768
-        			$unit = 'km';
753
+				//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
754
+				if ($year == '' && $month == '') {
755
+				$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
756
+			} else {
757
+				$polar = $Stats->getStatsSource('polar',$year,$month);
758
+				}
759
+				if (!empty($polar)) {
760
+					print '<h2>'._("Coverage pattern").'</h2>';
761
+				foreach ($polar as $eachpolar) {
762
+					unset($polar_data);
763
+					$Spotter = new Spotter();
764
+					$data = json_decode($eachpolar['source_data']);
765
+					foreach($data as $value => $key) {
766
+					$direction = $Spotter->parseDirection(($value*22.5));
767
+					$distance = $key;
768
+					$unit = 'km';
769 769
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
770 770
 					$distance = round($distance*0.539957);
771 771
 					$unit = 'nm';
@@ -776,10 +776,10 @@  discard block
 block discarded – undo
776 776
 					$distance = $distance;
777 777
 					$unit = 'km';
778 778
 				}
779
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
780
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
781
-        		    }
782
-        	?>
779
+					if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
780
+						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
781
+					}
782
+			?>
783 783
             <div class="col-md-6">
784 784
                 <h4><?php print $eachpolar['source_name']; ?></h4>
785 785
         	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
@@ -811,27 +811,27 @@  discard block
 block discarded – undo
811 811
 		</script>
812 812
             </div>
813 813
             <?php
814
-        	    }
815
-        	}
816
-            ?>
814
+				}
815
+			}
816
+			?>
817 817
         </div>
818 818
         <div class="row column">
819 819
             <div class="col-md-6">
820 820
         	<?php
821
-        	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
822
-        	    if ($year == '' && $month == '') {
823
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
824
-        	    } else {
825
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
826
-        	    }
827
-        	    if (!empty($msg)) {
828
-            		print '<h2>'._("Messages received").'</h2>';
829
-        		foreach ($msg as $eachmsg) {
830
-        		    //$eachmsg = $msg[0];
831
-        		    $data = $eachmsg['source_data'];
832
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
833
-        		    else $max = 500;
834
-        	?>
821
+				//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
822
+				if ($year == '' && $month == '') {
823
+				$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
824
+				} else {
825
+				$msg = $Stats->getStatsSource('msg',$year,$month);
826
+				}
827
+				if (!empty($msg)) {
828
+					print '<h2>'._("Messages received").'</h2>';
829
+				foreach ($msg as $eachmsg) {
830
+					//$eachmsg = $msg[0];
831
+					$data = $eachmsg['source_data'];
832
+					if ($data > 500) $max = (round(($data+100)/100))*100;
833
+					else $max = 500;
834
+			?>
835 835
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
836 836
         	<script>
837 837
 		      var g = new JustGage({
@@ -847,9 +847,9 @@  discard block
 block discarded – undo
847 847
 			  });
848 848
 		</script>
849 849
             <?php
850
-        	   }
851
-        	}
852
-            ?>
850
+			   }
851
+			}
852
+			?>
853 853
             </div>
854 854
         </div>
855 855
         <div class="row column">
@@ -881,19 +881,19 @@  discard block
 block discarded – undo
881 881
 				$hist_data .= '[ "'.$distance.'",'.$nb.'],';
882 882
 			}
883 883
 			$hist_data = substr($hist_data, 0, -1);
884
-            ?>
884
+			?>
885 885
             <div class="col-md-6">
886 886
                 <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
887 887
                 <?php
888
-                  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
888
+				  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
889 889
                     <script> 
890 890
                         google.load("visualization", "1", {packages:["corechart"]});
891 891
                       google.setOnLoadCallback(drawCharthist_'.str_replace(' ','_',strtolower($source)).');
892 892
                       function drawCharthist_'.str_replace(' ','_',strtolower($source)).'() {
893 893
                         var data = google.visualization.arrayToDataTable([
894 894
                             ["'._("Distance").'", "'._("# of Flights").'"], ';
895
-                            print $hist_data;
896
-                        print ']);
895
+							print $hist_data;
896
+						print ']);
897 897
 
898 898
                         var options = {
899 899
                             legend: {position: "none"},
@@ -911,15 +911,15 @@  discard block
 block discarded – undo
911 911
                               drawCharthist_'.str_replace(' ','_',strtolower($source)).'();
912 912
                             });
913 913
                   </script>';
914
-        	?>
914
+			?>
915 915
     	    </div>
916 916
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
917 917
         	<?php
918
-                  }
919
-                ?>
918
+				  }
919
+				?>
920 920
         </div>
921 921
 <?php
922
-    }
922
+	}
923 923
 ?>
924 924
     </div>
925 925
 </div>  
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 $Stats = new Stats();
8 8
 
9 9
 if (!isset($filter_name)) $filter_name = '';
10
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
11 11
 if ($airline_icao == '' && isset($globalFilter)) {
12 12
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13 13
 }
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	$title = _("Statistics");
23 23
 }
24 24
 
25
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
26
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
25
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
26
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
27 27
 
28 28
 require_once('header.php');
29 29
 
@@ -44,36 +44,36 @@  discard block
 block discarded – undo
44 44
 		date_default_timezone_set('UTC');
45 45
 		$lastupdate = strtotime($last_update[0]['value']);
46 46
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
47
-		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
47
+		print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
48 48
 	}
49 49
     ?>
50 50
     </div>
51 51
     <?php include('statistics-sub-menu.php'); ?>
52 52
     <p class="global-stats">
53
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
54
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
55
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
56
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
53
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
54
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
55
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
56
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
57 57
 	<?php
58 58
 	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
59 59
 	?>
60
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
61
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
60
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
61
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
62 62
         <?php
63 63
     	    } else {
64 64
     	?>
65
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
66
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
65
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
66
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
67 67
     	<?php
68 68
     	    }
69 69
     	?>
70
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
71
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
70
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
71
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
72 72
         <?php
73 73
     		if ($airline_icao == '') {
74 74
     	?>
75
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
76
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
75
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
76
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
77 77
 	<?php
78 78
 		}
79 79
 	?>
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
82 82
 			if ($airline_icao == '' || $airline_icao == 'all') {
83 83
 	?>
84
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
85
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
84
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
85
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
86 86
 	<?php
87 87
 			}
88 88
 		}
89 89
 	?>
90 90
     </p>
91
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
91
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
92 92
     <div class="specific-stats">
93 93
         <div class="row column">
94 94
             <div class="col-md-6">
95 95
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
96 96
                  <?php
97
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
97
+                  $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
98 98
 		    if (count($aircraft_array) == 0) print _("No data available");
99 99
 		    else {
100 100
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                         var data = google.visualization.arrayToDataTable([
107 107
                             ["'._("Aircraft").'", "'._("# of times").'"], ';
108 108
                             $aircraft_data = '';
109
-                          foreach($aircraft_array as $aircraft_item)
109
+                          foreach ($aircraft_array as $aircraft_item)
110 110
                                     {
111 111
                                             $aircraft_data .= '[ "'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
112 112
                                     }
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
             	    ?>
144 144
                 </div>
145 145
             </div>
146
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
146
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
147 147
 <?php
148 148
 //    echo $airline_icao;
149 149
     if ($airline_icao == '' || $airline_icao == 'all') {
150
-	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
150
+	$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
151 151
 	if (count($airline_array) > 0) {
152 152
             print '<div class="col-md-6">';
153 153
 	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                         var data = google.visualization.arrayToDataTable([
160 160
                             ["'._("Airline").'", "'._("# of times").'"], ';
161 161
 	    $airline_data = '';
162
-	    foreach($airline_array as $airline_item)
162
+	    foreach ($airline_array as $airline_item)
163 163
 	    {
164 164
 		$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
165 165
 	    }
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 	}
194 194
 ?>
195 195
         </div>
196
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
196
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
197 197
 <?php
198 198
     }
199 199
 ?>
200 200
         <div class="row column">
201 201
 <?php
202
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
202
+    $flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
203 203
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
204 204
 	if (empty($flightover_array)) {
205 205
 	    print '<div class="col-md-12">';
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 ?>
210 210
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
211 211
 <?php
212
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
212
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
213 213
 	if (count($pilot_array) == 0) print _("No data available");
214 214
 	else {
215 215
 	    print '<div id="chart7" class="chart" width="100%"></div>
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                         var data = google.visualization.arrayToDataTable([
221 221
                             ["'._("Pilots").'", "'._("# of times").'"], ';
222 222
 	    $pilot_data = '';
223
-	    foreach($pilot_array as $pilot_item)
223
+	    foreach ($pilot_array as $pilot_item)
224 224
 	    {
225 225
 		$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
226 226
 	    }
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 ?>
251 251
             </div>
252 252
         
253
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
253
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
254 254
 <?php
255 255
     } else {
256 256
 ?>
257 257
             <div class="col-md-6">
258 258
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
259 259
 <?php
260
-	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
260
+	$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
261 261
 	if (count($owner_array) == 0) print _("No data available");
262 262
 	else {
263 263
 	    print '<div id="chart7" class="chart" width="100%"></div>
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                         var data = google.visualization.arrayToDataTable([
269 269
                             ["'._("Owner").'", "'._("# of times").'"], ';
270 270
                             $owner_data = '';
271
-	    foreach($owner_array as $owner_item)
271
+	    foreach ($owner_array as $owner_item)
272 272
 	    {
273 273
 		$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
274 274
 	    }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
                 </div>
297 297
             </div>
298 298
         
299
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
299
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
300 300
 <?php
301 301
     }
302 302
     if (!empty($flightover_array)) {
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                         var data = google.visualization.arrayToDataTable([
316 316
                             ["'._("Country").'", "'._("# of times").'"], ';
317 317
                             $flightover_data = '';
318
-	    foreach($flightover_array as $flightover_item)
318
+	    foreach ($flightover_array as $flightover_item)
319 319
 	    {
320 320
 		$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
321 321
 	    }
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
     }
349 349
 ?>
350 350
         </div>
351
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
351
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
352 352
 
353 353
     	
354 354
         </div>
355 355
         <div class="row column">
356 356
             <div class="col-md-6">
357 357
 <?php
358
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
358
+    $airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
359 359
     if (count($airport_airport_array) > 0) {
360 360
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
361 361
 	print '<div id="chart3" class="chart" width="100%"></div>
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
                 var data = google.visualization.arrayToDataTable([ 
371 371
                     ["'._("Airport").'", "'._("# of times").'"],';
372 372
                     $airport_data = '';
373
-	foreach($airport_airport_array as $airport_item)
373
+	foreach ($airport_airport_array as $airport_item)
374 374
 	{
375 375
 	    $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
376 376
 	    $name = str_replace("'", "", $name);
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
     }
400 400
 ?>
401 401
             </div>
402
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
402
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
403 403
 
404 404
             <div class="col-md-6">
405 405
 <?php
406
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
406
+    $airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
407 407
     if (count($airport_airport_array2) > 0) {
408 408
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
409 409
 	print '<div id="chart4" class="chart" width="100%"></div>
@@ -418,10 +418,10 @@  discard block
 block discarded – undo
418 418
                 var data = google.visualization.arrayToDataTable([ 
419 419
                     ["'._("Airport").'", "'._("# of times").'"],';
420 420
 	$airport_data2 = '';
421
-	foreach($airport_airport_array2 as $airport_item2)
421
+	foreach ($airport_airport_array2 as $airport_item2)
422 422
 	{
423 423
 	    $name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
424
-	    $name2 = str_replace(array("'",'"'), '', $name2);
424
+	    $name2 = str_replace(array("'", '"'), '', $name2);
425 425
 	    $airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
426 426
 	}
427 427
 	$airport_data2 = substr($airport_data2, 0, -1);
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 ?>
448 448
             </div>
449 449
         </div>
450
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
450
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
451 451
 <?php
452 452
     if ($year == '' && $month == '') {
453 453
 ?>
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
             <div class="col-md-6">
456 456
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
457 457
                 <?php
458
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
458
+                  $year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
459 459
 		    if (count($year_array) == 0) print _("No data available");
460 460
 		    else {
461 461
                   print '<div id="chart8" class="chart" width="100%"></div>
@@ -466,9 +466,9 @@  discard block
 block discarded – undo
466 466
                         var data = google.visualization.arrayToDataTable([
467 467
                             ["'._("Month").'", "'._("# of Flights").'"], ';
468 468
                             $year_data = '';
469
-                          foreach($year_array as $year_item)
469
+                          foreach ($year_array as $year_item)
470 470
                                     {
471
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
471
+                                        $year_data .= '[ "'.date('F, Y', strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
472 472
                                     }
473 473
                                     $year_data = substr($year_data, 0, -1);
474 474
                                     print $year_data;
@@ -496,11 +496,11 @@  discard block
 block discarded – undo
496 496
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 497
                 </div>
498 498
             </div>
499
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
499
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
500 500
             <div class="col-md-6">
501 501
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
502 502
                 <?php
503
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
503
+                  $month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
504 504
 		    if (count($month_array) == 0) print _("No data available");
505 505
 		    else {
506 506
                   print '<div id="chart9" class="chart" width="100%"></div>
@@ -511,9 +511,9 @@  discard block
 block discarded – undo
511 511
                         var data = google.visualization.arrayToDataTable([
512 512
                             ["'._("Day").'", "'._("# of Flights").'"], ';
513 513
                             $month_data = '';
514
-                          foreach($month_array as $month_item)
514
+                          foreach ($month_array as $month_item)
515 515
                                     {
516
-                                        $month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
516
+                                        $month_data .= '[ "'.date('F j, Y', strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
517 517
                                     }
518 518
                                     $month_data = substr($month_data, 0, -1);
519 519
                                     print $month_data;
@@ -541,12 +541,12 @@  discard block
 block discarded – undo
541 541
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
542 542
                 </div>
543 543
             </div>
544
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
544
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
545 545
 
546 546
             <div class="col-md-6">
547 547
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
548 548
                 <?php
549
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
549
+                    $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
550 550
 		    if (empty($date_array)) print _("No data available");
551 551
 		    else {
552 552
                   print '<div id="chart5" class="chart" width="100%"></div>
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
                             ["'._("Date").'", "'._("# of Flights").'"], ';
559 559
                             $date_data = '';
560 560
                         
561
-                          foreach($date_array as $date_item)
561
+                          foreach ($date_array as $date_item)
562 562
                                     {
563 563
                                         $date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
564 564
                                     }
@@ -588,11 +588,11 @@  discard block
 block discarded – undo
588 588
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
589 589
                 </div>
590 590
             </div>
591
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
591
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
592 592
             <div class="col-md-6">
593 593
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
594 594
                 <?php
595
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
595
+                  $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
596 596
 		    if (empty($hour_array)) print _("No data available");
597 597
 		    else {
598 598
 
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
                         var data = google.visualization.arrayToDataTable([
605 605
                             ["'._("Hour").'", "'._("# of Flights").'"], ';
606 606
                             $hour_data = '';
607
-                          foreach($hour_array as $hour_item)
607
+                          foreach ($hour_array as $hour_item)
608 608
                                     {
609 609
                                         $hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
610 610
                                     }
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
635 635
                 </div>
636 636
             </div>
637
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
637
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
638 638
         </div>
639 639
 <?php
640 640
     }
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
                         var data = google.visualization.arrayToDataTable([
661 661
                             ["'._("Year").'", "'._("# of Fatalities").'"], ';
662 662
                             $year_data = '';
663
-                          foreach($year_array as $year_item)
663
+                          foreach ($year_array as $year_item)
664 664
                                     {
665 665
                                         $year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],';
666 666
                                     }
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
691 691
                 </div>
692 692
             </div>
693
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
693
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
694 694
 
695 695
         <div class="row column">
696 696
             <div class="col-md-6">
@@ -709,9 +709,9 @@  discard block
 block discarded – undo
709 709
                         var data = google.visualization.arrayToDataTable([
710 710
                             ["'._("Month").'", "'._("# of Fatalities").'"], ';
711 711
                             $year_data = '';
712
-                          foreach($year_array as $year_item)
712
+                          foreach ($year_array as $year_item)
713 713
                                     {
714
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
714
+                                        $year_data .= '[ "'.date('F, Y', strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
715 715
                                     }
716 716
                                     $year_data = substr($year_data, 0, -1);
717 717
                                     print $year_data;
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
740 740
                 </div>
741 741
             </div>
742
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
742
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
743 743
 <br/>
744 744
 <?php
745 745
     }
@@ -752,9 +752,9 @@  discard block
 block discarded – undo
752 752
         	<?php
753 753
         	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
754 754
         	    if ($year == '' && $month == '') {
755
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
755
+		        $polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
756 756
 		    } else {
757
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
757
+        		$polar = $Stats->getStatsSource('polar', $year, $month);
758 758
         	    }
759 759
         	    if (!empty($polar)) {
760 760
             		print '<h2>'._("Coverage pattern").'</h2>';
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         		    unset($polar_data);
763 763
 	        	    $Spotter = new Spotter();
764 764
         		    $data = json_decode($eachpolar['source_data']);
765
-        		    foreach($data as $value => $key) {
765
+        		    foreach ($data as $value => $key) {
766 766
         			$direction = $Spotter->parseDirection(($value*22.5));
767 767
         			$distance = $key;
768 768
         			$unit = 'km';
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
         	?>
783 783
             <div class="col-md-6">
784 784
                 <h4><?php print $eachpolar['source_name']; ?></h4>
785
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
785
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
786 786
         	<script>
787 787
         	    (function() {
788 788
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 		      color: color,
807 807
 		      unit: '<?php echo $unit; ?>'
808 808
 		    };
809
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
809
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
810 810
 		    })();
811 811
 		</script>
812 812
             </div>
@@ -820,22 +820,22 @@  discard block
 block discarded – undo
820 820
         	<?php
821 821
         	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
822 822
         	    if ($year == '' && $month == '') {
823
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
823
+        		$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
824 824
         	    } else {
825
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
825
+        		$msg = $Stats->getStatsSource('msg', $year, $month);
826 826
         	    }
827 827
         	    if (!empty($msg)) {
828 828
             		print '<h2>'._("Messages received").'</h2>';
829 829
         		foreach ($msg as $eachmsg) {
830 830
         		    //$eachmsg = $msg[0];
831 831
         		    $data = $eachmsg['source_data'];
832
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
832
+        		    if ($data > 500) $max = (round(($data + 100)/100))*100;
833 833
         		    else $max = 500;
834 834
         	?>
835
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
835
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
836 836
         	<script>
837 837
 		      var g = new JustGage({
838
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
838
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
839 839
 			    value: <?php echo $data; ?>,
840 840
 			    min: 0,
841 841
 			    max: <?php print $max; ?>,
@@ -857,15 +857,15 @@  discard block
 block discarded – undo
857 857
             <?php
858 858
 		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
859 859
 		if ($year == '' && $month == '') {
860
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
860
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
861 861
 		} else {
862
-			$hist = $Stats->getStatsSource('hist',$year,$month);
862
+			$hist = $Stats->getStatsSource('hist', $year, $month);
863 863
 		}
864 864
 		foreach ($hist as $hists) {
865 865
 			$hist_data = '';
866 866
 			$source = $hists['source_name'];
867 867
 			$hist_array = json_decode($hists['source_data']);
868
-			foreach($hist_array as $distance => $nb)
868
+			foreach ($hist_array as $distance => $nb)
869 869
 			{
870 870
 				$unit = 'km';
871 871
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -883,13 +883,13 @@  discard block
 block discarded – undo
883 883
 			$hist_data = substr($hist_data, 0, -1);
884 884
             ?>
885 885
             <div class="col-md-6">
886
-                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
886
+                <h2><?php echo sprintf(_("Flights Distance for %s"), $source); ?></h2>
887 887
                 <?php
888
-                  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
888
+                  print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div>
889 889
                     <script> 
890 890
                         google.load("visualization", "1", {packages:["corechart"]});
891
-                      google.setOnLoadCallback(drawCharthist_'.str_replace(' ','_',strtolower($source)).');
892
-                      function drawCharthist_'.str_replace(' ','_',strtolower($source)).'() {
891
+                      google.setOnLoadCallback(drawCharthist_'.str_replace(' ', '_', strtolower($source)).');
892
+                      function drawCharthist_'.str_replace(' ', '_', strtolower($source)).'() {
893 893
                         var data = google.visualization.arrayToDataTable([
894 894
                             ["'._("Distance").'", "'._("# of Flights").'"], ';
895 895
                             print $hist_data;
@@ -904,16 +904,16 @@  discard block
 block discarded – undo
904 904
                             colors: ["#1a3151"]
905 905
                         };
906 906
 
907
-                        var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ','_',strtolower($source)).'"));
907
+                        var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ', '_', strtolower($source)).'"));
908 908
                         chart.draw(data, options);
909 909
                       }
910 910
                       $(window).resize(function(){
911
-                              drawCharthist_'.str_replace(' ','_',strtolower($source)).'();
911
+                              drawCharthist_'.str_replace(' ', '_', strtolower($source)).'();
912 912
                             });
913 913
                   </script>';
914 914
         	?>
915 915
     	    </div>
916
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
916
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
917 917
         	<?php
918 918
                   }
919 919
                 ?>
Please login to merge, or discard this patch.
Braces   +103 added lines, -42 removed lines patch added patch discarded remove patch
@@ -6,11 +6,15 @@  discard block
 block discarded – undo
6 6
 $beginpage = microtime(true);
7 7
 $Stats = new Stats();
8 8
 
9
-if (!isset($filter_name)) $filter_name = '';
9
+if (!isset($filter_name)) {
10
+	$filter_name = '';
11
+}
10 12
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11 13
 if ($airline_icao == '' && isset($globalFilter)) {
12
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13
-}
14
+	if (isset($globalFilter['airline'])) {
15
+		$airline_icao = $globalFilter['airline'][0];
16
+	}
17
+	}
14 18
 if ($airline_icao != '' && $airline_icao != 'all') {
15 19
 	$Spotter = new Spotter();
16 20
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -36,14 +40,21 @@  discard block
 block discarded – undo
36 40
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/justgage.js"></script>
37 41
 <div class="column">
38 42
     <div class="info">
39
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
43
+            <h1><?php if (isset($airline_name)) {
44
+	echo _("Statistics for ").$airline_name;
45
+} else {
46
+	echo _("Statistics");
47
+}
48
+?></h1>
40 49
     <?php 
41 50
 	$last_update = $Stats->getLastStatsUpdate();
42 51
 	//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
43 52
 	if (isset($last_update[0]['value'])) {
44 53
 		date_default_timezone_set('UTC');
45 54
 		$lastupdate = strtotime($last_update[0]['value']);
46
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
55
+		if (isset($globalTimezone) && $globalTimezone != '') {
56
+			date_default_timezone_set($globalTimezone);
57
+		}
47 58
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
48 59
 	}
49 60
     ?>
@@ -95,8 +106,9 @@  discard block
 block discarded – undo
95 106
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
96 107
                  <?php
97 108
                   $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
98
-		    if (count($aircraft_array) == 0) print _("No data available");
99
-		    else {
109
+		    if (count($aircraft_array) == 0) {
110
+		    	print _("No data available");
111
+		    } else {
100 112
 
101 113
                     print '<div id="chart1" class="chart" width="100%"></div>
102 114
                     <script> 
@@ -133,11 +145,17 @@  discard block
 block discarded – undo
133 145
             	    <?php
134 146
             		if ($year != '' && $month != '') {
135 147
             	    ?>
136
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
148
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
149
+	echo '/'.$airline_icao;
150
+}
151
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
137 152
             	    <?php
138 153
             		} else {
139 154
             	    ?>
140
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
155
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
156
+	echo '/'.$airline_icao;
157
+}
158
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
141 159
             	    <?php
142 160
             		}
143 161
             	    ?>
@@ -182,11 +200,15 @@  discard block
 block discarded – undo
182 200
                   </script>';
183 201
 	    if ($year != '' && $month != '') {
184 202
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
185
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
203
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
204
+			echo '/'.$airline_icao;
205
+		}
186 206
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
187 207
 	    } else {
188 208
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
189
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
209
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
210
+			echo '/'.$airline_icao;
211
+		}
190 212
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
191 213
 	    }
192 214
     	    print '</div>';
@@ -210,8 +232,9 @@  discard block
 block discarded – undo
210 232
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
211 233
 <?php
212 234
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
213
-	if (count($pilot_array) == 0) print _("No data available");
214
-	else {
235
+	if (count($pilot_array) == 0) {
236
+		print _("No data available");
237
+	} else {
215 238
 	    print '<div id="chart7" class="chart" width="100%"></div>
216 239
                     <script> 
217 240
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -244,7 +267,9 @@  discard block
 block discarded – undo
244 267
         }
245 268
         print '<div class="more">';
246 269
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
247
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
270
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
271
+		echo '/'.$airline_icao;
272
+	}
248 273
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
249 274
 	print '</div>';
250 275
 ?>
@@ -258,8 +283,9 @@  discard block
 block discarded – undo
258 283
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
259 284
 <?php
260 285
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
261
-	if (count($owner_array) == 0) print _("No data available");
262
-	else {
286
+	if (count($owner_array) == 0) {
287
+		print _("No data available");
288
+	} else {
263 289
 	    print '<div id="chart7" class="chart" width="100%"></div>
264 290
                     <script> 
265 291
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -292,7 +318,10 @@  discard block
 block discarded – undo
292 318
 	}
293 319
 ?>
294 320
                 <div class="more">
295
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
321
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
322
+	echo '/'.$airline_icao;
323
+}
324
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
296 325
                 </div>
297 326
             </div>
298 327
         
@@ -305,8 +334,9 @@  discard block
 block discarded – undo
305 334
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
306 335
 <?php
307 336
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
308
-	if (count($flightover_array) == 0) print _("No data available");
309
-	else {
337
+	if (count($flightover_array) == 0) {
338
+		print _("No data available");
339
+	} else {
310 340
 	    print '<div id="chart10" class="chart" width="100%"></div>
311 341
                     <script> 
312 342
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -341,7 +371,10 @@  discard block
 block discarded – undo
341 371
 	}
342 372
 ?>
343 373
                 <div class="more">
344
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
374
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
375
+	echo '/'.$airline_icao;
376
+}
377
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
345 378
                 </div>
346 379
             </div>
347 380
 <?php
@@ -394,7 +427,9 @@  discard block
 block discarded – undo
394 427
               }
395 428
                 </script>';
396 429
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
397
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
430
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
431
+		echo '/'.$airline_icao;
432
+	}
398 433
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
399 434
     }
400 435
 ?>
@@ -441,7 +476,9 @@  discard block
 block discarded – undo
441 476
               }
442 477
                 </script>';
443 478
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
444
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
479
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
480
+		echo '/'.$airline_icao;
481
+	}
445 482
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
446 483
     }
447 484
 ?>
@@ -456,8 +493,9 @@  discard block
 block discarded – undo
456 493
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
457 494
                 <?php
458 495
                   $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
459
-		    if (count($year_array) == 0) print _("No data available");
460
-		    else {
496
+		    if (count($year_array) == 0) {
497
+		    	print _("No data available");
498
+		    } else {
461 499
                   print '<div id="chart8" class="chart" width="100%"></div>
462 500
                     <script> 
463 501
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -493,7 +531,10 @@  discard block
 block discarded – undo
493 531
                   }
494 532
                   ?>
495 533
                 <div class="more">
496
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
534
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
535
+	echo '/'.$airline_icao;
536
+}
537
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 538
                 </div>
498 539
             </div>
499 540
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -501,8 +542,9 @@  discard block
 block discarded – undo
501 542
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
502 543
                 <?php
503 544
                   $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
504
-		    if (count($month_array) == 0) print _("No data available");
505
-		    else {
545
+		    if (count($month_array) == 0) {
546
+		    	print _("No data available");
547
+		    } else {
506 548
                   print '<div id="chart9" class="chart" width="100%"></div>
507 549
                     <script> 
508 550
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -538,7 +580,10 @@  discard block
 block discarded – undo
538 580
                   }
539 581
                   ?>
540 582
                 <div class="more">
541
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
583
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
584
+	echo '/'.$airline_icao;
585
+}
586
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
542 587
                 </div>
543 588
             </div>
544 589
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -547,8 +592,9 @@  discard block
 block discarded – undo
547 592
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
548 593
                 <?php
549 594
                     $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
550
-		    if (empty($date_array)) print _("No data available");
551
-		    else {
595
+		    if (empty($date_array)) {
596
+		    	print _("No data available");
597
+		    } else {
552 598
                   print '<div id="chart5" class="chart" width="100%"></div>
553 599
                     <script> 
554 600
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -585,7 +631,10 @@  discard block
 block discarded – undo
585 631
                   }
586 632
                   ?>
587 633
                 <div class="more">
588
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
634
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
635
+	echo '/'.$airline_icao;
636
+}
637
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
589 638
                 </div>
590 639
             </div>
591 640
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -593,8 +642,9 @@  discard block
 block discarded – undo
593 642
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
594 643
                 <?php
595 644
                   $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
596
-		    if (empty($hour_array)) print _("No data available");
597
-		    else {
645
+		    if (empty($hour_array)) {
646
+		    	print _("No data available");
647
+		    } else {
598 648
 
599 649
                   print '<div id="chart6" class="chart" width="100%"></div>
600 650
                     <script> 
@@ -631,7 +681,10 @@  discard block
 block discarded – undo
631 681
                   }
632 682
                 ?>
633 683
                 <div class="more">
634
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
684
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
685
+	echo '/'.$airline_icao;
686
+}
687
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
635 688
                 </div>
636 689
             </div>
637 690
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -650,8 +703,9 @@  discard block
 block discarded – undo
650 703
 		    require_once('require/class.Accident.php');
651 704
             	    $Accident = new Accident();
652 705
                   $year_array = $Accident->countFatalitiesByYear($filter_name);
653
-		    if (count($year_array) == 0) print _("No data available");
654
-		    else {
706
+		    if (count($year_array) == 0) {
707
+		    	print _("No data available");
708
+		    } else {
655 709
                   print '<div id="chart32" class="chart" width="100%"></div>
656 710
                     <script> 
657 711
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -699,8 +753,9 @@  discard block
 block discarded – undo
699 753
 		    require_once('require/class.Accident.php');
700 754
             	    $Accident = new Accident();
701 755
                   $year_array = $Accident->countFatalitiesLast12Months($filter_name);
702
-		    if (count($year_array) == 0) print _("No data available");
703
-		    else {
756
+		    if (count($year_array) == 0) {
757
+		    	print _("No data available");
758
+		    } else {
704 759
                   print '<div id="chart33" class="chart" width="100%"></div>
705 760
                     <script> 
706 761
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -776,8 +831,11 @@  discard block
 block discarded – undo
776 831
 					$distance = $distance;
777 832
 					$unit = 'km';
778 833
 				}
779
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
780
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
834
+        			if (!isset($polar_data)) {
835
+        				$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
836
+        			} else {
837
+        	    			$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
838
+        	    		}
781 839
         		    }
782 840
         	?>
783 841
             <div class="col-md-6">
@@ -829,8 +887,11 @@  discard block
 block discarded – undo
829 887
         		foreach ($msg as $eachmsg) {
830 888
         		    //$eachmsg = $msg[0];
831 889
         		    $data = $eachmsg['source_data'];
832
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
833
-        		    else $max = 500;
890
+        		    if ($data > 500) {
891
+        		    	$max = (round(($data+100)/100))*100;
892
+        		    } else {
893
+        		    	$max = 500;
894
+        		    }
834 895
         	?>
835 896
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
836 897
         	<script>
Please login to merge, or discard this patch.
require/class.Stats.php 4 patches
Doc Comments   +31 added lines patch added patch discarded remove patch
@@ -17,6 +17,10 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
+	/**
21
+	 * @param string $type
22
+	 * @param string $stats_date
23
+	 */
20 24
 	public function addLastStatsUpdate($type,$stats_date) {
21 25
                 $query = "DELETE FROM config WHERE name = :type;
22 26
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
@@ -878,6 +882,11 @@  discard block
 block discarded – undo
878 882
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
879 883
                 return $all;
880 884
         }
885
+
886
+	/**
887
+	 * @param string $type
888
+	 * @param string $year
889
+	 */
881 890
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
882 891
 		if ($filter_name == '') $filter_name = $this->filter_name;
883 892
     		global $globalArchiveMonths, $globalDBdriver;
@@ -1022,6 +1031,10 @@  discard block
 block discarded – undo
1022 1031
                 else return 0;
1023 1032
         }
1024 1033
 
1034
+	/**
1035
+	 * @param string $type
1036
+	 * @param string $stats_date
1037
+	 */
1025 1038
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1026 1039
 		global $globalDBdriver;
1027 1040
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -1075,6 +1088,9 @@  discard block
 block discarded – undo
1075 1088
         }
1076 1089
         */
1077 1090
 
1091
+	/**
1092
+	 * @param string $stats_type
1093
+	 */
1078 1094
 	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1079 1095
 		global $globalDBdriver;
1080 1096
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
@@ -1118,6 +1134,9 @@  discard block
 block discarded – undo
1118 1134
 		return $all;
1119 1135
 	}
1120 1136
 
1137
+	/**
1138
+	 * @param string $stats_type
1139
+	 */
1121 1140
 	public function addStatSource($data,$source_name,$stats_type,$date) {
1122 1141
 		global $globalDBdriver;
1123 1142
 		if ($globalDBdriver == 'mysql') {
@@ -1133,6 +1152,10 @@  discard block
 block discarded – undo
1133 1152
                         return "error : ".$e->getMessage();
1134 1153
                 }
1135 1154
         }
1155
+
1156
+	/**
1157
+	 * @param string $type
1158
+	 */
1136 1159
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1137 1160
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1138 1161
                 $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
@@ -1399,6 +1422,10 @@  discard block
 block discarded – undo
1399 1422
                         return "error : ".$e->getMessage();
1400 1423
                 }
1401 1424
         }
1425
+
1426
+	/**
1427
+	 * @param string $type
1428
+	 */
1402 1429
 	public function deleteStatFlight($type) {
1403 1430
                 $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1404 1431
                 $query_values = array(':type' => $type);
@@ -1409,6 +1436,10 @@  discard block
 block discarded – undo
1409 1436
                         return "error : ".$e->getMessage();
1410 1437
                 }
1411 1438
         }
1439
+
1440
+	/**
1441
+	 * @param string $type
1442
+	 */
1412 1443
 	public function deleteStatAirport($type) {
1413 1444
                 $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1414 1445
                 $query_values = array(':type' => $type);
Please login to merge, or discard this patch.
Indentation   +779 added lines, -779 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
15 15
 		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-        }
18
+		}
19 19
               
20 20
 	public function addLastStatsUpdate($type,$stats_date) {
21
-                $query = "DELETE FROM config WHERE name = :type;
21
+				$query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
-                 try {
25
-                        $sth = $this->db->prepare($query);
26
-                        $sth->execute($query_values);
27
-                } catch(PDOException $e) {
28
-                        return "error : ".$e->getMessage();
29
-                }
30
-        }
23
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
24
+				 try {
25
+						$sth = $this->db->prepare($query);
26
+						$sth->execute($query_values);
27
+				} catch(PDOException $e) {
28
+						return "error : ".$e->getMessage();
29
+				}
30
+		}
31 31
 
32 32
 	public function getLastStatsUpdate($type = 'last_update_stats') {
33
-                $query = "SELECT value FROM config WHERE name = :type";
34
-                 try {
35
-                        $sth = $this->db->prepare($query);
36
-                        $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
38
-                        echo "error : ".$e->getMessage();
39
-                }
40
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
-                return $all;
42
-        }
43
-        public function deleteStats($filter_name = '') {
44
-        	/*
33
+				$query = "SELECT value FROM config WHERE name = :type";
34
+				 try {
35
+						$sth = $this->db->prepare($query);
36
+						$sth->execute(array(':type' => $type));
37
+				} catch(PDOException $e) {
38
+						echo "error : ".$e->getMessage();
39
+				}
40
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
+				return $all;
42
+		}
43
+		public function deleteStats($filter_name = '') {
44
+			/*
45 45
         	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
46 46
                  try {
47 47
                         $sth = $this->db->prepare($query);
@@ -50,106 +50,106 @@  discard block
 block discarded – undo
50 50
                         return "error : ".$e->getMessage();
51 51
                 }
52 52
                 */
53
-        	$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;";
54
-                 try {
55
-                        $sth = $this->db->prepare($query);
56
-                        $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-        }
61
-        public function deleteOldStats($filter_name = '') {
53
+			$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;";
54
+				 try {
55
+						$sth = $this->db->prepare($query);
56
+						$sth->execute(array(':filter_name' => $filter_name));
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+		}
61
+		public function deleteOldStats($filter_name = '') {
62 62
         	
63
-        	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
-                 try {
65
-                        $sth = $this->db->prepare($query);
66
-                        $sth->execute();
67
-                } catch(PDOException $e) {
68
-                        return "error : ".$e->getMessage();
69
-                }
63
+			$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
+				 try {
65
+						$sth = $this->db->prepare($query);
66
+						$sth->execute();
67
+				} catch(PDOException $e) {
68
+						return "error : ".$e->getMessage();
69
+				}
70 70
                 
71
-        	$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;";
72
-                 try {
73
-                        $sth = $this->db->prepare($query);
74
-                        $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
76
-                        return "error : ".$e->getMessage();
77
-                }
78
-        }
71
+			$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;";
72
+				 try {
73
+						$sth = $this->db->prepare($query);
74
+						$sth->execute(array(':filter_name' => $filter_name));
75
+				} catch(PDOException $e) {
76
+						return "error : ".$e->getMessage();
77
+				}
78
+		}
79 79
 	public function getAllAirlineNames($filter_name = '') {
80 80
 		if ($filter_name == '') $filter_name = $this->filter_name;
81
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
-                 try {
83
-                        $sth = $this->db->prepare($query);
84
-                        $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
86
-                        echo "error : ".$e->getMessage();
87
-                }
88
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
-                return $all;
90
-        }
81
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
+				 try {
83
+						$sth = $this->db->prepare($query);
84
+						$sth->execute(array(':filter_name' => $filter_name));
85
+				} catch(PDOException $e) {
86
+						echo "error : ".$e->getMessage();
87
+				}
88
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
+				return $all;
90
+		}
91 91
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
-                 try {
95
-                        $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
98
-                        echo "error : ".$e->getMessage();
99
-                }
100
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
-                return $all;
102
-        }
93
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
+				 try {
95
+						$sth = $this->db->prepare($query);
96
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
+				} catch(PDOException $e) {
98
+						echo "error : ".$e->getMessage();
99
+				}
100
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
+				return $all;
102
+		}
103 103
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105
-                $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106
-                 try {
107
-                        $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
110
-                        echo "error : ".$e->getMessage();
111
-                }
112
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
-                return $all;
114
-        }
105
+				$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106
+				 try {
107
+						$sth = $this->db->prepare($query);
108
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
+				} catch(PDOException $e) {
110
+						echo "error : ".$e->getMessage();
111
+				}
112
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
+				return $all;
114
+		}
115 115
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117
-                $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118
-                 try {
119
-                        $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
122
-                        echo "error : ".$e->getMessage();
123
-                }
124
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
-                return $all;
126
-        }
117
+				$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118
+				 try {
119
+						$sth = $this->db->prepare($query);
120
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
+				} catch(PDOException $e) {
122
+						echo "error : ".$e->getMessage();
123
+				}
124
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
+				return $all;
126
+		}
127 127
 
128 128
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130
-                $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
-                 try {
132
-                        $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
135
-                        echo "error : ".$e->getMessage();
136
-                }
137
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
-                return $all;
139
-        }
130
+				$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
+				 try {
132
+						$sth = $this->db->prepare($query);
133
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
+				} catch(PDOException $e) {
135
+						echo "error : ".$e->getMessage();
136
+				}
137
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
+				return $all;
139
+		}
140 140
 
141 141
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143
-                $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
-                 try {
145
-                        $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
148
-                        echo "error : ".$e->getMessage();
149
-                }
150
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
-                return $all;
152
-        }
143
+				$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
+				 try {
145
+						$sth = $this->db->prepare($query);
146
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
+				} catch(PDOException $e) {
148
+						echo "error : ".$e->getMessage();
149
+				}
150
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
+				return $all;
152
+		}
153 153
 
154 154
 
155 155
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168 168
 		} else $all = array();
169
-                if (empty($all)) {
170
-            	    $filters = array('airlines' => array($stats_airline));
171
-            	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
-            	    }
174
-            	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
-                }
177
-                return $all;
169
+				if (empty($all)) {
170
+					$filters = array('airlines' => array($stats_airline));
171
+					if ($filter_name != '') {
172
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
+					}
174
+					$Spotter = new Spotter($this->db);
175
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
+				}
177
+				return $all;
178 178
 	}
179 179
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 180
 		global $globalStatsFilters;
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192 192
 		} else $all = array();
193
-                if (empty($all)) {
194
-            		$Spotter = new Spotter($this->db);
195
-            		$filters = array();
196
-            		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
193
+				if (empty($all)) {
194
+					$Spotter = new Spotter($this->db);
195
+					$filters = array();
196
+					if ($filter_name != '') {
197
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
-                }
201
-                return $all;
199
+					$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
+				}
201
+				return $all;
202 202
 	}
203 203
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 204
 		global $globalStatsFilters;
@@ -239,37 +239,37 @@  discard block
 block discarded – undo
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241 241
 		} else $all = array();
242
-                if (empty($all)) {
242
+				if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
244 244
 			if ($filter_name != '') {
245
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Spotter = new Spotter($this->db);
248 248
 			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
249
-                }
250
-                return $all;
249
+				}
250
+				return $all;
251 251
 	}
252 252
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 253
 		global $globalStatsFilters;
254 254
 		if ($filter_name == '') $filter_name = $this->filter_name;
255 255
 		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";
256 256
 		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";
257
-                 try {
258
-                        $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
261
-                        echo "error : ".$e->getMessage();
262
-                }
263
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
-                if (empty($all)) {
257
+				 try {
258
+						$sth = $this->db->prepare($query);
259
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
+				} catch(PDOException $e) {
261
+						echo "error : ".$e->getMessage();
262
+				}
263
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
+				if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270 270
 			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
271
-                }
272
-                return $all;
271
+				}
272
+				return $all;
273 273
 	}
274 274
 
275 275
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 			}
287 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
288 288
 		} else $all = array();
289
-                if (empty($all)) {
290
-	                $Spotter = new Spotter($this->db);
291
-            		$filters = array();
292
-            		if ($filter_name != '') {
293
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
289
+				if (empty($all)) {
290
+					$Spotter = new Spotter($this->db);
291
+					$filters = array();
292
+					if ($filter_name != '') {
293
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
294 294
 			}
295 295
 
296
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
-                }
298
-                return $all;
296
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
+				}
298
+				return $all;
299 299
 	}
300 300
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
301 301
 		global $globalStatsFilters;
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
 			}
312 312
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313 313
 		} else $all = array();
314
-                if (empty($all)) {
314
+				if (empty($all)) {
315 315
 			$filters = array('airlines' => array($stats_airline));
316 316
 			if ($filter_name != '') {
317 317
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
318 318
 			}
319
-	                $Spotter = new Spotter($this->db);
320
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
-                }
322
-                return $all;
319
+					$Spotter = new Spotter($this->db);
320
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
+				}
322
+				return $all;
323 323
 	}
324 324
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
325 325
 		global $globalStatsFilters;
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 					echo "error : ".$e->getMessage();
360 360
 				}
361 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
362
-                /*
362
+				/*
363 363
                 if (empty($all)) {
364 364
 	                $Spotter = new Spotter($this->db);
365 365
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -410,15 +410,15 @@  discard block
 block discarded – undo
410 410
 			}
411 411
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
412 412
 		} else $all = array();
413
-                if (empty($all)) {
413
+				if (empty($all)) {
414 414
 			$filters = array('airlines' => array($stats_airline));
415 415
 			if ($filter_name != '') {
416 416
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
417 417
 			}
418
-            		$Spotter = new Spotter($this->db);
419
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
-                }
421
-                return $all;
418
+					$Spotter = new Spotter($this->db);
419
+					$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
+				}
421
+				return $all;
422 422
 	}
423 423
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
424 424
 		global $globalStatsFilters;
@@ -434,33 +434,33 @@  discard block
 block discarded – undo
434 434
 			}
435 435
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
436 436
 		} else $all = array();
437
-                if (empty($all)) {
437
+				if (empty($all)) {
438 438
 			$filters = array('airlines' => array($stats_airline));
439
-            		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
-			}
442
-            		$Spotter = new Spotter($this->db);
443
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
-        		$all = array();
446
-        		foreach ($pall as $value) {
447
-        			$icao = $value['airport_departure_icao'];
448
-        			$all[$icao] = $value;
449
-        		}
439
+					if ($filter_name != '') {
440
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
+			}
442
+					$Spotter = new Spotter($this->db);
443
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
+				$all = array();
446
+				foreach ($pall as $value) {
447
+					$icao = $value['airport_departure_icao'];
448
+					$all[$icao] = $value;
449
+				}
450 450
         		
451
-        		foreach ($dall as $value) {
452
-        			$icao = $value['airport_departure_icao'];
453
-        			if (isset($all[$icao])) {
454
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
-        			} else $all[$icao] = $value;
456
-        		}
457
-        		$count = array();
458
-        		foreach ($all as $key => $row) {
459
-        			$count[$key] = $row['airport_departure_icao_count'];
460
-        		}
461
-        		array_multisort($count,SORT_DESC,$all);
462
-                }
463
-                return $all;
451
+				foreach ($dall as $value) {
452
+					$icao = $value['airport_departure_icao'];
453
+					if (isset($all[$icao])) {
454
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
+					} else $all[$icao] = $value;
456
+				}
457
+				$count = array();
458
+				foreach ($all as $key => $row) {
459
+					$count[$key] = $row['airport_departure_icao_count'];
460
+				}
461
+				array_multisort($count,SORT_DESC,$all);
462
+				}
463
+				return $all;
464 464
 	}
465 465
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
466 466
 		global $globalStatsFilters;
@@ -484,26 +484,26 @@  discard block
 block discarded – undo
484 484
 			$Spotter = new Spotter($this->db);
485 485
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
486 486
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
487
-        		$all = array();
488
-        		foreach ($pall as $value) {
489
-        			$icao = $value['airport_arrival_icao'];
490
-        			$all[$icao] = $value;
491
-        		}
487
+				$all = array();
488
+				foreach ($pall as $value) {
489
+					$icao = $value['airport_arrival_icao'];
490
+					$all[$icao] = $value;
491
+				}
492 492
         		
493
-        		foreach ($dall as $value) {
494
-        			$icao = $value['airport_arrival_icao'];
495
-        			if (isset($all[$icao])) {
496
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
-        			} else $all[$icao] = $value;
498
-        		}
499
-        		$count = array();
500
-        		foreach ($all as $key => $row) {
501
-        			$count[$key] = $row['airport_arrival_icao_count'];
502
-        		}
503
-        		array_multisort($count,SORT_DESC,$all);
504
-                }
493
+				foreach ($dall as $value) {
494
+					$icao = $value['airport_arrival_icao'];
495
+					if (isset($all[$icao])) {
496
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
+					} else $all[$icao] = $value;
498
+				}
499
+				$count = array();
500
+				foreach ($all as $key => $row) {
501
+					$count[$key] = $row['airport_arrival_icao_count'];
502
+				}
503
+				array_multisort($count,SORT_DESC,$all);
504
+				}
505 505
  
506
-                return $all;
506
+				return $all;
507 507
 	}
508 508
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
509 509
 		global $globalDBdriver, $globalStatsFilters;
@@ -516,23 +516,23 @@  discard block
 block discarded – undo
516 516
 			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";
517 517
 		}
518 518
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
519
-                 try {
520
-                        $sth = $this->db->prepare($query);
521
-                        $sth->execute($query_data);
522
-                } catch(PDOException $e) {
523
-                        echo "error : ".$e->getMessage();
524
-                }
525
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
-                if (empty($all)) {
519
+				 try {
520
+						$sth = $this->db->prepare($query);
521
+						$sth->execute($query_data);
522
+				} catch(PDOException $e) {
523
+						echo "error : ".$e->getMessage();
524
+				}
525
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
+				if (empty($all)) {
527 527
 			$filters = array('airlines' => array($stats_airline));
528 528
 			if ($filter_name != '') {
529 529
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
530 530
 			}
531
-            		$Spotter = new Spotter($this->db);
532
-            		$all = $Spotter->countAllMonthsLastYear($filters);
533
-                }
531
+					$Spotter = new Spotter($this->db);
532
+					$all = $Spotter->countAllMonthsLastYear($filters);
533
+				}
534 534
                 
535
-                return $all;
535
+				return $all;
536 536
 	}
537 537
 	
538 538
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -540,22 +540,22 @@  discard block
 block discarded – undo
540 540
 		if ($filter_name == '') $filter_name = $this->filter_name;
541 541
 		$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";
542 542
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
543
-                 try {
544
-                        $sth = $this->db->prepare($query);
545
-                        $sth->execute($query_data);
546
-                } catch(PDOException $e) {
547
-                        echo "error : ".$e->getMessage();
548
-                }
549
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
-                if (empty($all)) {
543
+				 try {
544
+						$sth = $this->db->prepare($query);
545
+						$sth->execute($query_data);
546
+				} catch(PDOException $e) {
547
+						echo "error : ".$e->getMessage();
548
+				}
549
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
+				if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553 553
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
554 554
 			}
555
-            		$Spotter = new Spotter($this->db);
556
-            		$all = $Spotter->countAllDatesLastMonth($filters);
557
-                }
558
-                return $all;
555
+					$Spotter = new Spotter($this->db);
556
+					$all = $Spotter->countAllDatesLastMonth($filters);
557
+				}
558
+				return $all;
559 559
 	}
560 560
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
561 561
 		global $globalDBdriver, $globalStatsFilters;
@@ -566,110 +566,110 @@  discard block
 block discarded – undo
566 566
 			$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";
567 567
 		}
568 568
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
569
-                 try {
570
-                        $sth = $this->db->prepare($query);
571
-                        $sth->execute($query_data);
572
-                } catch(PDOException $e) {
573
-                        echo "error : ".$e->getMessage();
574
-                }
575
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
-                if (empty($all)) {
569
+				 try {
570
+						$sth = $this->db->prepare($query);
571
+						$sth->execute($query_data);
572
+				} catch(PDOException $e) {
573
+						echo "error : ".$e->getMessage();
574
+				}
575
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
+				if (empty($all)) {
577 577
 			$filters = array('airlines' => array($stats_airline));
578 578
 			if ($filter_name != '') {
579 579
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
580 580
 			}
581
-            		$Spotter = new Spotter($this->db);
582
-            		$all = $Spotter->countAllDatesLast7Days($filters);
583
-                }
584
-                return $all;
581
+					$Spotter = new Spotter($this->db);
582
+					$all = $Spotter->countAllDatesLast7Days($filters);
583
+				}
584
+				return $all;
585 585
 	}
586 586
 	public function countAllDates($stats_airline = '',$filter_name = '') {
587 587
 		global $globalStatsFilters;
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		$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";
590 590
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
591
-                 try {
592
-                        $sth = $this->db->prepare($query);
593
-                        $sth->execute($query_data);
594
-                } catch(PDOException $e) {
595
-                        echo "error : ".$e->getMessage();
596
-                }
597
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
-                if (empty($all)) {
591
+				 try {
592
+						$sth = $this->db->prepare($query);
593
+						$sth->execute($query_data);
594
+				} catch(PDOException $e) {
595
+						echo "error : ".$e->getMessage();
596
+				}
597
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
+				if (empty($all)) {
599 599
 			$filters = array('airlines' => array($stats_airline));
600 600
 			if ($filter_name != '') {
601
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
601
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
602 602
 			}
603
-            		$Spotter = new Spotter($this->db);
604
-            		$all = $Spotter->countAllDates($filters);
605
-                }
606
-                return $all;
603
+					$Spotter = new Spotter($this->db);
604
+					$all = $Spotter->countAllDates($filters);
605
+				}
606
+				return $all;
607 607
 	}
608 608
 	public function countAllDatesByAirlines($filter_name = '') {
609 609
 		global $globalStatsFilters;
610 610
 		if ($filter_name == '') $filter_name = $this->filter_name;
611 611
 		$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";
612 612
 		$query_data = array('filter_name' => $filter_name);
613
-                 try {
614
-                        $sth = $this->db->prepare($query);
615
-                        $sth->execute($query_data);
616
-                } catch(PDOException $e) {
617
-                        echo "error : ".$e->getMessage();
618
-                }
619
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
-                if (empty($all)) {
621
-            		$filters = array();
622
-            		if ($filter_name != '') {
623
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
613
+				 try {
614
+						$sth = $this->db->prepare($query);
615
+						$sth->execute($query_data);
616
+				} catch(PDOException $e) {
617
+						echo "error : ".$e->getMessage();
618
+				}
619
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
+				if (empty($all)) {
621
+					$filters = array();
622
+					if ($filter_name != '') {
623
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
624 624
 			}
625
-            		$Spotter = new Spotter($this->db);
626
-            		$all = $Spotter->countAllDatesByAirlines($filters);
627
-                }
628
-                return $all;
625
+					$Spotter = new Spotter($this->db);
626
+					$all = $Spotter->countAllDatesByAirlines($filters);
627
+				}
628
+				return $all;
629 629
 	}
630 630
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
631 631
 		global $globalStatsFilters;
632 632
 		if ($filter_name == '') $filter_name = $this->filter_name;
633
-	    	$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";
634
-                 try {
635
-                        $sth = $this->db->prepare($query);
636
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
-                } catch(PDOException $e) {
638
-                        echo "error : ".$e->getMessage();
639
-                }
640
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
633
+			$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";
634
+				 try {
635
+						$sth = $this->db->prepare($query);
636
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
+				} catch(PDOException $e) {
638
+						echo "error : ".$e->getMessage();
639
+				}
640
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
641 641
                 
642
-                if (empty($all)) {
642
+				if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645 645
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
646 646
 			}
647
-            		$Spotter = new Spotter($this->db);
648
-            		$all = $Spotter->countAllMonths($filters);
649
-                }
647
+					$Spotter = new Spotter($this->db);
648
+					$all = $Spotter->countAllMonths($filters);
649
+				}
650 650
                 
651
-                return $all;
651
+				return $all;
652 652
 	}
653 653
 	public function countAllMilitaryMonths($filter_name = '') {
654 654
 		global $globalStatsFilters;
655 655
 		if ($filter_name == '') $filter_name = $this->filter_name;
656
-	    	$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";
657
-                 try {
658
-                        $sth = $this->db->prepare($query);
659
-                        $sth->execute(array(':filter_name' => $filter_name));
660
-                } catch(PDOException $e) {
661
-                        echo "error : ".$e->getMessage();
662
-                }
663
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
-                if (empty($all)) {
665
-            		$filters = array();
666
-            		if ($filter_name != '') {
667
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
656
+			$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";
657
+				 try {
658
+						$sth = $this->db->prepare($query);
659
+						$sth->execute(array(':filter_name' => $filter_name));
660
+				} catch(PDOException $e) {
661
+						echo "error : ".$e->getMessage();
662
+				}
663
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
+				if (empty($all)) {
665
+					$filters = array();
666
+					if ($filter_name != '') {
667
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
668 668
 			}
669
-            		$Spotter = new Spotter($this->db);
670
-            		$all = $Spotter->countAllMilitaryMonths($filters);
671
-                }
672
-                return $all;
669
+					$Spotter = new Spotter($this->db);
670
+					$all = $Spotter->countAllMilitaryMonths($filters);
671
+				}
672
+				return $all;
673 673
 	}
674 674
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
675 675
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -685,22 +685,22 @@  discard block
 block discarded – undo
685 685
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
686 686
 		}
687 687
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
688
-                 try {
689
-                        $sth = $this->db->prepare($query);
690
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
-                } catch(PDOException $e) {
692
-                        echo "error : ".$e->getMessage();
693
-                }
694
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
-                if (empty($all)) {
688
+				 try {
689
+						$sth = $this->db->prepare($query);
690
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
+				} catch(PDOException $e) {
692
+						echo "error : ".$e->getMessage();
693
+				}
694
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
+				if (empty($all)) {
696 696
 			$filters = array('airlines' => array($stats_airline));
697 697
 			if ($filter_name != '') {
698
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
698
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
699 699
 			}
700
-            		$Spotter = new Spotter($this->db);
701
-            		$all = $Spotter->countAllHours($orderby,$filters);
702
-                }
703
-                return $all;
700
+					$Spotter = new Spotter($this->db);
701
+					$all = $Spotter->countAllHours($orderby,$filters);
702
+				}
703
+				return $all;
704 704
 	}
705 705
 	
706 706
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
@@ -724,9 +724,9 @@  discard block
 block discarded – undo
724 724
 		if ($year == '') $year = date('Y');
725 725
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
726 726
 		if (empty($all)) {
727
-		        $filters = array();
728
-            		if ($filter_name != '') {
729
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
727
+				$filters = array();
728
+					if ($filter_name != '') {
729
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
730 730
 			}
731 731
 			$Spotter = new Spotter($this->db);
732 732
 			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -787,9 +787,9 @@  discard block
 block discarded – undo
787 787
 			$all = $result[0]['nb_airline'];
788 788
 		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
789 789
 		if (empty($all)) {
790
-            		$filters = array();
791
-            		if ($filter_name != '') {
792
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
790
+					$filters = array();
791
+					if ($filter_name != '') {
792
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
793 793
 			}
794 794
 			$Spotter = new Spotter($this->db);
795 795
 			$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -856,33 +856,33 @@  discard block
 block discarded – undo
856 856
 		if ($filter_name == '') $filter_name = $this->filter_name;
857 857
 		$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";
858 858
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
859
-                 try {
860
-                        $sth = $this->db->prepare($query);
861
-                        $sth->execute($query_values);
862
-                } catch(PDOException $e) {
863
-                        echo "error : ".$e->getMessage();
864
-                }
865
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
866
-                return $all;
859
+				 try {
860
+						$sth = $this->db->prepare($query);
861
+						$sth->execute($query_values);
862
+				} catch(PDOException $e) {
863
+						echo "error : ".$e->getMessage();
864
+				}
865
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
866
+				return $all;
867 867
 	}
868 868
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
869 869
 		if ($filter_name == '') $filter_name = $this->filter_name;
870
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
871
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
872
-                 try {
873
-                        $sth = $this->db->prepare($query);
874
-                        $sth->execute($query_values);
875
-                } catch(PDOException $e) {
876
-                        echo "error : ".$e->getMessage();
877
-                }
878
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
879
-                return $all;
880
-        }
870
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
871
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
872
+				 try {
873
+						$sth = $this->db->prepare($query);
874
+						$sth->execute($query_values);
875
+				} catch(PDOException $e) {
876
+						echo "error : ".$e->getMessage();
877
+				}
878
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
879
+				return $all;
880
+		}
881 881
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
882 882
 		if ($filter_name == '') $filter_name = $this->filter_name;
883
-    		global $globalArchiveMonths, $globalDBdriver;
884
-    		if ($globalDBdriver == 'mysql') {
885
-    			if ($month == '') {
883
+			global $globalArchiveMonths, $globalDBdriver;
884
+			if ($globalDBdriver == 'mysql') {
885
+				if ($month == '') {
886 886
 				$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";
887 887
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
888 888
 			} else {
@@ -897,165 +897,165 @@  discard block
 block discarded – undo
897 897
 				$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";
898 898
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
899 899
 			}
900
-                }
901
-                 try {
902
-                        $sth = $this->db->prepare($query);
903
-                        $sth->execute($query_values);
904
-                } catch(PDOException $e) {
905
-                        echo "error : ".$e->getMessage();
906
-                }
907
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
908
-                return $all[0]['total'];
909
-        }
900
+				}
901
+				 try {
902
+						$sth = $this->db->prepare($query);
903
+						$sth->execute($query_values);
904
+				} catch(PDOException $e) {
905
+						echo "error : ".$e->getMessage();
906
+				}
907
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
908
+				return $all[0]['total'];
909
+		}
910 910
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
911
-    		global $globalArchiveMonths, $globalDBdriver;
911
+			global $globalArchiveMonths, $globalDBdriver;
912 912
 		if ($filter_name == '') $filter_name = $this->filter_name;
913
-    		if ($globalDBdriver == 'mysql') {
913
+			if ($globalDBdriver == 'mysql') {
914 914
 			$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";
915 915
 		} else {
916 916
 			$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";
917
-                }
918
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
919
-                 try {
920
-                        $sth = $this->db->prepare($query);
921
-                        $sth->execute($query_values);
922
-                } catch(PDOException $e) {
923
-                        echo "error : ".$e->getMessage();
924
-                }
925
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
926
-                return $all[0]['total'];
927
-        }
917
+				}
918
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
919
+				 try {
920
+						$sth = $this->db->prepare($query);
921
+						$sth->execute($query_values);
922
+				} catch(PDOException $e) {
923
+						echo "error : ".$e->getMessage();
924
+				}
925
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
926
+				return $all[0]['total'];
927
+		}
928 928
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
929
-    		global $globalArchiveMonths, $globalDBdriver;
929
+			global $globalArchiveMonths, $globalDBdriver;
930 930
 		if ($filter_name == '') $filter_name = $this->filter_name;
931
-    		if ($globalDBdriver == 'mysql') {
931
+			if ($globalDBdriver == 'mysql') {
932 932
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
933
-                } else {
933
+				} else {
934 934
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
935
-                }
936
-                 try {
937
-                        $sth = $this->db->prepare($query);
938
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
939
-                } catch(PDOException $e) {
940
-                        echo "error : ".$e->getMessage();
941
-                }
942
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
943
-                return $all[0]['total'];
944
-        }
935
+				}
936
+				 try {
937
+						$sth = $this->db->prepare($query);
938
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
939
+				} catch(PDOException $e) {
940
+						echo "error : ".$e->getMessage();
941
+				}
942
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
943
+				return $all[0]['total'];
944
+		}
945 945
 	public function getStatsAirlineTotal($filter_name = '') {
946
-    		global $globalArchiveMonths, $globalDBdriver;
946
+			global $globalArchiveMonths, $globalDBdriver;
947 947
 		if ($filter_name == '') $filter_name = $this->filter_name;
948
-    		if ($globalDBdriver == 'mysql') {
948
+			if ($globalDBdriver == 'mysql') {
949 949
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
950
-                } else {
950
+				} else {
951 951
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
952
-                }
953
-                 try {
954
-                        $sth = $this->db->prepare($query);
955
-                        $sth->execute(array(':filter_name' => $filter_name));
956
-                } catch(PDOException $e) {
957
-                        echo "error : ".$e->getMessage();
958
-                }
959
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
960
-                return $all[0]['total'];
961
-        }
952
+				}
953
+				 try {
954
+						$sth = $this->db->prepare($query);
955
+						$sth->execute(array(':filter_name' => $filter_name));
956
+				} catch(PDOException $e) {
957
+						echo "error : ".$e->getMessage();
958
+				}
959
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
960
+				return $all[0]['total'];
961
+		}
962 962
 	public function getStatsOwnerTotal($filter_name = '') {
963
-    		global $globalArchiveMonths, $globalDBdriver;
963
+			global $globalArchiveMonths, $globalDBdriver;
964 964
 		if ($filter_name == '') $filter_name = $this->filter_name;
965
-    		if ($globalDBdriver == 'mysql') {
965
+			if ($globalDBdriver == 'mysql') {
966 966
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
967 967
 		} else {
968 968
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
969
-                }
970
-                 try {
971
-                        $sth = $this->db->prepare($query);
972
-                        $sth->execute(array(':filter_name' => $filter_name));
973
-                } catch(PDOException $e) {
974
-                        echo "error : ".$e->getMessage();
975
-                }
976
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
977
-                return $all[0]['total'];
978
-        }
969
+				}
970
+				 try {
971
+						$sth = $this->db->prepare($query);
972
+						$sth->execute(array(':filter_name' => $filter_name));
973
+				} catch(PDOException $e) {
974
+						echo "error : ".$e->getMessage();
975
+				}
976
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
977
+				return $all[0]['total'];
978
+		}
979 979
 	public function getStatsOwner($owner_name,$filter_name = '') {
980
-    		global $globalArchiveMonths, $globalDBdriver;
980
+			global $globalArchiveMonths, $globalDBdriver;
981 981
 		if ($filter_name == '') $filter_name = $this->filter_name;
982 982
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
983
-                 try {
984
-                        $sth = $this->db->prepare($query);
985
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
986
-                } catch(PDOException $e) {
987
-                        echo "error : ".$e->getMessage();
988
-                }
989
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
990
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
991
-                else return 0;
992
-        }
983
+				 try {
984
+						$sth = $this->db->prepare($query);
985
+						$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
986
+				} catch(PDOException $e) {
987
+						echo "error : ".$e->getMessage();
988
+				}
989
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
990
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
991
+				else return 0;
992
+		}
993 993
 	public function getStatsPilotTotal($filter_name = '') {
994
-    		global $globalArchiveMonths, $globalDBdriver;
994
+			global $globalArchiveMonths, $globalDBdriver;
995 995
 		if ($filter_name == '') $filter_name = $this->filter_name;
996
-    		if ($globalDBdriver == 'mysql') {
997
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
998
-            	} else {
999
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1000
-            	}
1001
-                 try {
1002
-                        $sth = $this->db->prepare($query);
1003
-                        $sth->execute(array(':filter_name' => $filter_name));
1004
-                } catch(PDOException $e) {
1005
-                        echo "error : ".$e->getMessage();
1006
-                }
1007
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1008
-                return $all[0]['total'];
1009
-        }
996
+			if ($globalDBdriver == 'mysql') {
997
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
998
+				} else {
999
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1000
+				}
1001
+				 try {
1002
+						$sth = $this->db->prepare($query);
1003
+						$sth->execute(array(':filter_name' => $filter_name));
1004
+				} catch(PDOException $e) {
1005
+						echo "error : ".$e->getMessage();
1006
+				}
1007
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1008
+				return $all[0]['total'];
1009
+		}
1010 1010
 	public function getStatsPilot($pilot,$filter_name = '') {
1011
-    		global $globalArchiveMonths, $globalDBdriver;
1011
+			global $globalArchiveMonths, $globalDBdriver;
1012 1012
 		if ($filter_name == '') $filter_name = $this->filter_name;
1013 1013
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1014
-                 try {
1015
-                        $sth = $this->db->prepare($query);
1016
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1017
-                } catch(PDOException $e) {
1018
-                        echo "error : ".$e->getMessage();
1019
-                }
1020
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1021
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1022
-                else return 0;
1023
-        }
1014
+				 try {
1015
+						$sth = $this->db->prepare($query);
1016
+						$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1017
+				} catch(PDOException $e) {
1018
+						echo "error : ".$e->getMessage();
1019
+				}
1020
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1021
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1022
+				else return 0;
1023
+		}
1024 1024
 
1025 1025
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1026 1026
 		global $globalDBdriver;
1027 1027
 		if ($filter_name == '') $filter_name = $this->filter_name;
1028 1028
 		if ($globalDBdriver == 'mysql') {
1029 1029
 			$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";
1030
-                } else {
1030
+				} else {
1031 1031
 			$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);"; 
1032 1032
 		}
1033
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1034
-                 try {
1035
-                        $sth = $this->db->prepare($query);
1036
-                        $sth->execute($query_values);
1037
-                } catch(PDOException $e) {
1038
-                        return "error : ".$e->getMessage();
1039
-                }
1040
-        }
1033
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1034
+				 try {
1035
+						$sth = $this->db->prepare($query);
1036
+						$sth->execute($query_values);
1037
+				} catch(PDOException $e) {
1038
+						return "error : ".$e->getMessage();
1039
+				}
1040
+		}
1041 1041
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1042 1042
 		global $globalDBdriver;
1043 1043
 		if ($filter_name == '') $filter_name = $this->filter_name;
1044 1044
 		if ($globalDBdriver == 'mysql') {
1045 1045
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1046 1046
 		} else {
1047
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1047
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1048 1048
 			$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);"; 
1049
-                }
1050
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1051
-                 try {
1052
-                        $sth = $this->db->prepare($query);
1053
-                        $sth->execute($query_values);
1054
-                } catch(PDOException $e) {
1055
-                        return "error : ".$e->getMessage();
1056
-                }
1057
-        }
1058
-        /*
1049
+				}
1050
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1051
+				 try {
1052
+						$sth = $this->db->prepare($query);
1053
+						$sth->execute($query_values);
1054
+				} catch(PDOException $e) {
1055
+						return "error : ".$e->getMessage();
1056
+				}
1057
+		}
1058
+		/*
1059 1059
 	public function getStatsSource($date,$stats_type = '') {
1060 1060
 		if ($stats_type == '') {
1061 1061
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -1124,25 +1124,25 @@  discard block
 block discarded – undo
1124 1124
 			$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";
1125 1125
 		} else {
1126 1126
 			$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);"; 
1127
-                }
1128
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1129
-                 try {
1130
-                        $sth = $this->db->prepare($query);
1131
-                        $sth->execute($query_values);
1132
-                } catch(PDOException $e) {
1133
-                        return "error : ".$e->getMessage();
1134
-                }
1135
-        }
1136
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1137
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1138
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1139
-                 try {
1140
-                        $sth = $this->db->prepare($query);
1141
-                        $sth->execute($query_values);
1142
-                } catch(PDOException $e) {
1143
-                        return "error : ".$e->getMessage();
1144
-                }
1145
-        }
1127
+				}
1128
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1129
+				 try {
1130
+						$sth = $this->db->prepare($query);
1131
+						$sth->execute($query_values);
1132
+				} catch(PDOException $e) {
1133
+						return "error : ".$e->getMessage();
1134
+				}
1135
+		}
1136
+	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1137
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1138
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1139
+				 try {
1140
+						$sth = $this->db->prepare($query);
1141
+						$sth->execute($query_values);
1142
+				} catch(PDOException $e) {
1143
+						return "error : ".$e->getMessage();
1144
+				}
1145
+		}
1146 1146
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1147 1147
 		global $globalDBdriver;
1148 1148
 		if ($globalDBdriver == 'mysql') {
@@ -1158,14 +1158,14 @@  discard block
 block discarded – undo
1158 1158
 				$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);"; 
1159 1159
 			}
1160 1160
 		}
1161
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1162
-                 try {
1163
-                        $sth = $this->db->prepare($query);
1164
-                        $sth->execute($query_values);
1165
-                } catch(PDOException $e) {
1166
-                        return "error : ".$e->getMessage();
1167
-                }
1168
-        }
1161
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1162
+				 try {
1163
+						$sth = $this->db->prepare($query);
1164
+						$sth->execute($query_values);
1165
+				} catch(PDOException $e) {
1166
+						return "error : ".$e->getMessage();
1167
+				}
1168
+		}
1169 1169
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1170 1170
 		global $globalDBdriver;
1171 1171
 		if ($globalDBdriver == 'mysql') {
@@ -1181,14 +1181,14 @@  discard block
 block discarded – undo
1181 1181
 				$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);"; 
1182 1182
 			}
1183 1183
 		}
1184
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1185
-                 try {
1186
-                        $sth = $this->db->prepare($query);
1187
-                        $sth->execute($query_values);
1188
-                } catch(PDOException $e) {
1189
-                        return "error : ".$e->getMessage();
1190
-                }
1191
-        }
1184
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1185
+				 try {
1186
+						$sth = $this->db->prepare($query);
1187
+						$sth->execute($query_values);
1188
+				} catch(PDOException $e) {
1189
+						return "error : ".$e->getMessage();
1190
+				}
1191
+		}
1192 1192
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1193 1193
 		global $globalDBdriver;
1194 1194
 		if ($globalDBdriver == 'mysql') {
@@ -1204,14 +1204,14 @@  discard block
 block discarded – undo
1204 1204
 				$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);"; 
1205 1205
 			}
1206 1206
 		}
1207
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1208
-                 try {
1209
-                        $sth = $this->db->prepare($query);
1210
-                        $sth->execute($query_values);
1211
-                } catch(PDOException $e) {
1212
-                        return "error : ".$e->getMessage();
1213
-                }
1214
-        }
1207
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1208
+				 try {
1209
+						$sth = $this->db->prepare($query);
1210
+						$sth->execute($query_values);
1211
+				} catch(PDOException $e) {
1212
+						return "error : ".$e->getMessage();
1213
+				}
1214
+		}
1215 1215
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1216 1216
 		global $globalDBdriver;
1217 1217
 		if ($globalDBdriver == 'mysql') {
@@ -1227,14 +1227,14 @@  discard block
 block discarded – undo
1227 1227
 				$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);"; 
1228 1228
 			}
1229 1229
 		}
1230
-                $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);
1231
-                 try {
1232
-                        $sth = $this->db->prepare($query);
1233
-                        $sth->execute($query_values);
1234
-                } catch(PDOException $e) {
1235
-                        return "error : ".$e->getMessage();
1236
-                }
1237
-        }
1230
+				$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);
1231
+				 try {
1232
+						$sth = $this->db->prepare($query);
1233
+						$sth->execute($query_values);
1234
+				} catch(PDOException $e) {
1235
+						return "error : ".$e->getMessage();
1236
+				}
1237
+		}
1238 1238
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1239 1239
 		global $globalDBdriver;
1240 1240
 		if ($globalDBdriver == 'mysql') {
@@ -1250,14 +1250,14 @@  discard block
 block discarded – undo
1250 1250
 				$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);"; 
1251 1251
 			}
1252 1252
 		}
1253
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1254
-                 try {
1255
-                        $sth = $this->db->prepare($query);
1256
-                        $sth->execute($query_values);
1257
-                } catch(PDOException $e) {
1258
-                        return "error : ".$e->getMessage();
1259
-                }
1260
-        }
1253
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1254
+				 try {
1255
+						$sth = $this->db->prepare($query);
1256
+						$sth->execute($query_values);
1257
+				} catch(PDOException $e) {
1258
+						return "error : ".$e->getMessage();
1259
+				}
1260
+		}
1261 1261
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1262 1262
 		global $globalDBdriver;
1263 1263
 		if ($globalDBdriver == 'mysql') {
@@ -1273,14 +1273,14 @@  discard block
 block discarded – undo
1273 1273
 				$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);"; 
1274 1274
 			}
1275 1275
 		}
1276
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1277
-                 try {
1278
-                        $sth = $this->db->prepare($query);
1279
-                        $sth->execute($query_values);
1280
-                } catch(PDOException $e) {
1281
-                        return "error : ".$e->getMessage();
1282
-                }
1283
-        }
1276
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1277
+				 try {
1278
+						$sth = $this->db->prepare($query);
1279
+						$sth->execute($query_values);
1280
+				} catch(PDOException $e) {
1281
+						return "error : ".$e->getMessage();
1282
+				}
1283
+		}
1284 1284
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1285 1285
 		global $globalDBdriver;
1286 1286
 		if ($globalDBdriver == 'mysql') {
@@ -1296,14 +1296,14 @@  discard block
 block discarded – undo
1296 1296
 				$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);"; 
1297 1297
 			}
1298 1298
 		}
1299
-                $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);
1300
-                 try {
1301
-                        $sth = $this->db->prepare($query);
1302
-                        $sth->execute($query_values);
1303
-                } catch(PDOException $e) {
1304
-                        return "error : ".$e->getMessage();
1305
-                }
1306
-        }
1299
+				$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);
1300
+				 try {
1301
+						$sth = $this->db->prepare($query);
1302
+						$sth->execute($query_values);
1303
+				} catch(PDOException $e) {
1304
+						return "error : ".$e->getMessage();
1305
+				}
1306
+		}
1307 1307
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1308 1308
 		global $globalDBdriver;
1309 1309
 		if ($airport_icao != '') {
@@ -1327,8 +1327,8 @@  discard block
 block discarded – undo
1327 1327
 			} catch(PDOException $e) {
1328 1328
 				return "error : ".$e->getMessage();
1329 1329
 			}
1330
-                }
1331
-        }
1330
+				}
1331
+		}
1332 1332
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1333 1333
 		global $globalDBdriver;
1334 1334
 		if ($airport_icao != '') {
@@ -1344,8 +1344,8 @@  discard block
 block discarded – undo
1344 1344
 			} catch(PDOException $e) {
1345 1345
 				return "error : ".$e->getMessage();
1346 1346
 			}
1347
-                }
1348
-        }
1347
+				}
1348
+		}
1349 1349
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1350 1350
 		global $globalDBdriver;
1351 1351
 		if ($airport_icao != '') {
@@ -1362,15 +1362,15 @@  discard block
 block discarded – undo
1362 1362
 					$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);"; 
1363 1363
 				}
1364 1364
 			}
1365
-	                $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);
1365
+					$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);
1366 1366
 			 try {
1367
-                    		$sth = $this->db->prepare($query);
1368
-	                        $sth->execute($query_values);
1369
-    		        } catch(PDOException $e) {
1370
-            		        return "error : ".$e->getMessage();
1371
-	                }
1372
-	        }
1373
-        }
1367
+							$sth = $this->db->prepare($query);
1368
+							$sth->execute($query_values);
1369
+					} catch(PDOException $e) {
1370
+							return "error : ".$e->getMessage();
1371
+					}
1372
+			}
1373
+		}
1374 1374
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1375 1375
 		global $globalDBdriver;
1376 1376
 		if ($airport_icao != '') {
@@ -1386,46 +1386,46 @@  discard block
 block discarded – undo
1386 1386
 			} catch(PDOException $e) {
1387 1387
 				return "error : ".$e->getMessage();
1388 1388
 			}
1389
-                }
1390
-        }
1389
+				}
1390
+		}
1391 1391
 
1392 1392
 	public function deleteStat($id) {
1393
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1394
-                $query_values = array(':id' => $id);
1395
-                 try {
1396
-                        $sth = $this->db->prepare($query);
1397
-                        $sth->execute($query_values);
1398
-                } catch(PDOException $e) {
1399
-                        return "error : ".$e->getMessage();
1400
-                }
1401
-        }
1393
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1394
+				$query_values = array(':id' => $id);
1395
+				 try {
1396
+						$sth = $this->db->prepare($query);
1397
+						$sth->execute($query_values);
1398
+				} catch(PDOException $e) {
1399
+						return "error : ".$e->getMessage();
1400
+				}
1401
+		}
1402 1402
 	public function deleteStatFlight($type) {
1403
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1404
-                $query_values = array(':type' => $type);
1405
-                 try {
1406
-                        $sth = $this->db->prepare($query);
1407
-                        $sth->execute($query_values);
1408
-                } catch(PDOException $e) {
1409
-                        return "error : ".$e->getMessage();
1410
-                }
1411
-        }
1403
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1404
+				$query_values = array(':type' => $type);
1405
+				 try {
1406
+						$sth = $this->db->prepare($query);
1407
+						$sth->execute($query_values);
1408
+				} catch(PDOException $e) {
1409
+						return "error : ".$e->getMessage();
1410
+				}
1411
+		}
1412 1412
 	public function deleteStatAirport($type) {
1413
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1414
-                $query_values = array(':type' => $type);
1415
-                 try {
1416
-                        $sth = $this->db->prepare($query);
1417
-                        $sth->execute($query_values);
1418
-                } catch(PDOException $e) {
1419
-                        return "error : ".$e->getMessage();
1420
-                }
1421
-        }
1413
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1414
+				$query_values = array(':type' => $type);
1415
+				 try {
1416
+						$sth = $this->db->prepare($query);
1417
+						$sth->execute($query_values);
1418
+				} catch(PDOException $e) {
1419
+						return "error : ".$e->getMessage();
1420
+				}
1421
+		}
1422 1422
         
1423
-        public function addOldStats() {
1424
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1425
-    		$Common = new Common();
1426
-    		$Connection = new Connection();
1427
-    		date_default_timezone_set('UTC');
1428
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1423
+		public function addOldStats() {
1424
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1425
+			$Common = new Common();
1426
+			$Connection = new Connection();
1427
+			date_default_timezone_set('UTC');
1428
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1429 1429
 			if ($globalDebug) echo 'Update stats !'."\n";
1430 1430
 			if (isset($last_update[0]['value'])) {
1431 1431
 				$last_update_day = $last_update[0]['value'];
@@ -1471,24 +1471,24 @@  discard block
 block discarded – undo
1471 1471
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1472 1472
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1473 1473
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1474
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1474
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1475 1475
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1476
-	        	$alldata = array();
1476
+				$alldata = array();
1477 1477
 	        	
1478
-    			foreach ($pall as $value) {
1479
-	        		$icao = $value['airport_departure_icao'];
1480
-    				$alldata[$icao] = $value;
1481
-	        	}
1482
-	        	foreach ($dall as $value) {
1483
-    				$icao = $value['airport_departure_icao'];
1484
-        			if (isset($alldata[$icao])) {
1485
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1486
-        			} else $alldata[$icao] = $value;
1487
-			}
1488
-    			$count = array();
1489
-    			foreach ($alldata as $key => $row) {
1490
-    				$count[$key] = $row['airport_departure_icao_count'];
1491
-        		}
1478
+				foreach ($pall as $value) {
1479
+					$icao = $value['airport_departure_icao'];
1480
+					$alldata[$icao] = $value;
1481
+				}
1482
+				foreach ($dall as $value) {
1483
+					$icao = $value['airport_departure_icao'];
1484
+					if (isset($alldata[$icao])) {
1485
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1486
+					} else $alldata[$icao] = $value;
1487
+			}
1488
+				$count = array();
1489
+				foreach ($alldata as $key => $row) {
1490
+					$count[$key] = $row['airport_departure_icao_count'];
1491
+				}
1492 1492
 			array_multisort($count,SORT_DESC,$alldata);
1493 1493
 			foreach ($alldata as $number) {
1494 1494
 				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);
@@ -1496,25 +1496,25 @@  discard block
 block discarded – undo
1496 1496
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1497 1497
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1498 1498
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1499
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1499
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1500 1500
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1501
-	        	$alldata = array();
1502
-    			foreach ($pall as $value) {
1503
-	        		$icao = $value['airport_arrival_icao'];
1504
-    				$alldata[$icao] = $value;
1505
-	        	}
1506
-	        	foreach ($dall as $value) {
1507
-    				$icao = $value['airport_arrival_icao'];
1508
-        			if (isset($alldata[$icao])) {
1509
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1510
-	        		} else $alldata[$icao] = $value;
1511
-    			}
1512
-        		$count = array();
1513
-        		foreach ($alldata as $key => $row) {
1514
-        			$count[$key] = $row['airport_arrival_icao_count'];
1515
-	        	}
1516
-    			array_multisort($count,SORT_DESC,$alldata);
1517
-                        foreach ($alldata as $number) {
1501
+				$alldata = array();
1502
+				foreach ($pall as $value) {
1503
+					$icao = $value['airport_arrival_icao'];
1504
+					$alldata[$icao] = $value;
1505
+				}
1506
+				foreach ($dall as $value) {
1507
+					$icao = $value['airport_arrival_icao'];
1508
+					if (isset($alldata[$icao])) {
1509
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1510
+					} else $alldata[$icao] = $value;
1511
+				}
1512
+				$count = array();
1513
+				foreach ($alldata as $key => $row) {
1514
+					$count[$key] = $row['airport_arrival_icao_count'];
1515
+				}
1516
+				array_multisort($count,SORT_DESC,$alldata);
1517
+						foreach ($alldata as $number) {
1518 1518
 				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);
1519 1519
 			}
1520 1520
 			if ($Connection->tableExists('countries')) {
@@ -1574,8 +1574,8 @@  discard block
 block discarded – undo
1574 1574
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1575 1575
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1576 1576
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1577
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1578
-        		/*
1577
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1578
+				/*
1579 1579
 	        	$alldata = array();
1580 1580
     			foreach ($pall as $value) {
1581 1581
 	        		$icao = $value['departure_airport_icao'];
@@ -1594,29 +1594,29 @@  discard block
 block discarded – undo
1594 1594
 	        	}
1595 1595
     			array_multisort($count,SORT_DESC,$alldata);
1596 1596
     			*/
1597
-    			foreach ($dall as $value) {
1598
-    				$icao = $value['departure_airport_icao'];
1599
-    				$ddate = $value['date'];
1600
-    				$find = false;
1601
-    				foreach ($pall as $pvalue) {
1602
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1603
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1604
-    						$find = true;
1605
-    						break;
1606
-    					}
1607
-    				}
1608
-    				if ($find === false) {
1609
-    					$pall[] = $value;
1610
-    				}
1611
-    			}
1612
-    			$alldata = $pall;
1597
+				foreach ($dall as $value) {
1598
+					$icao = $value['departure_airport_icao'];
1599
+					$ddate = $value['date'];
1600
+					$find = false;
1601
+					foreach ($pall as $pvalue) {
1602
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1603
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1604
+							$find = true;
1605
+							break;
1606
+						}
1607
+					}
1608
+					if ($find === false) {
1609
+						$pall[] = $value;
1610
+					}
1611
+				}
1612
+				$alldata = $pall;
1613 1613
 			foreach ($alldata as $number) {
1614 1614
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1615 1615
 			}
1616 1616
 			echo '...Arrival'."\n";
1617 1617
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1618
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1619
-        		/*
1618
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1619
+				/*
1620 1620
 	        	$alldata = array();
1621 1621
     			foreach ($pall as $value) {
1622 1622
 	        		$icao = $value['arrival_airport_icao'];
@@ -1636,22 +1636,22 @@  discard block
 block discarded – undo
1636 1636
     			*/
1637 1637
 
1638 1638
 
1639
-    			foreach ($dall as $value) {
1640
-    				$icao = $value['arrival_airport_icao'];
1641
-    				$ddate = $value['date'];
1642
-    				$find = false;
1643
-    				foreach ($pall as $pvalue) {
1644
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1645
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1646
-    						$find = true;
1647
-    						break;
1648
-    					}
1649
-    				}
1650
-    				if ($find === false) {
1651
-    					$pall[] = $value;
1652
-    				}
1653
-    			}
1654
-    			$alldata = $pall;
1639
+				foreach ($dall as $value) {
1640
+					$icao = $value['arrival_airport_icao'];
1641
+					$ddate = $value['date'];
1642
+					$find = false;
1643
+					foreach ($pall as $pvalue) {
1644
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1645
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1646
+							$find = true;
1647
+							break;
1648
+						}
1649
+					}
1650
+					if ($find === false) {
1651
+						$pall[] = $value;
1652
+					}
1653
+				}
1654
+				$alldata = $pall;
1655 1655
 			foreach ($alldata as $number) {
1656 1656
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1657 1657
 			}
@@ -1726,51 +1726,51 @@  discard block
 block discarded – undo
1726 1726
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1727 1727
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1728 1728
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1729
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1729
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1730 1730
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1731
-	        	//$alldata = array();
1732
-    			foreach ($dall as $value) {
1733
-    				$icao = $value['airport_departure_icao'];
1734
-    				$dicao = $value['airline_icao'];
1735
-    				$find = false;
1736
-    				foreach ($pall as $pvalue) {
1737
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1738
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1739
-    						$find = true;
1740
-    						break;
1741
-    					}
1742
-    				}
1743
-    				if ($find === false) {
1744
-    					$pall[] = $value;
1745
-    				}
1746
-    			}
1747
-    			$alldata = $pall;
1731
+				//$alldata = array();
1732
+				foreach ($dall as $value) {
1733
+					$icao = $value['airport_departure_icao'];
1734
+					$dicao = $value['airline_icao'];
1735
+					$find = false;
1736
+					foreach ($pall as $pvalue) {
1737
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1738
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1739
+							$find = true;
1740
+							break;
1741
+						}
1742
+					}
1743
+					if ($find === false) {
1744
+						$pall[] = $value;
1745
+					}
1746
+				}
1747
+				$alldata = $pall;
1748 1748
 			foreach ($alldata as $number) {
1749 1749
 				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);
1750 1750
 			}
1751 1751
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1752 1752
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1753 1753
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1754
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1754
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1755 1755
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1756
-	        	//$alldata = array();
1757
-    			foreach ($dall as $value) {
1758
-    				$icao = $value['airport_arrival_icao'];
1759
-    				$dicao = $value['airline_icao'];
1760
-    				$find = false;
1761
-    				foreach ($pall as $pvalue) {
1762
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1763
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1764
-    						$find = true;
1765
-    						break;
1766
-    					}
1767
-    				}
1768
-    				if ($find === false) {
1769
-    					$pall[] = $value;
1770
-    				}
1771
-    			}
1772
-    			$alldata = $pall;
1773
-                        foreach ($alldata as $number) {
1756
+				//$alldata = array();
1757
+				foreach ($dall as $value) {
1758
+					$icao = $value['airport_arrival_icao'];
1759
+					$dicao = $value['airline_icao'];
1760
+					$find = false;
1761
+					foreach ($pall as $pvalue) {
1762
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1763
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1764
+							$find = true;
1765
+							break;
1766
+						}
1767
+					}
1768
+					if ($find === false) {
1769
+						$pall[] = $value;
1770
+					}
1771
+				}
1772
+				$alldata = $pall;
1773
+						foreach ($alldata as $number) {
1774 1774
 				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);
1775 1775
 			}
1776 1776
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1803,47 +1803,47 @@  discard block
 block discarded – undo
1803 1803
 			}
1804 1804
 			if ($globalDebug) echo '...Departure'."\n";
1805 1805
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1806
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1807
-    			foreach ($dall as $value) {
1808
-    				$icao = $value['departure_airport_icao'];
1809
-    				$airline = $value['airline_icao'];
1810
-    				$ddate = $value['date'];
1811
-    				$find = false;
1812
-    				foreach ($pall as $pvalue) {
1813
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1814
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1815
-    						$find = true;
1816
-    						break;
1817
-    					}
1818
-    				}
1819
-    				if ($find === false) {
1820
-    					$pall[] = $value;
1821
-    				}
1822
-    			}
1823
-    			$alldata = $pall;
1806
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1807
+				foreach ($dall as $value) {
1808
+					$icao = $value['departure_airport_icao'];
1809
+					$airline = $value['airline_icao'];
1810
+					$ddate = $value['date'];
1811
+					$find = false;
1812
+					foreach ($pall as $pvalue) {
1813
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1814
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1815
+							$find = true;
1816
+							break;
1817
+						}
1818
+					}
1819
+					if ($find === false) {
1820
+						$pall[] = $value;
1821
+					}
1822
+				}
1823
+				$alldata = $pall;
1824 1824
 			foreach ($alldata as $number) {
1825 1825
 				$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']);
1826 1826
 			}
1827 1827
 			if ($globalDebug) echo '...Arrival'."\n";
1828 1828
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1829
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1830
-    			foreach ($dall as $value) {
1831
-    				$icao = $value['arrival_airport_icao'];
1832
-    				$airline = $value['airline_icao'];
1833
-    				$ddate = $value['date'];
1834
-    				$find = false;
1835
-    				foreach ($pall as $pvalue) {
1836
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1837
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1838
-    						$find = true;
1839
-    						break;
1840
-    					}
1841
-    				}
1842
-    				if ($find === false) {
1843
-    					$pall[] = $value;
1844
-    				}
1845
-    			}
1846
-    			$alldata = $pall;
1829
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1830
+				foreach ($dall as $value) {
1831
+					$icao = $value['arrival_airport_icao'];
1832
+					$airline = $value['airline_icao'];
1833
+					$ddate = $value['date'];
1834
+					$find = false;
1835
+					foreach ($pall as $pvalue) {
1836
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1837
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1838
+							$find = true;
1839
+							break;
1840
+						}
1841
+					}
1842
+					if ($find === false) {
1843
+						$pall[] = $value;
1844
+					}
1845
+				}
1846
+				$alldata = $pall;
1847 1847
 			foreach ($alldata as $number) {
1848 1848
 				$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']);
1849 1849
 			}
@@ -1914,44 +1914,44 @@  discard block
 block discarded – undo
1914 1914
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1915 1915
 				}
1916 1916
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1917
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1918
-		        	$alldata = array();
1919
-	    			foreach ($pall as $value) {
1920
-		        		$icao = $value['airport_departure_icao'];
1921
-    					$alldata[$icao] = $value;
1922
-	    			}
1923
-		        	foreach ($dall as $value) {
1924
-	    				$icao = $value['airport_departure_icao'];
1925
-        				if (isset($alldata[$icao])) {
1926
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1927
-        				} else $alldata[$icao] = $value;
1928
-				}
1929
-	    			$count = array();
1930
-    				foreach ($alldata as $key => $row) {
1931
-    					$count[$key] = $row['airport_departure_icao_count'];
1932
-    				}
1917
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1918
+					$alldata = array();
1919
+					foreach ($pall as $value) {
1920
+						$icao = $value['airport_departure_icao'];
1921
+						$alldata[$icao] = $value;
1922
+					}
1923
+					foreach ($dall as $value) {
1924
+						$icao = $value['airport_departure_icao'];
1925
+						if (isset($alldata[$icao])) {
1926
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1927
+						} else $alldata[$icao] = $value;
1928
+				}
1929
+					$count = array();
1930
+					foreach ($alldata as $key => $row) {
1931
+						$count[$key] = $row['airport_departure_icao_count'];
1932
+					}
1933 1933
 				array_multisort($count,SORT_DESC,$alldata);
1934 1934
 				foreach ($alldata as $number) {
1935
-    					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);
1935
+						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);
1936 1936
 				}
1937 1937
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1938
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1938
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1939 1939
 				$alldata = array();
1940
-    				foreach ($pall as $value) {
1941
-		        		$icao = $value['airport_arrival_icao'];
1942
-    					$alldata[$icao] = $value;
1943
-	    			}
1944
-		        	foreach ($dall as $value) {
1945
-	    				$icao = $value['airport_arrival_icao'];
1946
-        				if (isset($alldata[$icao])) {
1947
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1948
-		        		} else $alldata[$icao] = $value;
1949
-	    			}
1950
-        			$count = array();
1951
-        			foreach ($alldata as $key => $row) {
1952
-    					$count[$key] = $row['airport_arrival_icao_count'];
1953
-		        	}
1954
-        			array_multisort($count,SORT_DESC,$alldata);
1940
+					foreach ($pall as $value) {
1941
+						$icao = $value['airport_arrival_icao'];
1942
+						$alldata[$icao] = $value;
1943
+					}
1944
+					foreach ($dall as $value) {
1945
+						$icao = $value['airport_arrival_icao'];
1946
+						if (isset($alldata[$icao])) {
1947
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1948
+						} else $alldata[$icao] = $value;
1949
+					}
1950
+					$count = array();
1951
+					foreach ($alldata as $key => $row) {
1952
+						$count[$key] = $row['airport_arrival_icao_count'];
1953
+					}
1954
+					array_multisort($count,SORT_DESC,$alldata);
1955 1955
 				foreach ($alldata as $number) {
1956 1956
 					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);
1957 1957
 				}
@@ -1984,45 +1984,45 @@  discard block
 block discarded – undo
1984 1984
 				}
1985 1985
 				echo '...Departure'."\n";
1986 1986
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1987
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1987
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1988 1988
 				foreach ($dall as $value) {
1989
-    					$icao = $value['departure_airport_icao'];
1990
-    					$ddate = $value['date'];
1991
-    					$find = false;
1992
-    					foreach ($pall as $pvalue) {
1993
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1994
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1995
-	    						$find = true;
1996
-    							break;
1997
-    						}
1998
-    					}
1999
-    					if ($find === false) {
2000
-    						$pall[] = $value;
2001
-	    				}
2002
-    				}
2003
-	    			$alldata = $pall;
1989
+						$icao = $value['departure_airport_icao'];
1990
+						$ddate = $value['date'];
1991
+						$find = false;
1992
+						foreach ($pall as $pvalue) {
1993
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1994
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1995
+								$find = true;
1996
+								break;
1997
+							}
1998
+						}
1999
+						if ($find === false) {
2000
+							$pall[] = $value;
2001
+						}
2002
+					}
2003
+					$alldata = $pall;
2004 2004
 				foreach ($alldata as $number) {
2005 2005
 					$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);
2006 2006
 				}
2007 2007
 				echo '...Arrival'."\n";
2008 2008
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2009
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2009
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2010 2010
 				foreach ($dall as $value) {
2011 2011
 					$icao = $value['arrival_airport_icao'];
2012 2012
 					$ddate = $value['date'];
2013
-    					$find = false;
2013
+						$find = false;
2014 2014
 					foreach ($pall as $pvalue) {
2015
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2016
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2017
-    							$find = true;
2018
-    							break;
2019
-	    					}
2020
-    					}
2021
-    					if ($find === false) {
2022
-    						$pall[] = $value;
2023
-	    				}
2024
-    				}
2025
-    				$alldata = $pall;
2015
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2016
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2017
+								$find = true;
2018
+								break;
2019
+							}
2020
+						}
2021
+						if ($find === false) {
2022
+							$pall[] = $value;
2023
+						}
2024
+					}
2025
+					$alldata = $pall;
2026 2026
 				foreach ($alldata as $number) {
2027 2027
 					$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);
2028 2028
 				}
Please login to merge, or discard this patch.
Spacing   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
-	public function addLastStatsUpdate($type,$stats_date) {
20
+	public function addLastStatsUpdate($type, $stats_date) {
21 21
                 $query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
23
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
24 24
                  try {
25 25
                         $sth = $this->db->prepare($query);
26 26
                         $sth->execute($query_values);
27
-                } catch(PDOException $e) {
27
+                } catch (PDOException $e) {
28 28
                         return "error : ".$e->getMessage();
29 29
                 }
30 30
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                  try {
35 35
                         $sth = $this->db->prepare($query);
36 36
                         $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
37
+                } catch (PDOException $e) {
38 38
                         echo "error : ".$e->getMessage();
39 39
                 }
40 40
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                  try {
55 55
                         $sth = $this->db->prepare($query);
56 56
                         $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                  try {
65 65
                         $sth = $this->db->prepare($query);
66 66
                         $sth->execute();
67
-                } catch(PDOException $e) {
67
+                } catch (PDOException $e) {
68 68
                         return "error : ".$e->getMessage();
69 69
                 }
70 70
                 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                  try {
73 73
                         $sth = $this->db->prepare($query);
74 74
                         $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
75
+                } catch (PDOException $e) {
76 76
                         return "error : ".$e->getMessage();
77 77
                 }
78 78
         }
@@ -82,69 +82,69 @@  discard block
 block discarded – undo
82 82
                  try {
83 83
                         $sth = $this->db->prepare($query);
84 84
                         $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
85
+                } catch (PDOException $e) {
86 86
                         echo "error : ".$e->getMessage();
87 87
                 }
88 88
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89 89
                 return $all;
90 90
         }
91
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
91
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93 93
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 94
                  try {
95 95
                         $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
96
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
97
+                } catch (PDOException $e) {
98 98
                         echo "error : ".$e->getMessage();
99 99
                 }
100 100
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101 101
                 return $all;
102 102
         }
103
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
103
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105 105
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 106
                  try {
107 107
                         $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
108
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
109
+                } catch (PDOException $e) {
110 110
                         echo "error : ".$e->getMessage();
111 111
                 }
112 112
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113 113
                 return $all;
114 114
         }
115
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
115
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117 117
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 118
                  try {
119 119
                         $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
120
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
121
+                } catch (PDOException $e) {
122 122
                         echo "error : ".$e->getMessage();
123 123
                 }
124 124
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125 125
                 return $all;
126 126
         }
127 127
 
128
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
128
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130 130
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 131
                  try {
132 132
                         $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
133
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
134
+                } catch (PDOException $e) {
135 135
                         echo "error : ".$e->getMessage();
136 136
                 }
137 137
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138 138
                 return $all;
139 139
         }
140 140
 
141
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
141
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143 143
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144 144
                  try {
145 145
                         $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
146
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
147
+                } catch (PDOException $e) {
148 148
                         echo "error : ".$e->getMessage();
149 149
                 }
150 150
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         }
153 153
 
154 154
 
155
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
155
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
156 156
 		global $globalStatsFilters;
157 157
 		if ($filter_name == '') $filter_name = $this->filter_name;
158 158
 		if ($year == '' && $month == '') {
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 			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";
161 161
 			try {
162 162
 				$sth = $this->db->prepare($query);
163
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
164
-			} catch(PDOException $e) {
163
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
164
+			} catch (PDOException $e) {
165 165
 				echo "error : ".$e->getMessage();
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
                 if (empty($all)) {
170 170
             	    $filters = array('airlines' => array($stats_airline));
171 171
             	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
172
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
173 173
             	    }
174 174
             	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
175
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters, $year, $month);
176 176
                 }
177 177
                 return $all;
178 178
 	}
179
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
179
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
180 180
 		global $globalStatsFilters;
181 181
 		if ($filter_name == '') $filter_name = $this->filter_name;
182 182
 		if ($year == '' && $month == '') {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			try {
186 186
 				$sth = $this->db->prepare($query);
187 187
 				$sth->execute(array(':filter_name' => $filter_name));
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				echo "error : ".$e->getMessage();
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
             		$Spotter = new Spotter($this->db);
195 195
             		$filters = array();
196 196
             		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
197
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
199
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters, $year, $month);
200 200
                 }
201 201
                 return $all;
202 202
 	}
203
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
203
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
204 204
 		global $globalStatsFilters;
205 205
 		if ($filter_name == '') $filter_name = $this->filter_name;
206 206
 		if ($year == '' && $month == '') {
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			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";
209 209
 			try {
210 210
 				$sth = $this->db->prepare($query);
211
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
212
-			} catch(PDOException $e) {
211
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
212
+			} catch (PDOException $e) {
213 213
 				echo "error : ".$e->getMessage();
214 214
 			}
215 215
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 		if (empty($all)) {
218 218
 			$filters = array('airlines' => array($stats_airline));
219 219
 			if ($filter_name != '') {
220
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
220
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
221 221
 			}
222 222
 			$Spotter = new Spotter($this->db);
223
-			$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
223
+			$all = $Spotter->countAllAircraftManufacturers($filters, $year, $month);
224 224
 		}
225 225
 		return $all;
226 226
 	}
227 227
 
228
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
228
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
229 229
 		global $globalStatsFilters;
230 230
 		if ($filter_name == '') $filter_name = $this->filter_name;
231 231
 		if ($year == '' && $month == '') {
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 			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";
234 234
 			try {
235 235
 				$sth = $this->db->prepare($query);
236
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
237
-			} catch(PDOException $e) {
236
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
237
+			} catch (PDOException $e) {
238 238
 				echo "error : ".$e->getMessage();
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
                 if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
244 244
 			if ($filter_name != '') {
245
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Spotter = new Spotter($this->db);
248
-			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
248
+			$all = $Spotter->countAllArrivalCountries($limit, $filters, $year, $month);
249 249
                 }
250 250
                 return $all;
251 251
 	}
@@ -256,23 +256,23 @@  discard block
 block discarded – undo
256 256
 		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";
257 257
                  try {
258 258
                         $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
259
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
260
+                } catch (PDOException $e) {
261 261
                         echo "error : ".$e->getMessage();
262 262
                 }
263 263
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264 264
                 if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270
-			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
270
+			$all = $Spotter->countAllDepartureCountries($filters, $year, $month);
271 271
                 }
272 272
                 return $all;
273 273
 	}
274 274
 
275
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
275
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
276 276
 		global $globalStatsFilters;
277 277
 		if ($filter_name == '') $filter_name = $this->filter_name;
278 278
 		if ($year == '' && $month == '') {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			try {
282 282
 				$sth = $this->db->prepare($query);
283 283
 				$sth->execute(array(':filter_name' => $filter_name));
284
-			} catch(PDOException $e) {
284
+			} catch (PDOException $e) {
285 285
 				echo "error : ".$e->getMessage();
286 286
 			}
287 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 	                $Spotter = new Spotter($this->db);
291 291
             		$filters = array();
292 292
             		if ($filter_name != '') {
293
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
293
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
294 294
 			}
295 295
 
296
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
296
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters, $year, $month);
297 297
                 }
298 298
                 return $all;
299 299
 	}
300
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
300
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
301 301
 		global $globalStatsFilters;
302 302
 		if ($filter_name == '') $filter_name = $this->filter_name;
303 303
 		if ($year == '' && $month == '') {
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
306 306
 			try {
307 307
 				$sth = $this->db->prepare($query);
308
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
309
-			} catch(PDOException $e) {
308
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
309
+			} catch (PDOException $e) {
310 310
 				echo "error : ".$e->getMessage();
311 311
 			}
312 312
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -314,14 +314,14 @@  discard block
 block discarded – undo
314 314
                 if (empty($all)) {
315 315
 			$filters = array('airlines' => array($stats_airline));
316 316
 			if ($filter_name != '') {
317
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
317
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
318 318
 			}
319 319
 	                $Spotter = new Spotter($this->db);
320
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
320
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters, $year, $month);
321 321
                 }
322 322
                 return $all;
323 323
 	}
324
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
324
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
325 325
 		global $globalStatsFilters;
326 326
 		if ($filter_name == '') $filter_name = $this->filter_name;
327 327
 		if ($year == '' && $month == '') {
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 			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";
330 330
 			 try {
331 331
 				$sth = $this->db->prepare($query);
332
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
333
-			} catch(PDOException $e) {
332
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
333
+			} catch (PDOException $e) {
334 334
 				echo "error : ".$e->getMessage();
335 335
 			}
336 336
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 		if (empty($all)) {
339 339
 			$filters = array('airlines' => array($stats_airline));
340 340
 			if ($filter_name != '') {
341
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
341
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
342 342
 			}
343 343
 			$Spotter = new Spotter($this->db);
344
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
344
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters, $year, $month);
345 345
 		}
346 346
 		return $all;
347 347
 	}
348
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
348
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
349 349
 		$Connection = new Connection();
350 350
 		if ($filter_name == '') $filter_name = $this->filter_name;
351 351
 		if ($Connection->tableExists('countries')) {
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 				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";
355 355
 				 try {
356 356
 					$sth = $this->db->prepare($query);
357
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
358
-				} catch(PDOException $e) {
357
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
358
+				} catch (PDOException $e) {
359 359
 					echo "error : ".$e->getMessage();
360 360
 				}
361 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 			return array();
372 372
 		}
373 373
 	}
374
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
374
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
375 375
 		global $globalStatsFilters;
376 376
 		if ($filter_name == '') $filter_name = $this->filter_name;
377 377
 		if ($year == '' && $month == '') {
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 			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";
380 380
 			try {
381 381
 				$sth = $this->db->prepare($query);
382
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
383
-			} catch(PDOException $e) {
382
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
383
+			} catch (PDOException $e) {
384 384
 				echo "error : ".$e->getMessage();
385 385
 			}
386 386
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -388,15 +388,15 @@  discard block
 block discarded – undo
388 388
 		if (empty($all)) {
389 389
 			$filters = array('airlines' => array($stats_airline));
390 390
 			if ($filter_name != '') {
391
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
391
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
392 392
 			}
393 393
 			$Spotter = new Spotter($this->db);
394
-			$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
394
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters, $year, $month);
395 395
 		}
396 396
 		return $all;
397 397
 	}
398 398
 
399
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
399
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
400 400
 		global $globalStatsFilters;
401 401
 		if ($filter_name == '') $filter_name = $this->filter_name;
402 402
 		if ($year == '' && $month == '') {
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 			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";
405 405
 			try {
406 406
 				$sth = $this->db->prepare($query);
407
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
408
-			} catch(PDOException $e) {
407
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
408
+			} catch (PDOException $e) {
409 409
 				echo "error : ".$e->getMessage();
410 410
 			}
411 411
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -413,14 +413,14 @@  discard block
 block discarded – undo
413 413
                 if (empty($all)) {
414 414
 			$filters = array('airlines' => array($stats_airline));
415 415
 			if ($filter_name != '') {
416
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
416
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
417 417
 			}
418 418
             		$Spotter = new Spotter($this->db);
419
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
419
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters, $year, $month);
420 420
                 }
421 421
                 return $all;
422 422
 	}
423
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
423
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
424 424
 		global $globalStatsFilters;
425 425
 		if ($filter_name == '') $filter_name = $this->filter_name;
426 426
 		if ($year == '' && $month == '') {
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 			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";
429 429
 			try {
430 430
 				$sth = $this->db->prepare($query);
431
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
432
-			} catch(PDOException $e) {
431
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
432
+			} catch (PDOException $e) {
433 433
 				echo "error : ".$e->getMessage();
434 434
 			}
435 435
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
                 if (empty($all)) {
438 438
 			$filters = array('airlines' => array($stats_airline));
439 439
             		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
440
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
441 441
 			}
442 442
             		$Spotter = new Spotter($this->db);
443
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
443
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters, $year, $month);
444
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters, $year, $month);
445 445
         		$all = array();
446 446
         		foreach ($pall as $value) {
447 447
         			$icao = $value['airport_departure_icao'];
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
         		foreach ($all as $key => $row) {
459 459
         			$count[$key] = $row['airport_departure_icao_count'];
460 460
         		}
461
-        		array_multisort($count,SORT_DESC,$all);
461
+        		array_multisort($count, SORT_DESC, $all);
462 462
                 }
463 463
                 return $all;
464 464
 	}
465
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
465
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
466 466
 		global $globalStatsFilters;
467 467
 		if ($filter_name == '') $filter_name = $this->filter_name;
468 468
 		if ($year == '' && $month == '') {
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
 			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";
471 471
 			try {
472 472
 				$sth = $this->db->prepare($query);
473
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
474
-			} catch(PDOException $e) {
473
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
474
+			} catch (PDOException $e) {
475 475
 				echo "error : ".$e->getMessage();
476 476
 			}
477 477
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
 		if (empty($all)) {
480 480
 			$filters = array('airlines' => array($stats_airline));
481 481
 			if ($filter_name != '') {
482
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
482
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
483 483
 			}
484 484
 			$Spotter = new Spotter($this->db);
485
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
486
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
485
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters, $year, $month);
486
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters, $year, $month);
487 487
         		$all = array();
488 488
         		foreach ($pall as $value) {
489 489
         			$icao = $value['airport_arrival_icao'];
@@ -500,12 +500,12 @@  discard block
 block discarded – undo
500 500
         		foreach ($all as $key => $row) {
501 501
         			$count[$key] = $row['airport_arrival_icao_count'];
502 502
         		}
503
-        		array_multisort($count,SORT_DESC,$all);
503
+        		array_multisort($count, SORT_DESC, $all);
504 504
                 }
505 505
  
506 506
                 return $all;
507 507
 	}
508
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
508
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
509 509
 		global $globalDBdriver, $globalStatsFilters;
510 510
 		if ($filter_name == '') $filter_name = $this->filter_name;
511 511
 		if ($globalDBdriver == 'mysql') {
@@ -515,18 +515,18 @@  discard block
 block discarded – undo
515 515
 			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";
516 516
 			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";
517 517
 		}
518
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
518
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
519 519
                  try {
520 520
                         $sth = $this->db->prepare($query);
521 521
                         $sth->execute($query_data);
522
-                } catch(PDOException $e) {
522
+                } catch (PDOException $e) {
523 523
                         echo "error : ".$e->getMessage();
524 524
                 }
525 525
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
526 526
                 if (empty($all)) {
527 527
 			$filters = array('airlines' => array($stats_airline));
528 528
 			if ($filter_name != '') {
529
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
529
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
530 530
 			}
531 531
             		$Spotter = new Spotter($this->db);
532 532
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -535,29 +535,29 @@  discard block
 block discarded – undo
535 535
                 return $all;
536 536
 	}
537 537
 	
538
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
538
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
539 539
 		global $globalStatsFilters;
540 540
 		if ($filter_name == '') $filter_name = $this->filter_name;
541 541
 		$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";
542
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
542
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
543 543
                  try {
544 544
                         $sth = $this->db->prepare($query);
545 545
                         $sth->execute($query_data);
546
-                } catch(PDOException $e) {
546
+                } catch (PDOException $e) {
547 547
                         echo "error : ".$e->getMessage();
548 548
                 }
549 549
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550 550
                 if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
553
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
554 554
 			}
555 555
             		$Spotter = new Spotter($this->db);
556 556
             		$all = $Spotter->countAllDatesLastMonth($filters);
557 557
                 }
558 558
                 return $all;
559 559
 	}
560
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
560
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
561 561
 		global $globalDBdriver, $globalStatsFilters;
562 562
 		if ($filter_name == '') $filter_name = $this->filter_name;
563 563
 		if ($globalDBdriver == 'mysql') {
@@ -565,40 +565,40 @@  discard block
 block discarded – undo
565 565
 		} else {
566 566
 			$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";
567 567
 		}
568
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
568
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
569 569
                  try {
570 570
                         $sth = $this->db->prepare($query);
571 571
                         $sth->execute($query_data);
572
-                } catch(PDOException $e) {
572
+                } catch (PDOException $e) {
573 573
                         echo "error : ".$e->getMessage();
574 574
                 }
575 575
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
576 576
                 if (empty($all)) {
577 577
 			$filters = array('airlines' => array($stats_airline));
578 578
 			if ($filter_name != '') {
579
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
579
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
580 580
 			}
581 581
             		$Spotter = new Spotter($this->db);
582 582
             		$all = $Spotter->countAllDatesLast7Days($filters);
583 583
                 }
584 584
                 return $all;
585 585
 	}
586
-	public function countAllDates($stats_airline = '',$filter_name = '') {
586
+	public function countAllDates($stats_airline = '', $filter_name = '') {
587 587
 		global $globalStatsFilters;
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		$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";
590
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
590
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
591 591
                  try {
592 592
                         $sth = $this->db->prepare($query);
593 593
                         $sth->execute($query_data);
594
-                } catch(PDOException $e) {
594
+                } catch (PDOException $e) {
595 595
                         echo "error : ".$e->getMessage();
596 596
                 }
597 597
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
598 598
                 if (empty($all)) {
599 599
 			$filters = array('airlines' => array($stats_airline));
600 600
 			if ($filter_name != '') {
601
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
601
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
602 602
 			}
603 603
             		$Spotter = new Spotter($this->db);
604 604
             		$all = $Spotter->countAllDates($filters);
@@ -613,28 +613,28 @@  discard block
 block discarded – undo
613 613
                  try {
614 614
                         $sth = $this->db->prepare($query);
615 615
                         $sth->execute($query_data);
616
-                } catch(PDOException $e) {
616
+                } catch (PDOException $e) {
617 617
                         echo "error : ".$e->getMessage();
618 618
                 }
619 619
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
620 620
                 if (empty($all)) {
621 621
             		$filters = array();
622 622
             		if ($filter_name != '') {
623
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
623
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
624 624
 			}
625 625
             		$Spotter = new Spotter($this->db);
626 626
             		$all = $Spotter->countAllDatesByAirlines($filters);
627 627
                 }
628 628
                 return $all;
629 629
 	}
630
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
630
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
631 631
 		global $globalStatsFilters;
632 632
 		if ($filter_name == '') $filter_name = $this->filter_name;
633 633
 	    	$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";
634 634
                  try {
635 635
                         $sth = $this->db->prepare($query);
636 636
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
-                } catch(PDOException $e) {
637
+                } catch (PDOException $e) {
638 638
                         echo "error : ".$e->getMessage();
639 639
                 }
640 640
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
                 if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
645
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
646 646
 			}
647 647
             		$Spotter = new Spotter($this->db);
648 648
             		$all = $Spotter->countAllMonths($filters);
@@ -657,21 +657,21 @@  discard block
 block discarded – undo
657 657
                  try {
658 658
                         $sth = $this->db->prepare($query);
659 659
                         $sth->execute(array(':filter_name' => $filter_name));
660
-                } catch(PDOException $e) {
660
+                } catch (PDOException $e) {
661 661
                         echo "error : ".$e->getMessage();
662 662
                 }
663 663
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
664 664
                 if (empty($all)) {
665 665
             		$filters = array();
666 666
             		if ($filter_name != '') {
667
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
667
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
668 668
 			}
669 669
             		$Spotter = new Spotter($this->db);
670 670
             		$all = $Spotter->countAllMilitaryMonths($filters);
671 671
                 }
672 672
                 return $all;
673 673
 	}
674
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
674
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
675 675
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
676 676
 		if ($filter_name == '') $filter_name = $this->filter_name;
677 677
 		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";
@@ -688,91 +688,91 @@  discard block
 block discarded – undo
688 688
                  try {
689 689
                         $sth = $this->db->prepare($query);
690 690
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
-                } catch(PDOException $e) {
691
+                } catch (PDOException $e) {
692 692
                         echo "error : ".$e->getMessage();
693 693
                 }
694 694
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
695 695
                 if (empty($all)) {
696 696
 			$filters = array('airlines' => array($stats_airline));
697 697
 			if ($filter_name != '') {
698
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
698
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
699 699
 			}
700 700
             		$Spotter = new Spotter($this->db);
701
-            		$all = $Spotter->countAllHours($orderby,$filters);
701
+            		$all = $Spotter->countAllHours($orderby, $filters);
702 702
                 }
703 703
                 return $all;
704 704
 	}
705 705
 	
706
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
706
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
707 707
 		global $globalStatsFilters;
708 708
 		if ($filter_name == '') $filter_name = $this->filter_name;
709 709
 		if ($year == '') $year = date('Y');
710
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
710
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
711 711
 		if (empty($all)) {
712 712
 			$filters = array('airlines' => array($stats_airline));
713 713
 			if ($filter_name != '') {
714
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
714
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
715 715
 			}
716 716
 			$Spotter = new Spotter($this->db);
717
-			$all = $Spotter->countOverallFlights($filters,$year,$month);
717
+			$all = $Spotter->countOverallFlights($filters, $year, $month);
718 718
 		}
719 719
 		return $all;
720 720
 	}
721
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
721
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
722 722
 		global $globalStatsFilters;
723 723
 		if ($filter_name == '') $filter_name = $this->filter_name;
724 724
 		if ($year == '') $year = date('Y');
725
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
725
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
726 726
 		if (empty($all)) {
727 727
 		        $filters = array();
728 728
             		if ($filter_name != '') {
729
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
729
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
730 730
 			}
731 731
 			$Spotter = new Spotter($this->db);
732
-			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
732
+			$all = $Spotter->countOverallMilitaryFlights($filters, $year, $month);
733 733
 		}
734 734
 		return $all;
735 735
 	}
736
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
736
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
737 737
 		global $globalStatsFilters;
738 738
 		if ($filter_name == '') $filter_name = $this->filter_name;
739 739
 		if ($year == '') $year = date('Y');
740
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
740
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
741 741
 		if (empty($all)) {
742 742
 			$filters = array('airlines' => array($stats_airline));
743 743
 			if ($filter_name != '') {
744
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
744
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
745 745
 			}
746 746
 			$Spotter = new Spotter($this->db);
747
-			$all = $Spotter->countOverallArrival($filters,$year,$month);
747
+			$all = $Spotter->countOverallArrival($filters, $year, $month);
748 748
 		}
749 749
 		return $all;
750 750
 	}
751
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
751
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
752 752
 		global $globalStatsFilters;
753 753
 		if ($filter_name == '') $filter_name = $this->filter_name;
754 754
 		if ($year == '' && $month == '') {
755 755
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
756 756
 			try {
757 757
 				$sth = $this->db->prepare($query);
758
-				$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
759
-			} catch(PDOException $e) {
758
+				$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
759
+			} catch (PDOException $e) {
760 760
 				echo "error : ".$e->getMessage();
761 761
 			}
762 762
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
763 763
 			$all = $result[0]['nb'];
764
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
764
+		} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
765 765
 		if (empty($all)) {
766 766
 			$filters = array('airlines' => array($stats_airline));
767 767
 			if ($filter_name != '') {
768
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
768
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
769 769
 			}
770 770
 			$Spotter = new Spotter($this->db);
771
-			$all = $Spotter->countOverallAircrafts($filters,$year,$month);
771
+			$all = $Spotter->countOverallAircrafts($filters, $year, $month);
772 772
 		}
773 773
 		return $all;
774 774
 	}
775
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
775
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
776 776
 		global $globalStatsFilters;
777 777
 		if ($filter_name == '') $filter_name = $this->filter_name;
778 778
 		if ($year == '' && $month == '') {
@@ -780,23 +780,23 @@  discard block
 block discarded – undo
780 780
 			try {
781 781
 				$sth = $this->db->prepare($query);
782 782
 				$sth->execute(array(':filter_name' => $filter_name));
783
-			} catch(PDOException $e) {
783
+			} catch (PDOException $e) {
784 784
 				echo "error : ".$e->getMessage();
785 785
 			}
786 786
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
787 787
 			$all = $result[0]['nb_airline'];
788
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
788
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
789 789
 		if (empty($all)) {
790 790
             		$filters = array();
791 791
             		if ($filter_name != '') {
792
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
792
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
793 793
 			}
794 794
 			$Spotter = new Spotter($this->db);
795
-			$all = $Spotter->countOverallAirlines($filters,$year,$month);
795
+			$all = $Spotter->countOverallAirlines($filters, $year, $month);
796 796
 		}
797 797
 		return $all;
798 798
 	}
799
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
799
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
800 800
 		global $globalStatsFilters;
801 801
 		if ($filter_name == '') $filter_name = $this->filter_name;
802 802
 		if ($year == '' && $month == '') {
@@ -805,25 +805,25 @@  discard block
 block discarded – undo
805 805
 			try {
806 806
 				$sth = $this->db->prepare($query);
807 807
 				$sth->execute($query_values);
808
-			} catch(PDOException $e) {
808
+			} catch (PDOException $e) {
809 809
 				echo "error : ".$e->getMessage();
810 810
 			}
811 811
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
812 812
 			$all = $result[0]['nb'];
813 813
 		} else {
814
-			$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
814
+			$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
815 815
 		}
816 816
 		if (empty($all)) {
817 817
 			$filters = array('airlines' => array($stats_airline));
818 818
 			if ($filter_name != '') {
819
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
819
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
820 820
 			}
821 821
 			$Spotter = new Spotter($this->db);
822
-			$all = $Spotter->countOverallOwners($filters,$year,$month);
822
+			$all = $Spotter->countOverallOwners($filters, $year, $month);
823 823
 		}
824 824
 		return $all;
825 825
 	}
826
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
826
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
827 827
 		global $globalStatsFilters;
828 828
 		if ($filter_name == '') $filter_name = $this->filter_name;
829 829
 		//if ($year == '') $year = date('Y');
@@ -833,75 +833,75 @@  discard block
 block discarded – undo
833 833
 			try {
834 834
 				$sth = $this->db->prepare($query);
835 835
 				$sth->execute($query_values);
836
-			} catch(PDOException $e) {
836
+			} catch (PDOException $e) {
837 837
 				echo "error : ".$e->getMessage();
838 838
 			}
839 839
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
840 840
 			$all = $result[0]['nb'];
841 841
 		} else {
842
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
842
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
843 843
 		}
844 844
 		if (empty($all)) {
845 845
 			$filters = array('airlines' => array($stats_airline));
846 846
 			if ($filter_name != '') {
847
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
847
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
848 848
 			}
849 849
 			$Spotter = new Spotter($this->db);
850
-			$all = $Spotter->countOverallPilots($filters,$year,$month);
850
+			$all = $Spotter->countOverallPilots($filters, $year, $month);
851 851
 		}
852 852
 		return $all;
853 853
 	}
854 854
 
855
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
855
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
856 856
 		if ($filter_name == '') $filter_name = $this->filter_name;
857 857
 		$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";
858
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
858
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
859 859
                  try {
860 860
                         $sth = $this->db->prepare($query);
861 861
                         $sth->execute($query_values);
862
-                } catch(PDOException $e) {
862
+                } catch (PDOException $e) {
863 863
                         echo "error : ".$e->getMessage();
864 864
                 }
865 865
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
866 866
                 return $all;
867 867
 	}
868
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
868
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
869 869
 		if ($filter_name == '') $filter_name = $this->filter_name;
870 870
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
871
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
871
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
872 872
                  try {
873 873
                         $sth = $this->db->prepare($query);
874 874
                         $sth->execute($query_values);
875
-                } catch(PDOException $e) {
875
+                } catch (PDOException $e) {
876 876
                         echo "error : ".$e->getMessage();
877 877
                 }
878 878
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
879 879
                 return $all;
880 880
         }
881
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
881
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
882 882
 		if ($filter_name == '') $filter_name = $this->filter_name;
883 883
     		global $globalArchiveMonths, $globalDBdriver;
884 884
     		if ($globalDBdriver == 'mysql') {
885 885
     			if ($month == '') {
886 886
 				$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";
887
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
887
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
888 888
 			} else {
889 889
 				$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";
890
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
890
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
891 891
 			}
892 892
 		} else {
893 893
 			if ($month == '') {
894 894
 				$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";
895
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
895
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
896 896
 			} else {
897 897
 				$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";
898
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
898
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
899 899
 			}
900 900
                 }
901 901
                  try {
902 902
                         $sth = $this->db->prepare($query);
903 903
                         $sth->execute($query_values);
904
-                } catch(PDOException $e) {
904
+                } catch (PDOException $e) {
905 905
                         echo "error : ".$e->getMessage();
906 906
                 }
907 907
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
                  try {
920 920
                         $sth = $this->db->prepare($query);
921 921
                         $sth->execute($query_values);
922
-                } catch(PDOException $e) {
922
+                } catch (PDOException $e) {
923 923
                         echo "error : ".$e->getMessage();
924 924
                 }
925 925
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
                  try {
937 937
                         $sth = $this->db->prepare($query);
938 938
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
939
-                } catch(PDOException $e) {
939
+                } catch (PDOException $e) {
940 940
                         echo "error : ".$e->getMessage();
941 941
                 }
942 942
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
                  try {
954 954
                         $sth = $this->db->prepare($query);
955 955
                         $sth->execute(array(':filter_name' => $filter_name));
956
-                } catch(PDOException $e) {
956
+                } catch (PDOException $e) {
957 957
                         echo "error : ".$e->getMessage();
958 958
                 }
959 959
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -970,20 +970,20 @@  discard block
 block discarded – undo
970 970
                  try {
971 971
                         $sth = $this->db->prepare($query);
972 972
                         $sth->execute(array(':filter_name' => $filter_name));
973
-                } catch(PDOException $e) {
973
+                } catch (PDOException $e) {
974 974
                         echo "error : ".$e->getMessage();
975 975
                 }
976 976
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
977 977
                 return $all[0]['total'];
978 978
         }
979
-	public function getStatsOwner($owner_name,$filter_name = '') {
979
+	public function getStatsOwner($owner_name, $filter_name = '') {
980 980
     		global $globalArchiveMonths, $globalDBdriver;
981 981
 		if ($filter_name == '') $filter_name = $this->filter_name;
982 982
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
983 983
                  try {
984 984
                         $sth = $this->db->prepare($query);
985
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
986
-                } catch(PDOException $e) {
985
+                        $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
986
+                } catch (PDOException $e) {
987 987
                         echo "error : ".$e->getMessage();
988 988
                 }
989 989
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1001,20 +1001,20 @@  discard block
 block discarded – undo
1001 1001
                  try {
1002 1002
                         $sth = $this->db->prepare($query);
1003 1003
                         $sth->execute(array(':filter_name' => $filter_name));
1004
-                } catch(PDOException $e) {
1004
+                } catch (PDOException $e) {
1005 1005
                         echo "error : ".$e->getMessage();
1006 1006
                 }
1007 1007
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1008 1008
                 return $all[0]['total'];
1009 1009
         }
1010
-	public function getStatsPilot($pilot,$filter_name = '') {
1010
+	public function getStatsPilot($pilot, $filter_name = '') {
1011 1011
     		global $globalArchiveMonths, $globalDBdriver;
1012 1012
 		if ($filter_name == '') $filter_name = $this->filter_name;
1013 1013
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1014 1014
                  try {
1015 1015
                         $sth = $this->db->prepare($query);
1016
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1017
-                } catch(PDOException $e) {
1016
+                        $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1017
+                } catch (PDOException $e) {
1018 1018
                         echo "error : ".$e->getMessage();
1019 1019
                 }
1020 1020
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
                 else return 0;
1023 1023
         }
1024 1024
 
1025
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1025
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1026 1026
 		global $globalDBdriver;
1027 1027
 		if ($filter_name == '') $filter_name = $this->filter_name;
1028 1028
 		if ($globalDBdriver == 'mysql') {
@@ -1030,15 +1030,15 @@  discard block
 block discarded – undo
1030 1030
                 } else {
1031 1031
 			$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);"; 
1032 1032
 		}
1033
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1033
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1034 1034
                  try {
1035 1035
                         $sth = $this->db->prepare($query);
1036 1036
                         $sth->execute($query_values);
1037
-                } catch(PDOException $e) {
1037
+                } catch (PDOException $e) {
1038 1038
                         return "error : ".$e->getMessage();
1039 1039
                 }
1040 1040
         }
1041
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1041
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1042 1042
 		global $globalDBdriver;
1043 1043
 		if ($filter_name == '') $filter_name = $this->filter_name;
1044 1044
 		if ($globalDBdriver == 'mysql') {
@@ -1047,11 +1047,11 @@  discard block
 block discarded – undo
1047 1047
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1048 1048
 			$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);"; 
1049 1049
                 }
1050
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1050
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1051 1051
                  try {
1052 1052
                         $sth = $this->db->prepare($query);
1053 1053
                         $sth->execute($query_values);
1054
-                } catch(PDOException $e) {
1054
+                } catch (PDOException $e) {
1055 1055
                         return "error : ".$e->getMessage();
1056 1056
                 }
1057 1057
         }
@@ -1075,75 +1075,75 @@  discard block
 block discarded – undo
1075 1075
         }
1076 1076
         */
1077 1077
 
1078
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1078
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1079 1079
 		global $globalDBdriver;
1080 1080
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1081 1081
 		$query_values = array();
1082 1082
 		if ($globalDBdriver == 'mysql') {
1083 1083
 			if ($year != '') {
1084 1084
 				$query .= ' AND YEAR(stats_date) = :year';
1085
-				$query_values = array_merge($query_values,array(':year' => $year));
1085
+				$query_values = array_merge($query_values, array(':year' => $year));
1086 1086
 			}
1087 1087
 			if ($month != '') {
1088 1088
 				$query .= ' AND MONTH(stats_date) = :month';
1089
-				$query_values = array_merge($query_values,array(':month' => $month));
1089
+				$query_values = array_merge($query_values, array(':month' => $month));
1090 1090
 			}
1091 1091
 			if ($day != '') {
1092 1092
 				$query .= ' AND DAY(stats_date) = :day';
1093
-				$query_values = array_merge($query_values,array(':day' => $day));
1093
+				$query_values = array_merge($query_values, array(':day' => $day));
1094 1094
 			}
1095 1095
 		} else {
1096 1096
 			if ($year != '') {
1097 1097
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1098
-				$query_values = array_merge($query_values,array(':year' => $year));
1098
+				$query_values = array_merge($query_values, array(':year' => $year));
1099 1099
 			}
1100 1100
 			if ($month != '') {
1101 1101
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1102
-				$query_values = array_merge($query_values,array(':month' => $month));
1102
+				$query_values = array_merge($query_values, array(':month' => $month));
1103 1103
 			}
1104 1104
 			if ($day != '') {
1105 1105
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1106
-				$query_values = array_merge($query_values,array(':day' => $day));
1106
+				$query_values = array_merge($query_values, array(':day' => $day));
1107 1107
 			}
1108 1108
 		}
1109 1109
 		$query .= " ORDER BY source_name";
1110
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1110
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1111 1111
 		try {
1112 1112
 			$sth = $this->db->prepare($query);
1113 1113
 			$sth->execute($query_values);
1114
-		} catch(PDOException $e) {
1114
+		} catch (PDOException $e) {
1115 1115
 			echo "error : ".$e->getMessage();
1116 1116
 		}
1117 1117
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1118 1118
 		return $all;
1119 1119
 	}
1120 1120
 
1121
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1121
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1122 1122
 		global $globalDBdriver;
1123 1123
 		if ($globalDBdriver == 'mysql') {
1124 1124
 			$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";
1125 1125
 		} else {
1126 1126
 			$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);"; 
1127 1127
                 }
1128
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1128
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1129 1129
                  try {
1130 1130
                         $sth = $this->db->prepare($query);
1131 1131
                         $sth->execute($query_values);
1132
-                } catch(PDOException $e) {
1132
+                } catch (PDOException $e) {
1133 1133
                         return "error : ".$e->getMessage();
1134 1134
                 }
1135 1135
         }
1136
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1136
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1137 1137
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1138
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1138
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1139 1139
                  try {
1140 1140
                         $sth = $this->db->prepare($query);
1141 1141
                         $sth->execute($query_values);
1142
-                } catch(PDOException $e) {
1142
+                } catch (PDOException $e) {
1143 1143
                         return "error : ".$e->getMessage();
1144 1144
                 }
1145 1145
         }
1146
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1146
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1147 1147
 		global $globalDBdriver;
1148 1148
 		if ($globalDBdriver == 'mysql') {
1149 1149
 			if ($reset) {
@@ -1158,15 +1158,15 @@  discard block
 block discarded – undo
1158 1158
 				$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);"; 
1159 1159
 			}
1160 1160
 		}
1161
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1161
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1162 1162
                  try {
1163 1163
                         $sth = $this->db->prepare($query);
1164 1164
                         $sth->execute($query_values);
1165
-                } catch(PDOException $e) {
1165
+                } catch (PDOException $e) {
1166 1166
                         return "error : ".$e->getMessage();
1167 1167
                 }
1168 1168
         }
1169
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1169
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1170 1170
 		global $globalDBdriver;
1171 1171
 		if ($globalDBdriver == 'mysql') {
1172 1172
 			if ($reset) {
@@ -1181,15 +1181,15 @@  discard block
 block discarded – undo
1181 1181
 				$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);"; 
1182 1182
 			}
1183 1183
 		}
1184
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1184
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1185 1185
                  try {
1186 1186
                         $sth = $this->db->prepare($query);
1187 1187
                         $sth->execute($query_values);
1188
-                } catch(PDOException $e) {
1188
+                } catch (PDOException $e) {
1189 1189
                         return "error : ".$e->getMessage();
1190 1190
                 }
1191 1191
         }
1192
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1192
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1193 1193
 		global $globalDBdriver;
1194 1194
 		if ($globalDBdriver == 'mysql') {
1195 1195
 			if ($reset) {
@@ -1204,15 +1204,15 @@  discard block
 block discarded – undo
1204 1204
 				$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);"; 
1205 1205
 			}
1206 1206
 		}
1207
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1207
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1208 1208
                  try {
1209 1209
                         $sth = $this->db->prepare($query);
1210 1210
                         $sth->execute($query_values);
1211
-                } catch(PDOException $e) {
1211
+                } catch (PDOException $e) {
1212 1212
                         return "error : ".$e->getMessage();
1213 1213
                 }
1214 1214
         }
1215
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1215
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1216 1216
 		global $globalDBdriver;
1217 1217
 		if ($globalDBdriver == 'mysql') {
1218 1218
 			if ($reset) {
@@ -1227,15 +1227,15 @@  discard block
 block discarded – undo
1227 1227
 				$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);"; 
1228 1228
 			}
1229 1229
 		}
1230
-                $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);
1230
+                $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);
1231 1231
                  try {
1232 1232
                         $sth = $this->db->prepare($query);
1233 1233
                         $sth->execute($query_values);
1234
-                } catch(PDOException $e) {
1234
+                } catch (PDOException $e) {
1235 1235
                         return "error : ".$e->getMessage();
1236 1236
                 }
1237 1237
         }
1238
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1238
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1239 1239
 		global $globalDBdriver;
1240 1240
 		if ($globalDBdriver == 'mysql') {
1241 1241
 			if ($reset) {
@@ -1250,15 +1250,15 @@  discard block
 block discarded – undo
1250 1250
 				$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);"; 
1251 1251
 			}
1252 1252
 		}
1253
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1253
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1254 1254
                  try {
1255 1255
                         $sth = $this->db->prepare($query);
1256 1256
                         $sth->execute($query_values);
1257
-                } catch(PDOException $e) {
1257
+                } catch (PDOException $e) {
1258 1258
                         return "error : ".$e->getMessage();
1259 1259
                 }
1260 1260
         }
1261
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1261
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1262 1262
 		global $globalDBdriver;
1263 1263
 		if ($globalDBdriver == 'mysql') {
1264 1264
 			if ($reset) {
@@ -1273,15 +1273,15 @@  discard block
 block discarded – undo
1273 1273
 				$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);"; 
1274 1274
 			}
1275 1275
 		}
1276
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1276
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1277 1277
                  try {
1278 1278
                         $sth = $this->db->prepare($query);
1279 1279
                         $sth->execute($query_values);
1280
-                } catch(PDOException $e) {
1280
+                } catch (PDOException $e) {
1281 1281
                         return "error : ".$e->getMessage();
1282 1282
                 }
1283 1283
         }
1284
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1284
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1285 1285
 		global $globalDBdriver;
1286 1286
 		if ($globalDBdriver == 'mysql') {
1287 1287
 			if ($reset) {
@@ -1296,15 +1296,15 @@  discard block
 block discarded – undo
1296 1296
 				$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);"; 
1297 1297
 			}
1298 1298
 		}
1299
-                $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);
1299
+                $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);
1300 1300
                  try {
1301 1301
                         $sth = $this->db->prepare($query);
1302 1302
                         $sth->execute($query_values);
1303
-                } catch(PDOException $e) {
1303
+                } catch (PDOException $e) {
1304 1304
                         return "error : ".$e->getMessage();
1305 1305
                 }
1306 1306
         }
1307
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1307
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1308 1308
 		global $globalDBdriver;
1309 1309
 		if ($airport_icao != '') {
1310 1310
 			if ($globalDBdriver == 'mysql') {
@@ -1320,16 +1320,16 @@  discard block
 block discarded – undo
1320 1320
 					$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);"; 
1321 1321
 				}
1322 1322
 			}
1323
-			$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);
1323
+			$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);
1324 1324
 			try {
1325 1325
 				$sth = $this->db->prepare($query);
1326 1326
 				$sth->execute($query_values);
1327
-			} catch(PDOException $e) {
1327
+			} catch (PDOException $e) {
1328 1328
 				return "error : ".$e->getMessage();
1329 1329
 			}
1330 1330
                 }
1331 1331
         }
1332
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1332
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1333 1333
 		global $globalDBdriver;
1334 1334
 		if ($airport_icao != '') {
1335 1335
 			if ($globalDBdriver == 'mysql') {
@@ -1337,16 +1337,16 @@  discard block
 block discarded – undo
1337 1337
 			} else {
1338 1338
 				$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);"; 
1339 1339
 			}
1340
-			$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);
1340
+			$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);
1341 1341
 			 try {
1342 1342
 				$sth = $this->db->prepare($query);
1343 1343
 				$sth->execute($query_values);
1344
-			} catch(PDOException $e) {
1344
+			} catch (PDOException $e) {
1345 1345
 				return "error : ".$e->getMessage();
1346 1346
 			}
1347 1347
                 }
1348 1348
         }
1349
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1349
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1350 1350
 		global $globalDBdriver;
1351 1351
 		if ($airport_icao != '') {
1352 1352
 			if ($globalDBdriver == 'mysql') {
@@ -1362,16 +1362,16 @@  discard block
 block discarded – undo
1362 1362
 					$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);"; 
1363 1363
 				}
1364 1364
 			}
1365
-	                $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);
1365
+	                $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);
1366 1366
 			 try {
1367 1367
                     		$sth = $this->db->prepare($query);
1368 1368
 	                        $sth->execute($query_values);
1369
-    		        } catch(PDOException $e) {
1369
+    		        } catch (PDOException $e) {
1370 1370
             		        return "error : ".$e->getMessage();
1371 1371
 	                }
1372 1372
 	        }
1373 1373
         }
1374
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1374
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1375 1375
 		global $globalDBdriver;
1376 1376
 		if ($airport_icao != '') {
1377 1377
 			if ($globalDBdriver == 'mysql') {
@@ -1379,11 +1379,11 @@  discard block
 block discarded – undo
1379 1379
 			} else {
1380 1380
 				$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);"; 
1381 1381
 			}
1382
-			$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);
1382
+			$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);
1383 1383
 			try {
1384 1384
 				$sth = $this->db->prepare($query);
1385 1385
 				$sth->execute($query_values);
1386
-			} catch(PDOException $e) {
1386
+			} catch (PDOException $e) {
1387 1387
 				return "error : ".$e->getMessage();
1388 1388
 			}
1389 1389
                 }
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
                  try {
1396 1396
                         $sth = $this->db->prepare($query);
1397 1397
                         $sth->execute($query_values);
1398
-                } catch(PDOException $e) {
1398
+                } catch (PDOException $e) {
1399 1399
                         return "error : ".$e->getMessage();
1400 1400
                 }
1401 1401
         }
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
                  try {
1406 1406
                         $sth = $this->db->prepare($query);
1407 1407
                         $sth->execute($query_values);
1408
-                } catch(PDOException $e) {
1408
+                } catch (PDOException $e) {
1409 1409
                         return "error : ".$e->getMessage();
1410 1410
                 }
1411 1411
         }
@@ -1415,13 +1415,13 @@  discard block
 block discarded – undo
1415 1415
                  try {
1416 1416
                         $sth = $this->db->prepare($query);
1417 1417
                         $sth->execute($query_values);
1418
-                } catch(PDOException $e) {
1418
+                } catch (PDOException $e) {
1419 1419
                         return "error : ".$e->getMessage();
1420 1420
                 }
1421 1421
         }
1422 1422
         
1423 1423
         public function addOldStats() {
1424
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1424
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear;
1425 1425
     		$Common = new Common();
1426 1426
     		$Connection = new Connection();
1427 1427
     		date_default_timezone_set('UTC');
@@ -1438,40 +1438,40 @@  discard block
 block discarded – undo
1438 1438
 			$Spotter = new Spotter($this->db);
1439 1439
 
1440 1440
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1441
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1441
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1442 1442
 			foreach ($alldata as $number) {
1443
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1443
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
1444 1444
 			}
1445 1445
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1446
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1446
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1447 1447
 			foreach ($alldata as $number) {
1448
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1448
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1449 1449
 			}
1450 1450
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1451
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1451
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1452 1452
 			foreach ($alldata as $number) {
1453
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1453
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1454 1454
 			}
1455 1455
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1456
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1456
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1457 1457
 			foreach ($alldata as $number) {
1458
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1458
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1459 1459
 			}
1460 1460
 			if ($globalDebug) echo 'Count all owners...'."\n";
1461
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1461
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1462 1462
 			foreach ($alldata as $number) {
1463
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1463
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1464 1464
 			}
1465 1465
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1466
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1466
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1467 1467
 			foreach ($alldata as $number) {
1468
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1468
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1469 1469
 			}
1470 1470
 			
1471 1471
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1472
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1472
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1473 1473
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1474
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1474
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1475 1475
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1476 1476
 	        	$alldata = array();
1477 1477
 	        	
@@ -1489,14 +1489,14 @@  discard block
 block discarded – undo
1489 1489
     			foreach ($alldata as $key => $row) {
1490 1490
     				$count[$key] = $row['airport_departure_icao_count'];
1491 1491
         		}
1492
-			array_multisort($count,SORT_DESC,$alldata);
1492
+			array_multisort($count, SORT_DESC, $alldata);
1493 1493
 			foreach ($alldata as $number) {
1494
-				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);
1494
+				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);
1495 1495
 			}
1496 1496
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1497
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1497
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1498 1498
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1499
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1499
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1500 1500
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1501 1501
 	        	$alldata = array();
1502 1502
     			foreach ($pall as $value) {
@@ -1513,16 +1513,16 @@  discard block
 block discarded – undo
1513 1513
         		foreach ($alldata as $key => $row) {
1514 1514
         			$count[$key] = $row['airport_arrival_icao_count'];
1515 1515
 	        	}
1516
-    			array_multisort($count,SORT_DESC,$alldata);
1516
+    			array_multisort($count, SORT_DESC, $alldata);
1517 1517
                         foreach ($alldata as $number) {
1518
-				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);
1518
+				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);
1519 1519
 			}
1520 1520
 			if ($Connection->tableExists('countries')) {
1521 1521
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1522 1522
 				$SpotterArchive = new SpotterArchive();
1523
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1523
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1524 1524
 				foreach ($alldata as $number) {
1525
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
1525
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
1526 1526
 				}
1527 1527
 			}
1528 1528
 			
@@ -1536,37 +1536,37 @@  discard block
 block discarded – undo
1536 1536
 			$lastyear = false;
1537 1537
 			foreach ($alldata as $number) {
1538 1538
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1539
-				$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'])));
1539
+				$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'])));
1540 1540
 			}
1541 1541
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1542 1542
 			$alldata = $Spotter->countAllMilitaryMonths();
1543 1543
 			foreach ($alldata as $number) {
1544
-				$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'])));
1544
+				$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'])));
1545 1545
 			}
1546 1546
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1547 1547
 			$alldata = $Spotter->countAllMonthsOwners();
1548 1548
 			foreach ($alldata as $number) {
1549
-				$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'])));
1549
+				$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'])));
1550 1550
 			}
1551 1551
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1552 1552
 			$alldata = $Spotter->countAllMonthsPilots();
1553 1553
 			foreach ($alldata as $number) {
1554
-				$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'])));
1554
+				$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'])));
1555 1555
 			}
1556 1556
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1557 1557
 			$alldata = $Spotter->countAllMonthsAirlines();
1558 1558
 			foreach ($alldata as $number) {
1559
-				$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'])));
1559
+				$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'])));
1560 1560
 			}
1561 1561
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1562 1562
 			$alldata = $Spotter->countAllMonthsAircrafts();
1563 1563
 			foreach ($alldata as $number) {
1564
-				$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'])));
1564
+				$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'])));
1565 1565
 			}
1566 1566
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1567 1567
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1568 1568
 			foreach ($alldata as $number) {
1569
-				$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'])));
1569
+				$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'])));
1570 1570
 			}
1571 1571
 			if ($globalDebug) echo 'Airports data...'."\n";
1572 1572
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
     			}
1612 1612
     			$alldata = $pall;
1613 1613
 			foreach ($alldata as $number) {
1614
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1614
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1615 1615
 			}
1616 1616
 			echo '...Arrival'."\n";
1617 1617
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1653,7 +1653,7 @@  discard block
 block discarded – undo
1653 1653
     			}
1654 1654
     			$alldata = $pall;
1655 1655
 			foreach ($alldata as $number) {
1656
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1656
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1657 1657
 			}
1658 1658
 
1659 1659
 			echo 'Flights data...'."\n";
@@ -1661,28 +1661,28 @@  discard block
 block discarded – undo
1661 1661
 			echo '-> countAllDatesLastMonth...'."\n";
1662 1662
 			$alldata = $Spotter->countAllDatesLastMonth();
1663 1663
 			foreach ($alldata as $number) {
1664
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1664
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1665 1665
 			}
1666 1666
 			echo '-> countAllDates...'."\n";
1667 1667
 			$previousdata = $this->countAllDates();
1668 1668
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1669 1669
 			$this->deleteStatFlight('date');
1670
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1670
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1671 1671
 			$values = array();
1672 1672
 			foreach ($alldata as $cnt) {
1673 1673
 				$values[] = $cnt['date_count'];
1674 1674
 			}
1675
-			array_multisort($values,SORT_DESC,$alldata);
1676
-			array_splice($alldata,11);
1675
+			array_multisort($values, SORT_DESC, $alldata);
1676
+			array_splice($alldata, 11);
1677 1677
 			foreach ($alldata as $number) {
1678
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1678
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1679 1679
 			}
1680 1680
 			
1681 1681
 			$this->deleteStatFlight('hour');
1682 1682
 			echo '-> countAllHours...'."\n";
1683 1683
 			$alldata = $Spotter->countAllHours('hour');
1684 1684
 			foreach ($alldata as $number) {
1685
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1685
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1686 1686
 			}
1687 1687
 
1688 1688
 
@@ -1692,41 +1692,41 @@  discard block
 block discarded – undo
1692 1692
 			if ($Connection->tableExists('countries')) {
1693 1693
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1694 1694
 				$SpotterArchive = new SpotterArchive();
1695
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1695
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
1696 1696
 				foreach ($alldata as $number) {
1697
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1697
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
1698 1698
 				}
1699 1699
 			}
1700 1700
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1701 1701
 			$Spotter = new Spotter($this->db);
1702
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1702
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1703 1703
 			foreach ($alldata as $number) {
1704
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1704
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1705 1705
 			}
1706 1706
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1707
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1707
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1708 1708
 			foreach ($alldata as $number) {
1709
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1709
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1710 1710
 			}
1711 1711
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1712
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1712
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1713 1713
 			foreach ($alldata as $number) {
1714
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1714
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1715 1715
 			}
1716 1716
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1717
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1717
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1718 1718
 			foreach ($alldata as $number) {
1719
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1719
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1720 1720
 			}
1721 1721
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1722
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1722
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1723 1723
 			foreach ($alldata as $number) {
1724
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1724
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1725 1725
 			}
1726 1726
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1727
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1727
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1728 1728
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1729
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1729
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1730 1730
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1731 1731
 	        	//$alldata = array();
1732 1732
     			foreach ($dall as $value) {
@@ -1746,12 +1746,12 @@  discard block
 block discarded – undo
1746 1746
     			}
1747 1747
     			$alldata = $pall;
1748 1748
 			foreach ($alldata as $number) {
1749
-				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);
1749
+				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);
1750 1750
 			}
1751 1751
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1752
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1752
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1753 1753
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1754
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1754
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1755 1755
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1756 1756
 	        	//$alldata = array();
1757 1757
     			foreach ($dall as $value) {
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
     			}
1772 1772
     			$alldata = $pall;
1773 1773
                         foreach ($alldata as $number) {
1774
-				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);
1774
+				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);
1775 1775
 			}
1776 1776
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1777 1777
 			$Spotter = new Spotter($this->db);
@@ -1779,27 +1779,27 @@  discard block
 block discarded – undo
1779 1779
 			$lastyear = false;
1780 1780
 			foreach ($alldata as $number) {
1781 1781
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1782
-				$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']);
1782
+				$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']);
1783 1783
 			}
1784 1784
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1785 1785
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1786 1786
 			foreach ($alldata as $number) {
1787
-				$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']);
1787
+				$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']);
1788 1788
 			}
1789 1789
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1790 1790
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1791 1791
 			foreach ($alldata as $number) {
1792
-				$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']);
1792
+				$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']);
1793 1793
 			}
1794 1794
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1795 1795
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1796 1796
 			foreach ($alldata as $number) {
1797
-				$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']);
1797
+				$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']);
1798 1798
 			}
1799 1799
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1800 1800
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1801 1801
 			foreach ($alldata as $number) {
1802
-				$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']);
1802
+				$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']);
1803 1803
 			}
1804 1804
 			if ($globalDebug) echo '...Departure'."\n";
1805 1805
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1822,7 +1822,7 @@  discard block
 block discarded – undo
1822 1822
     			}
1823 1823
     			$alldata = $pall;
1824 1824
 			foreach ($alldata as $number) {
1825
-				$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']);
1825
+				$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']);
1826 1826
 			}
1827 1827
 			if ($globalDebug) echo '...Arrival'."\n";
1828 1828
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1845,32 +1845,32 @@  discard block
 block discarded – undo
1845 1845
     			}
1846 1846
     			$alldata = $pall;
1847 1847
 			foreach ($alldata as $number) {
1848
-				$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']);
1848
+				$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']);
1849 1849
 			}
1850 1850
 
1851 1851
 			if ($globalDebug) echo 'Flights data...'."\n";
1852 1852
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1853 1853
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1854 1854
 			foreach ($alldata as $number) {
1855
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1855
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1856 1856
 			}
1857 1857
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1858 1858
 			//$previousdata = $this->countAllDatesByAirlines();
1859
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1859
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1860 1860
 			$values = array();
1861 1861
 			foreach ($alldata as $cnt) {
1862 1862
 				$values[] = $cnt['date_count'];
1863 1863
 			}
1864
-			array_multisort($values,SORT_DESC,$alldata);
1865
-			array_splice($alldata,11);
1864
+			array_multisort($values, SORT_DESC, $alldata);
1865
+			array_splice($alldata, 11);
1866 1866
 			foreach ($alldata as $number) {
1867
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1867
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1868 1868
 			}
1869 1869
 			
1870 1870
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1871 1871
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1872 1872
 			foreach ($alldata as $number) {
1873
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1873
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1874 1874
 			}
1875 1875
 			
1876 1876
 
@@ -1889,32 +1889,32 @@  discard block
 block discarded – undo
1889 1889
 				// Count by filter
1890 1890
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1891 1891
 				$Spotter = new Spotter($this->db);
1892
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1892
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1893 1893
 				foreach ($alldata as $number) {
1894
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
1894
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
1895 1895
 				}
1896
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
1896
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
1897 1897
 				foreach ($alldata as $number) {
1898
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
1898
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
1899 1899
 				}
1900
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1900
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1901 1901
 				foreach ($alldata as $number) {
1902
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
1902
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
1903 1903
 				}
1904
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1904
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1905 1905
 				foreach ($alldata as $number) {
1906
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
1906
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
1907 1907
 				}
1908
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1908
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1909 1909
 				foreach ($alldata as $number) {
1910
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
1910
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
1911 1911
 				}
1912
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1912
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1913 1913
 				foreach ($alldata as $number) {
1914
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1914
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
1915 1915
 				}
1916
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1917
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1916
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1917
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1918 1918
 		        	$alldata = array();
1919 1919
 	    			foreach ($pall as $value) {
1920 1920
 		        		$icao = $value['airport_departure_icao'];
@@ -1930,12 +1930,12 @@  discard block
 block discarded – undo
1930 1930
     				foreach ($alldata as $key => $row) {
1931 1931
     					$count[$key] = $row['airport_departure_icao_count'];
1932 1932
     				}
1933
-				array_multisort($count,SORT_DESC,$alldata);
1933
+				array_multisort($count, SORT_DESC, $alldata);
1934 1934
 				foreach ($alldata as $number) {
1935
-    					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);
1935
+    					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);
1936 1936
 				}
1937
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1938
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1937
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
1938
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
1939 1939
 				$alldata = array();
1940 1940
     				foreach ($pall as $value) {
1941 1941
 		        		$icao = $value['airport_arrival_icao'];
@@ -1951,40 +1951,40 @@  discard block
 block discarded – undo
1951 1951
         			foreach ($alldata as $key => $row) {
1952 1952
     					$count[$key] = $row['airport_arrival_icao_count'];
1953 1953
 		        	}
1954
-        			array_multisort($count,SORT_DESC,$alldata);
1954
+        			array_multisort($count, SORT_DESC, $alldata);
1955 1955
 				foreach ($alldata as $number) {
1956
-					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);
1956
+					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);
1957 1957
 				}
1958 1958
 				$Spotter = new Spotter($this->db);
1959 1959
 				$alldata = $Spotter->countAllMonths($filter);
1960 1960
 				$lastyear = false;
1961 1961
 				foreach ($alldata as $number) {
1962 1962
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1963
-					$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);
1963
+					$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);
1964 1964
 				}
1965 1965
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1966 1966
 				foreach ($alldata as $number) {
1967
-					$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);
1967
+					$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);
1968 1968
 				}
1969 1969
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1970 1970
 				foreach ($alldata as $number) {
1971
-					$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);
1971
+					$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);
1972 1972
 				}
1973 1973
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
1974 1974
 				foreach ($alldata as $number) {
1975
-					$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);
1975
+					$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);
1976 1976
 				}
1977 1977
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1978 1978
 				foreach ($alldata as $number) {
1979
-					$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);
1979
+					$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);
1980 1980
 				}
1981 1981
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1982 1982
 				foreach ($alldata as $number) {
1983
-					$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);
1983
+					$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);
1984 1984
 				}
1985 1985
 				echo '...Departure'."\n";
1986
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1987
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1986
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
1987
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
1988 1988
 				foreach ($dall as $value) {
1989 1989
     					$icao = $value['departure_airport_icao'];
1990 1990
     					$ddate = $value['date'];
@@ -2002,11 +2002,11 @@  discard block
 block discarded – undo
2002 2002
     				}
2003 2003
 	    			$alldata = $pall;
2004 2004
 				foreach ($alldata as $number) {
2005
-					$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);
2005
+					$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);
2006 2006
 				}
2007 2007
 				echo '...Arrival'."\n";
2008
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2009
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2008
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
2009
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
2010 2010
 				foreach ($dall as $value) {
2011 2011
 					$icao = $value['arrival_airport_icao'];
2012 2012
 					$ddate = $value['date'];
@@ -2024,40 +2024,40 @@  discard block
 block discarded – undo
2024 2024
     				}
2025 2025
     				$alldata = $pall;
2026 2026
 				foreach ($alldata as $number) {
2027
-					$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);
2027
+					$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);
2028 2028
 				}
2029 2029
     
2030 2030
 				echo 'Flights data...'."\n";
2031 2031
 				echo '-> countAllDatesLastMonth...'."\n";
2032 2032
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
2033 2033
 				foreach ($alldata as $number) {
2034
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
2034
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
2035 2035
 				}
2036 2036
 				echo '-> countAllDates...'."\n";
2037
-				$previousdata = $this->countAllDates('',$filter_name);
2038
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
2037
+				$previousdata = $this->countAllDates('', $filter_name);
2038
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
2039 2039
 				$values = array();
2040 2040
 				foreach ($alldata as $cnt) {
2041 2041
 					$values[] = $cnt['date_count'];
2042 2042
 				}
2043
-				array_multisort($values,SORT_DESC,$alldata);
2044
-				array_splice($alldata,11);
2043
+				array_multisort($values, SORT_DESC, $alldata);
2044
+				array_splice($alldata, 11);
2045 2045
 				foreach ($alldata as $number) {
2046
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
2046
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
2047 2047
 				}
2048 2048
 				
2049 2049
 				echo '-> countAllHours...'."\n";
2050
-				$alldata = $Spotter->countAllHours('hour',$filter);
2050
+				$alldata = $Spotter->countAllHours('hour', $filter);
2051 2051
 				foreach ($alldata as $number) {
2052
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
2052
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
2053 2053
 				}
2054 2054
 				echo 'Insert last stats update date...'."\n";
2055 2055
 				date_default_timezone_set('UTC');
2056
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
2056
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
2057 2057
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
2058
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
2058
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
2059 2059
 						$this->deleteOldStats($filter_name);
2060
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
2060
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2061 2061
 					}
2062 2062
 				}
2063 2063
 
@@ -2070,16 +2070,16 @@  discard block
 block discarded – undo
2070 2070
 				// SUM all previous month to put as year
2071 2071
 				$previous_year = date('Y');
2072 2072
 				$previous_year--;
2073
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2074
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2075
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2076
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2073
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2074
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2075
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2076
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2077 2077
 				$allairlines = $this->getAllAirlineNames();
2078 2078
 				foreach ($allairlines as $data) {
2079
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2080
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2081
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2082
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2079
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2080
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2081
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2082
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2083 2083
 				}
2084 2084
 				
2085 2085
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2088,7 +2088,7 @@  discard block
 block discarded – undo
2088 2088
 						try {
2089 2089
 							$sth = $this->db->prepare($query);
2090 2090
 							$sth->execute();
2091
-						} catch(PDOException $e) {
2091
+						} catch (PDOException $e) {
2092 2092
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2093 2093
 						}
2094 2094
 					}
@@ -2097,15 +2097,15 @@  discard block
 block discarded – undo
2097 2097
 					try {
2098 2098
 						$sth = $this->db->prepare($query);
2099 2099
 						$sth->execute();
2100
-					} catch(PDOException $e) {
2100
+					} catch (PDOException $e) {
2101 2101
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2102 2102
 					}
2103 2103
 				}
2104 2104
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2105 2105
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2106
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2106
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2107 2107
 						$this->deleteOldStats();
2108
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2108
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2109 2109
 						$lastyearupdate = true;
2110 2110
 					}
2111 2111
 				}
@@ -2127,7 +2127,7 @@  discard block
 block discarded – undo
2127 2127
 					try {
2128 2128
 						$sth = $this->db->prepare($query);
2129 2129
 						$sth->execute();
2130
-					} catch(PDOException $e) {
2130
+					} catch (PDOException $e) {
2131 2131
 						return "error : ".$e->getMessage();
2132 2132
 					}
2133 2133
 				}
@@ -2141,14 +2141,14 @@  discard block
 block discarded – undo
2141 2141
 				try {
2142 2142
 					$sth = $this->db->prepare($query);
2143 2143
 					$sth->execute();
2144
-				} catch(PDOException $e) {
2144
+				} catch (PDOException $e) {
2145 2145
 					return "error : ".$e->getMessage();
2146 2146
 				}
2147 2147
 			}
2148 2148
 			if (!isset($lastyearupdate)) {
2149 2149
 				echo 'Insert last stats update date...'."\n";
2150 2150
 				date_default_timezone_set('UTC');
2151
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2151
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2152 2152
 			}
2153 2153
 			if ($globalStatsResetYear) {
2154 2154
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +465 added lines, -161 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -77,7 +79,9 @@  discard block
 block discarded – undo
77 79
                 }
78 80
         }
79 81
 	public function getAllAirlineNames($filter_name = '') {
80
-		if ($filter_name == '') $filter_name = $this->filter_name;
82
+		if ($filter_name == '') {
83
+			$filter_name = $this->filter_name;
84
+		}
81 85
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82 86
                  try {
83 87
                         $sth = $this->db->prepare($query);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
                 return $all;
90 94
         }
91 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92
-		if ($filter_name == '') $filter_name = $this->filter_name;
96
+		if ($filter_name == '') {
97
+			$filter_name = $this->filter_name;
98
+		}
93 99
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 100
                  try {
95 101
                         $sth = $this->db->prepare($query);
@@ -101,7 +107,9 @@  discard block
 block discarded – undo
101 107
                 return $all;
102 108
         }
103 109
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104
-		if ($filter_name == '') $filter_name = $this->filter_name;
110
+		if ($filter_name == '') {
111
+			$filter_name = $this->filter_name;
112
+		}
105 113
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 114
                  try {
107 115
                         $sth = $this->db->prepare($query);
@@ -113,7 +121,9 @@  discard block
 block discarded – undo
113 121
                 return $all;
114 122
         }
115 123
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
124
+		if ($filter_name == '') {
125
+			$filter_name = $this->filter_name;
126
+		}
117 127
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 128
                  try {
119 129
                         $sth = $this->db->prepare($query);
@@ -126,7 +136,9 @@  discard block
 block discarded – undo
126 136
         }
127 137
 
128 138
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129
-		if ($filter_name == '') $filter_name = $this->filter_name;
139
+		if ($filter_name == '') {
140
+			$filter_name = $this->filter_name;
141
+		}
130 142
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 143
                  try {
132 144
                         $sth = $this->db->prepare($query);
@@ -139,7 +151,9 @@  discard block
 block discarded – undo
139 151
         }
140 152
 
141 153
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142
-		if ($filter_name == '') $filter_name = $this->filter_name;
154
+		if ($filter_name == '') {
155
+			$filter_name = $this->filter_name;
156
+		}
143 157
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144 158
                  try {
145 159
                         $sth = $this->db->prepare($query);
@@ -154,10 +168,15 @@  discard block
 block discarded – undo
154 168
 
155 169
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
156 170
 		global $globalStatsFilters;
157
-		if ($filter_name == '') $filter_name = $this->filter_name;
171
+		if ($filter_name == '') {
172
+			$filter_name = $this->filter_name;
173
+		}
158 174
 		if ($year == '' && $month == '') {
159
-			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";
160
-			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";
175
+			if ($limit) {
176
+				$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";
177
+			} else {
178
+				$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
+			}
161 180
 			try {
162 181
 				$sth = $this->db->prepare($query);
163 182
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -165,7 +184,9 @@  discard block
 block discarded – undo
165 184
 				echo "error : ".$e->getMessage();
166 185
 			}
167 186
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168
-		} else $all = array();
187
+		} else {
188
+			$all = array();
189
+		}
169 190
                 if (empty($all)) {
170 191
             	    $filters = array('airlines' => array($stats_airline));
171 192
             	    if ($filter_name != '') {
@@ -178,10 +199,15 @@  discard block
 block discarded – undo
178 199
 	}
179 200
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 201
 		global $globalStatsFilters;
181
-		if ($filter_name == '') $filter_name = $this->filter_name;
202
+		if ($filter_name == '') {
203
+			$filter_name = $this->filter_name;
204
+		}
182 205
 		if ($year == '' && $month == '') {
183
-			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";
184
-			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";
206
+			if ($limit) {
207
+				$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";
208
+			} else {
209
+				$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";
210
+			}
185 211
 			try {
186 212
 				$sth = $this->db->prepare($query);
187 213
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -189,7 +215,9 @@  discard block
 block discarded – undo
189 215
 				echo "error : ".$e->getMessage();
190 216
 			}
191 217
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-		} else $all = array();
218
+		} else {
219
+			$all = array();
220
+		}
193 221
                 if (empty($all)) {
194 222
             		$Spotter = new Spotter($this->db);
195 223
             		$filters = array();
@@ -202,10 +230,15 @@  discard block
 block discarded – undo
202 230
 	}
203 231
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 232
 		global $globalStatsFilters;
205
-		if ($filter_name == '') $filter_name = $this->filter_name;
233
+		if ($filter_name == '') {
234
+			$filter_name = $this->filter_name;
235
+		}
206 236
 		if ($year == '' && $month == '') {
207
-			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";
208
-			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";
237
+			if ($limit) {
238
+				$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";
239
+			} else {
240
+				$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";
241
+			}
209 242
 			try {
210 243
 				$sth = $this->db->prepare($query);
211 244
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -213,7 +246,9 @@  discard block
 block discarded – undo
213 246
 				echo "error : ".$e->getMessage();
214 247
 			}
215 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
216
-		} else $all = array();
249
+		} else {
250
+			$all = array();
251
+		}
217 252
 		if (empty($all)) {
218 253
 			$filters = array('airlines' => array($stats_airline));
219 254
 			if ($filter_name != '') {
@@ -227,10 +262,15 @@  discard block
 block discarded – undo
227 262
 
228 263
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
229 264
 		global $globalStatsFilters;
230
-		if ($filter_name == '') $filter_name = $this->filter_name;
265
+		if ($filter_name == '') {
266
+			$filter_name = $this->filter_name;
267
+		}
231 268
 		if ($year == '' && $month == '') {
232
-			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";
233
-			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";
269
+			if ($limit) {
270
+				$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";
271
+			} else {
272
+				$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";
273
+			}
234 274
 			try {
235 275
 				$sth = $this->db->prepare($query);
236 276
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -238,7 +278,9 @@  discard block
 block discarded – undo
238 278
 				echo "error : ".$e->getMessage();
239 279
 			}
240 280
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241
-		} else $all = array();
281
+		} else {
282
+			$all = array();
283
+		}
242 284
                 if (empty($all)) {
243 285
 			$filters = array('airlines' => array($stats_airline));
244 286
 			if ($filter_name != '') {
@@ -251,9 +293,14 @@  discard block
 block discarded – undo
251 293
 	}
252 294
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 295
 		global $globalStatsFilters;
254
-		if ($filter_name == '') $filter_name = $this->filter_name;
255
-		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";
256
-		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";
296
+		if ($filter_name == '') {
297
+			$filter_name = $this->filter_name;
298
+		}
299
+		if ($limit) {
300
+			$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";
301
+		} else {
302
+			$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";
303
+		}
257 304
                  try {
258 305
                         $sth = $this->db->prepare($query);
259 306
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -274,10 +321,15 @@  discard block
 block discarded – undo
274 321
 
275 322
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
276 323
 		global $globalStatsFilters;
277
-		if ($filter_name == '') $filter_name = $this->filter_name;
324
+		if ($filter_name == '') {
325
+			$filter_name = $this->filter_name;
326
+		}
278 327
 		if ($year == '' && $month == '') {
279
-			if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
280
-			else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
328
+			if ($limit) {
329
+				$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
330
+			} else {
331
+				$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
332
+			}
281 333
 			try {
282 334
 				$sth = $this->db->prepare($query);
283 335
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -285,7 +337,9 @@  discard block
 block discarded – undo
285 337
 				echo "error : ".$e->getMessage();
286 338
 			}
287 339
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
288
-		} else $all = array();
340
+		} else {
341
+			$all = array();
342
+		}
289 343
                 if (empty($all)) {
290 344
 	                $Spotter = new Spotter($this->db);
291 345
             		$filters = array();
@@ -299,10 +353,15 @@  discard block
 block discarded – undo
299 353
 	}
300 354
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
301 355
 		global $globalStatsFilters;
302
-		if ($filter_name == '') $filter_name = $this->filter_name;
356
+		if ($filter_name == '') {
357
+			$filter_name = $this->filter_name;
358
+		}
303 359
 		if ($year == '' && $month == '') {
304
-			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";
305
-			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";
360
+			if ($limit) {
361
+				$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";
362
+			} else {
363
+				$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";
364
+			}
306 365
 			try {
307 366
 				$sth = $this->db->prepare($query);
308 367
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -310,7 +369,9 @@  discard block
 block discarded – undo
310 369
 				echo "error : ".$e->getMessage();
311 370
 			}
312 371
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313
-		} else $all = array();
372
+		} else {
373
+			$all = array();
374
+		}
314 375
                 if (empty($all)) {
315 376
 			$filters = array('airlines' => array($stats_airline));
316 377
 			if ($filter_name != '') {
@@ -323,10 +384,15 @@  discard block
 block discarded – undo
323 384
 	}
324 385
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
325 386
 		global $globalStatsFilters;
326
-		if ($filter_name == '') $filter_name = $this->filter_name;
387
+		if ($filter_name == '') {
388
+			$filter_name = $this->filter_name;
389
+		}
327 390
 		if ($year == '' && $month == '') {
328
-			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";
329
-			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";
391
+			if ($limit) {
392
+				$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";
393
+			} else {
394
+				$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";
395
+			}
330 396
 			 try {
331 397
 				$sth = $this->db->prepare($query);
332 398
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -334,7 +400,9 @@  discard block
 block discarded – undo
334 400
 				echo "error : ".$e->getMessage();
335 401
 			}
336 402
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
337
-		} else $all = array();
403
+		} else {
404
+			$all = array();
405
+		}
338 406
 		if (empty($all)) {
339 407
 			$filters = array('airlines' => array($stats_airline));
340 408
 			if ($filter_name != '') {
@@ -347,11 +415,16 @@  discard block
 block discarded – undo
347 415
 	}
348 416
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
349 417
 		$Connection = new Connection();
350
-		if ($filter_name == '') $filter_name = $this->filter_name;
418
+		if ($filter_name == '') {
419
+			$filter_name = $this->filter_name;
420
+		}
351 421
 		if ($Connection->tableExists('countries')) {
352 422
 			if ($year == '' && $month == '') {
353
-				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";
354
-				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";
423
+				if ($limit) {
424
+					$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";
425
+				} else {
426
+					$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";
427
+				}
355 428
 				 try {
356 429
 					$sth = $this->db->prepare($query);
357 430
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -366,17 +439,24 @@  discard block
 block discarded – undo
366 439
                 }
367 440
                 */
368 441
 				return $all;
369
-			} else return array();
442
+			} else {
443
+				return array();
444
+			}
370 445
 		} else {
371 446
 			return array();
372 447
 		}
373 448
 	}
374 449
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
375 450
 		global $globalStatsFilters;
376
-		if ($filter_name == '') $filter_name = $this->filter_name;
451
+		if ($filter_name == '') {
452
+			$filter_name = $this->filter_name;
453
+		}
377 454
 		if ($year == '' && $month == '') {
378
-			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";
379
-			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";
455
+			if ($limit) {
456
+				$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";
457
+			} else {
458
+				$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";
459
+			}
380 460
 			try {
381 461
 				$sth = $this->db->prepare($query);
382 462
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -384,7 +464,9 @@  discard block
 block discarded – undo
384 464
 				echo "error : ".$e->getMessage();
385 465
 			}
386 466
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
387
-		} else $all = array();
467
+		} else {
468
+			$all = array();
469
+		}
388 470
 		if (empty($all)) {
389 471
 			$filters = array('airlines' => array($stats_airline));
390 472
 			if ($filter_name != '') {
@@ -398,10 +480,15 @@  discard block
 block discarded – undo
398 480
 
399 481
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
400 482
 		global $globalStatsFilters;
401
-		if ($filter_name == '') $filter_name = $this->filter_name;
483
+		if ($filter_name == '') {
484
+			$filter_name = $this->filter_name;
485
+		}
402 486
 		if ($year == '' && $month == '') {
403
-			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";
404
-			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";
487
+			if ($limit) {
488
+				$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";
489
+			} else {
490
+				$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";
491
+			}
405 492
 			try {
406 493
 				$sth = $this->db->prepare($query);
407 494
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -409,7 +496,9 @@  discard block
 block discarded – undo
409 496
 				echo "error : ".$e->getMessage();
410 497
 			}
411 498
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
412
-		} else $all = array();
499
+		} else {
500
+			$all = array();
501
+		}
413 502
                 if (empty($all)) {
414 503
 			$filters = array('airlines' => array($stats_airline));
415 504
 			if ($filter_name != '') {
@@ -422,10 +511,15 @@  discard block
 block discarded – undo
422 511
 	}
423 512
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
424 513
 		global $globalStatsFilters;
425
-		if ($filter_name == '') $filter_name = $this->filter_name;
514
+		if ($filter_name == '') {
515
+			$filter_name = $this->filter_name;
516
+		}
426 517
 		if ($year == '' && $month == '') {
427
-			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";
428
-			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";
518
+			if ($limit) {
519
+				$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";
520
+			} else {
521
+				$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";
522
+			}
429 523
 			try {
430 524
 				$sth = $this->db->prepare($query);
431 525
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -433,7 +527,9 @@  discard block
 block discarded – undo
433 527
 				echo "error : ".$e->getMessage();
434 528
 			}
435 529
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
436
-		} else $all = array();
530
+		} else {
531
+			$all = array();
532
+		}
437 533
                 if (empty($all)) {
438 534
 			$filters = array('airlines' => array($stats_airline));
439 535
             		if ($filter_name != '') {
@@ -452,7 +548,9 @@  discard block
 block discarded – undo
452 548
         			$icao = $value['airport_departure_icao'];
453 549
         			if (isset($all[$icao])) {
454 550
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
-        			} else $all[$icao] = $value;
551
+        			} else {
552
+        				$all[$icao] = $value;
553
+        			}
456 554
         		}
457 555
         		$count = array();
458 556
         		foreach ($all as $key => $row) {
@@ -464,10 +562,15 @@  discard block
 block discarded – undo
464 562
 	}
465 563
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
466 564
 		global $globalStatsFilters;
467
-		if ($filter_name == '') $filter_name = $this->filter_name;
565
+		if ($filter_name == '') {
566
+			$filter_name = $this->filter_name;
567
+		}
468 568
 		if ($year == '' && $month == '') {
469
-			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";
470
-			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";
569
+			if ($limit) {
570
+				$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";
571
+			} else {
572
+				$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";
573
+			}
471 574
 			try {
472 575
 				$sth = $this->db->prepare($query);
473 576
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -475,7 +578,9 @@  discard block
 block discarded – undo
475 578
 				echo "error : ".$e->getMessage();
476 579
 			}
477 580
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
478
-		} else $all = array();
581
+		} else {
582
+			$all = array();
583
+		}
479 584
 		if (empty($all)) {
480 585
 			$filters = array('airlines' => array($stats_airline));
481 586
 			if ($filter_name != '') {
@@ -494,7 +599,9 @@  discard block
 block discarded – undo
494 599
         			$icao = $value['airport_arrival_icao'];
495 600
         			if (isset($all[$icao])) {
496 601
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
-        			} else $all[$icao] = $value;
602
+        			} else {
603
+        				$all[$icao] = $value;
604
+        			}
498 605
         		}
499 606
         		$count = array();
500 607
         		foreach ($all as $key => $row) {
@@ -507,13 +614,21 @@  discard block
 block discarded – undo
507 614
 	}
508 615
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
509 616
 		global $globalDBdriver, $globalStatsFilters;
510
-		if ($filter_name == '') $filter_name = $this->filter_name;
617
+		if ($filter_name == '') {
618
+			$filter_name = $this->filter_name;
619
+		}
511 620
 		if ($globalDBdriver == 'mysql') {
512
-			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";
513
-			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";
621
+			if ($limit) {
622
+				$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";
623
+			} else {
624
+				$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";
625
+			}
514 626
 		} else {
515
-			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";
516
-			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";
627
+			if ($limit) {
628
+				$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";
629
+			} else {
630
+				$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";
631
+			}
517 632
 		}
518 633
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
519 634
                  try {
@@ -537,7 +652,9 @@  discard block
 block discarded – undo
537 652
 	
538 653
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
539 654
 		global $globalStatsFilters;
540
-		if ($filter_name == '') $filter_name = $this->filter_name;
655
+		if ($filter_name == '') {
656
+			$filter_name = $this->filter_name;
657
+		}
541 658
 		$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";
542 659
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
543 660
                  try {
@@ -559,7 +676,9 @@  discard block
 block discarded – undo
559 676
 	}
560 677
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
561 678
 		global $globalDBdriver, $globalStatsFilters;
562
-		if ($filter_name == '') $filter_name = $this->filter_name;
679
+		if ($filter_name == '') {
680
+			$filter_name = $this->filter_name;
681
+		}
563 682
 		if ($globalDBdriver == 'mysql') {
564 683
 			$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";
565 684
 		} else {
@@ -585,7 +704,9 @@  discard block
 block discarded – undo
585 704
 	}
586 705
 	public function countAllDates($stats_airline = '',$filter_name = '') {
587 706
 		global $globalStatsFilters;
588
-		if ($filter_name == '') $filter_name = $this->filter_name;
707
+		if ($filter_name == '') {
708
+			$filter_name = $this->filter_name;
709
+		}
589 710
 		$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";
590 711
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
591 712
                  try {
@@ -607,7 +728,9 @@  discard block
 block discarded – undo
607 728
 	}
608 729
 	public function countAllDatesByAirlines($filter_name = '') {
609 730
 		global $globalStatsFilters;
610
-		if ($filter_name == '') $filter_name = $this->filter_name;
731
+		if ($filter_name == '') {
732
+			$filter_name = $this->filter_name;
733
+		}
611 734
 		$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";
612 735
 		$query_data = array('filter_name' => $filter_name);
613 736
                  try {
@@ -629,7 +752,9 @@  discard block
 block discarded – undo
629 752
 	}
630 753
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
631 754
 		global $globalStatsFilters;
632
-		if ($filter_name == '') $filter_name = $this->filter_name;
755
+		if ($filter_name == '') {
756
+			$filter_name = $this->filter_name;
757
+		}
633 758
 	    	$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";
634 759
                  try {
635 760
                         $sth = $this->db->prepare($query);
@@ -652,7 +777,9 @@  discard block
 block discarded – undo
652 777
 	}
653 778
 	public function countAllMilitaryMonths($filter_name = '') {
654 779
 		global $globalStatsFilters;
655
-		if ($filter_name == '') $filter_name = $this->filter_name;
780
+		if ($filter_name == '') {
781
+			$filter_name = $this->filter_name;
782
+		}
656 783
 	    	$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";
657 784
                  try {
658 785
                         $sth = $this->db->prepare($query);
@@ -673,9 +800,14 @@  discard block
 block discarded – undo
673 800
 	}
674 801
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
675 802
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
676
-		if ($filter_name == '') $filter_name = $this->filter_name;
677
-		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";
678
-		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";
803
+		if ($filter_name == '') {
804
+			$filter_name = $this->filter_name;
805
+		}
806
+		if ($limit) {
807
+			$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";
808
+		} else {
809
+			$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";
810
+		}
679 811
 		if ($orderby == 'hour') {
680 812
 			/*
681 813
 			if ($globalDBdriver == 'mysql') {
@@ -684,7 +816,9 @@  discard block
 block discarded – undo
684 816
 			*/
685 817
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
686 818
 		}
687
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
819
+		if ($orderby == 'count') {
820
+			$query .= " ORDER BY hour_count DESC";
821
+		}
688 822
                  try {
689 823
                         $sth = $this->db->prepare($query);
690 824
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -705,8 +839,12 @@  discard block
 block discarded – undo
705 839
 	
706 840
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
707 841
 		global $globalStatsFilters;
708
-		if ($filter_name == '') $filter_name = $this->filter_name;
709
-		if ($year == '') $year = date('Y');
842
+		if ($filter_name == '') {
843
+			$filter_name = $this->filter_name;
844
+		}
845
+		if ($year == '') {
846
+			$year = date('Y');
847
+		}
710 848
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
711 849
 		if (empty($all)) {
712 850
 			$filters = array('airlines' => array($stats_airline));
@@ -720,8 +858,12 @@  discard block
 block discarded – undo
720 858
 	}
721 859
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
722 860
 		global $globalStatsFilters;
723
-		if ($filter_name == '') $filter_name = $this->filter_name;
724
-		if ($year == '') $year = date('Y');
861
+		if ($filter_name == '') {
862
+			$filter_name = $this->filter_name;
863
+		}
864
+		if ($year == '') {
865
+			$year = date('Y');
866
+		}
725 867
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
726 868
 		if (empty($all)) {
727 869
 		        $filters = array();
@@ -735,8 +877,12 @@  discard block
 block discarded – undo
735 877
 	}
736 878
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
737 879
 		global $globalStatsFilters;
738
-		if ($filter_name == '') $filter_name = $this->filter_name;
739
-		if ($year == '') $year = date('Y');
880
+		if ($filter_name == '') {
881
+			$filter_name = $this->filter_name;
882
+		}
883
+		if ($year == '') {
884
+			$year = date('Y');
885
+		}
740 886
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
741 887
 		if (empty($all)) {
742 888
 			$filters = array('airlines' => array($stats_airline));
@@ -750,7 +896,9 @@  discard block
 block discarded – undo
750 896
 	}
751 897
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
752 898
 		global $globalStatsFilters;
753
-		if ($filter_name == '') $filter_name = $this->filter_name;
899
+		if ($filter_name == '') {
900
+			$filter_name = $this->filter_name;
901
+		}
754 902
 		if ($year == '' && $month == '') {
755 903
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
756 904
 			try {
@@ -761,7 +909,9 @@  discard block
 block discarded – undo
761 909
 			}
762 910
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
763 911
 			$all = $result[0]['nb'];
764
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
912
+		} else {
913
+			$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
914
+		}
765 915
 		if (empty($all)) {
766 916
 			$filters = array('airlines' => array($stats_airline));
767 917
 			if ($filter_name != '') {
@@ -774,7 +924,9 @@  discard block
 block discarded – undo
774 924
 	}
775 925
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
776 926
 		global $globalStatsFilters;
777
-		if ($filter_name == '') $filter_name = $this->filter_name;
927
+		if ($filter_name == '') {
928
+			$filter_name = $this->filter_name;
929
+		}
778 930
 		if ($year == '' && $month == '') {
779 931
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
780 932
 			try {
@@ -785,7 +937,9 @@  discard block
 block discarded – undo
785 937
 			}
786 938
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
787 939
 			$all = $result[0]['nb_airline'];
788
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
940
+		} else {
941
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
942
+		}
789 943
 		if (empty($all)) {
790 944
             		$filters = array();
791 945
             		if ($filter_name != '') {
@@ -798,7 +952,9 @@  discard block
 block discarded – undo
798 952
 	}
799 953
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
800 954
 		global $globalStatsFilters;
801
-		if ($filter_name == '') $filter_name = $this->filter_name;
955
+		if ($filter_name == '') {
956
+			$filter_name = $this->filter_name;
957
+		}
802 958
 		if ($year == '' && $month == '') {
803 959
 			$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
804 960
 			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
@@ -825,7 +981,9 @@  discard block
 block discarded – undo
825 981
 	}
826 982
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
827 983
 		global $globalStatsFilters;
828
-		if ($filter_name == '') $filter_name = $this->filter_name;
984
+		if ($filter_name == '') {
985
+			$filter_name = $this->filter_name;
986
+		}
829 987
 		//if ($year == '') $year = date('Y');
830 988
 		if ($year == '' && $month == '') {
831 989
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -853,7 +1011,9 @@  discard block
 block discarded – undo
853 1011
 	}
854 1012
 
855 1013
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
856
-		if ($filter_name == '') $filter_name = $this->filter_name;
1014
+		if ($filter_name == '') {
1015
+			$filter_name = $this->filter_name;
1016
+		}
857 1017
 		$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";
858 1018
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
859 1019
                  try {
@@ -866,7 +1026,9 @@  discard block
 block discarded – undo
866 1026
                 return $all;
867 1027
 	}
868 1028
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
869
-		if ($filter_name == '') $filter_name = $this->filter_name;
1029
+		if ($filter_name == '') {
1030
+			$filter_name = $this->filter_name;
1031
+		}
870 1032
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
871 1033
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
872 1034
                  try {
@@ -879,7 +1041,9 @@  discard block
 block discarded – undo
879 1041
                 return $all;
880 1042
         }
881 1043
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
882
-		if ($filter_name == '') $filter_name = $this->filter_name;
1044
+		if ($filter_name == '') {
1045
+			$filter_name = $this->filter_name;
1046
+		}
883 1047
     		global $globalArchiveMonths, $globalDBdriver;
884 1048
     		if ($globalDBdriver == 'mysql') {
885 1049
     			if ($month == '') {
@@ -909,7 +1073,9 @@  discard block
 block discarded – undo
909 1073
         }
910 1074
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
911 1075
     		global $globalArchiveMonths, $globalDBdriver;
912
-		if ($filter_name == '') $filter_name = $this->filter_name;
1076
+		if ($filter_name == '') {
1077
+			$filter_name = $this->filter_name;
1078
+		}
913 1079
     		if ($globalDBdriver == 'mysql') {
914 1080
 			$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";
915 1081
 		} else {
@@ -927,7 +1093,9 @@  discard block
 block discarded – undo
927 1093
         }
928 1094
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
929 1095
     		global $globalArchiveMonths, $globalDBdriver;
930
-		if ($filter_name == '') $filter_name = $this->filter_name;
1096
+		if ($filter_name == '') {
1097
+			$filter_name = $this->filter_name;
1098
+		}
931 1099
     		if ($globalDBdriver == 'mysql') {
932 1100
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
933 1101
                 } else {
@@ -944,7 +1112,9 @@  discard block
 block discarded – undo
944 1112
         }
945 1113
 	public function getStatsAirlineTotal($filter_name = '') {
946 1114
     		global $globalArchiveMonths, $globalDBdriver;
947
-		if ($filter_name == '') $filter_name = $this->filter_name;
1115
+		if ($filter_name == '') {
1116
+			$filter_name = $this->filter_name;
1117
+		}
948 1118
     		if ($globalDBdriver == 'mysql') {
949 1119
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
950 1120
                 } else {
@@ -961,7 +1131,9 @@  discard block
 block discarded – undo
961 1131
         }
962 1132
 	public function getStatsOwnerTotal($filter_name = '') {
963 1133
     		global $globalArchiveMonths, $globalDBdriver;
964
-		if ($filter_name == '') $filter_name = $this->filter_name;
1134
+		if ($filter_name == '') {
1135
+			$filter_name = $this->filter_name;
1136
+		}
965 1137
     		if ($globalDBdriver == 'mysql') {
966 1138
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
967 1139
 		} else {
@@ -978,7 +1150,9 @@  discard block
 block discarded – undo
978 1150
         }
979 1151
 	public function getStatsOwner($owner_name,$filter_name = '') {
980 1152
     		global $globalArchiveMonths, $globalDBdriver;
981
-		if ($filter_name == '') $filter_name = $this->filter_name;
1153
+		if ($filter_name == '') {
1154
+			$filter_name = $this->filter_name;
1155
+		}
982 1156
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
983 1157
                  try {
984 1158
                         $sth = $this->db->prepare($query);
@@ -987,12 +1161,17 @@  discard block
 block discarded – undo
987 1161
                         echo "error : ".$e->getMessage();
988 1162
                 }
989 1163
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
990
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
991
-                else return 0;
1164
+                if (isset($all[0]['cnt'])) {
1165
+                	return $all[0]['cnt'];
1166
+                } else {
1167
+                	return 0;
1168
+                }
992 1169
         }
993 1170
 	public function getStatsPilotTotal($filter_name = '') {
994 1171
     		global $globalArchiveMonths, $globalDBdriver;
995
-		if ($filter_name == '') $filter_name = $this->filter_name;
1172
+		if ($filter_name == '') {
1173
+			$filter_name = $this->filter_name;
1174
+		}
996 1175
     		if ($globalDBdriver == 'mysql') {
997 1176
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
998 1177
             	} else {
@@ -1009,7 +1188,9 @@  discard block
 block discarded – undo
1009 1188
         }
1010 1189
 	public function getStatsPilot($pilot,$filter_name = '') {
1011 1190
     		global $globalArchiveMonths, $globalDBdriver;
1012
-		if ($filter_name == '') $filter_name = $this->filter_name;
1191
+		if ($filter_name == '') {
1192
+			$filter_name = $this->filter_name;
1193
+		}
1013 1194
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1014 1195
                  try {
1015 1196
                         $sth = $this->db->prepare($query);
@@ -1018,13 +1199,18 @@  discard block
 block discarded – undo
1018 1199
                         echo "error : ".$e->getMessage();
1019 1200
                 }
1020 1201
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1021
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1022
-                else return 0;
1202
+                if (isset($all[0]['cnt'])) {
1203
+                	return $all[0]['cnt'];
1204
+                } else {
1205
+                	return 0;
1206
+                }
1023 1207
         }
1024 1208
 
1025 1209
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1026 1210
 		global $globalDBdriver;
1027
-		if ($filter_name == '') $filter_name = $this->filter_name;
1211
+		if ($filter_name == '') {
1212
+			$filter_name = $this->filter_name;
1213
+		}
1028 1214
 		if ($globalDBdriver == 'mysql') {
1029 1215
 			$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";
1030 1216
                 } else {
@@ -1040,7 +1226,9 @@  discard block
 block discarded – undo
1040 1226
         }
1041 1227
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1042 1228
 		global $globalDBdriver;
1043
-		if ($filter_name == '') $filter_name = $this->filter_name;
1229
+		if ($filter_name == '') {
1230
+			$filter_name = $this->filter_name;
1231
+		}
1044 1232
 		if ($globalDBdriver == 'mysql') {
1045 1233
 			$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";
1046 1234
 		} else {
@@ -1426,10 +1614,14 @@  discard block
 block discarded – undo
1426 1614
     		$Connection = new Connection();
1427 1615
     		date_default_timezone_set('UTC');
1428 1616
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1429
-			if ($globalDebug) echo 'Update stats !'."\n";
1617
+			if ($globalDebug) {
1618
+				echo 'Update stats !'."\n";
1619
+			}
1430 1620
 			if (isset($last_update[0]['value'])) {
1431 1621
 				$last_update_day = $last_update[0]['value'];
1432
-			} else $last_update_day = '2012-12-12 12:12:12';
1622
+			} else {
1623
+				$last_update_day = '2012-12-12 12:12:12';
1624
+			}
1433 1625
 			$reset = false;
1434 1626
 			if ($globalStatsResetYear) {
1435 1627
 				$reset = true;
@@ -1437,42 +1629,60 @@  discard block
 block discarded – undo
1437 1629
 			}
1438 1630
 			$Spotter = new Spotter($this->db);
1439 1631
 
1440
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1632
+			if ($globalDebug) {
1633
+				echo 'Count all aircraft types...'."\n";
1634
+			}
1441 1635
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1442 1636
 			foreach ($alldata as $number) {
1443 1637
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1444 1638
 			}
1445
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1639
+			if ($globalDebug) {
1640
+				echo 'Count all airlines...'."\n";
1641
+			}
1446 1642
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1447 1643
 			foreach ($alldata as $number) {
1448 1644
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1449 1645
 			}
1450
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1646
+			if ($globalDebug) {
1647
+				echo 'Count all registrations...'."\n";
1648
+			}
1451 1649
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1452 1650
 			foreach ($alldata as $number) {
1453 1651
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1454 1652
 			}
1455
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1653
+			if ($globalDebug) {
1654
+				echo 'Count all callsigns...'."\n";
1655
+			}
1456 1656
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1457 1657
 			foreach ($alldata as $number) {
1458 1658
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1459 1659
 			}
1460
-			if ($globalDebug) echo 'Count all owners...'."\n";
1660
+			if ($globalDebug) {
1661
+				echo 'Count all owners...'."\n";
1662
+			}
1461 1663
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1462 1664
 			foreach ($alldata as $number) {
1463 1665
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1464 1666
 			}
1465
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1667
+			if ($globalDebug) {
1668
+				echo 'Count all pilots...'."\n";
1669
+			}
1466 1670
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1467 1671
 			foreach ($alldata as $number) {
1468 1672
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1469 1673
 			}
1470 1674
 			
1471
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1675
+			if ($globalDebug) {
1676
+				echo 'Count all departure airports...'."\n";
1677
+			}
1472 1678
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1473
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1679
+			if ($globalDebug) {
1680
+				echo 'Count all detected departure airports...'."\n";
1681
+			}
1474 1682
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1475
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1683
+			if ($globalDebug) {
1684
+				echo 'Order departure airports...'."\n";
1685
+			}
1476 1686
 	        	$alldata = array();
1477 1687
 	        	
1478 1688
     			foreach ($pall as $value) {
@@ -1483,7 +1693,9 @@  discard block
 block discarded – undo
1483 1693
     				$icao = $value['airport_departure_icao'];
1484 1694
         			if (isset($alldata[$icao])) {
1485 1695
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1486
-        			} else $alldata[$icao] = $value;
1696
+        			} else {
1697
+        				$alldata[$icao] = $value;
1698
+        			}
1487 1699
 			}
1488 1700
     			$count = array();
1489 1701
     			foreach ($alldata as $key => $row) {
@@ -1493,11 +1705,17 @@  discard block
 block discarded – undo
1493 1705
 			foreach ($alldata as $number) {
1494 1706
 				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);
1495 1707
 			}
1496
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1708
+			if ($globalDebug) {
1709
+				echo 'Count all arrival airports...'."\n";
1710
+			}
1497 1711
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1498
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1712
+			if ($globalDebug) {
1713
+				echo 'Count all detected arrival airports...'."\n";
1714
+			}
1499 1715
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1500
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1716
+			if ($globalDebug) {
1717
+				echo 'Order arrival airports...'."\n";
1718
+			}
1501 1719
 	        	$alldata = array();
1502 1720
     			foreach ($pall as $value) {
1503 1721
 	        		$icao = $value['airport_arrival_icao'];
@@ -1507,7 +1725,9 @@  discard block
 block discarded – undo
1507 1725
     				$icao = $value['airport_arrival_icao'];
1508 1726
         			if (isset($alldata[$icao])) {
1509 1727
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1510
-	        		} else $alldata[$icao] = $value;
1728
+	        		} else {
1729
+	        			$alldata[$icao] = $value;
1730
+	        		}
1511 1731
     			}
1512 1732
         		$count = array();
1513 1733
         		foreach ($alldata as $key => $row) {
@@ -1518,7 +1738,9 @@  discard block
 block discarded – undo
1518 1738
 				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);
1519 1739
 			}
1520 1740
 			if ($Connection->tableExists('countries')) {
1521
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1741
+				if ($globalDebug) {
1742
+					echo 'Count all flights by countries...'."\n";
1743
+				}
1522 1744
 				$SpotterArchive = new SpotterArchive();
1523 1745
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1524 1746
 				foreach ($alldata as $number) {
@@ -1530,46 +1752,66 @@  discard block
 block discarded – undo
1530 1752
 			// Add by month using getstat if month finish...
1531 1753
 
1532 1754
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1533
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1755
+			if ($globalDebug) {
1756
+				echo 'Count all flights by months...'."\n";
1757
+			}
1534 1758
 			$Spotter = new Spotter($this->db);
1535 1759
 			$alldata = $Spotter->countAllMonths();
1536 1760
 			$lastyear = false;
1537 1761
 			foreach ($alldata as $number) {
1538
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1762
+				if ($number['year_name'] != date('Y')) {
1763
+					$lastyear = true;
1764
+				}
1539 1765
 				$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'])));
1540 1766
 			}
1541
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1767
+			if ($globalDebug) {
1768
+				echo 'Count all military flights by months...'."\n";
1769
+			}
1542 1770
 			$alldata = $Spotter->countAllMilitaryMonths();
1543 1771
 			foreach ($alldata as $number) {
1544 1772
 				$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'])));
1545 1773
 			}
1546
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1774
+			if ($globalDebug) {
1775
+				echo 'Count all owners by months...'."\n";
1776
+			}
1547 1777
 			$alldata = $Spotter->countAllMonthsOwners();
1548 1778
 			foreach ($alldata as $number) {
1549 1779
 				$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'])));
1550 1780
 			}
1551
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1781
+			if ($globalDebug) {
1782
+				echo 'Count all pilots by months...'."\n";
1783
+			}
1552 1784
 			$alldata = $Spotter->countAllMonthsPilots();
1553 1785
 			foreach ($alldata as $number) {
1554 1786
 				$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'])));
1555 1787
 			}
1556
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1788
+			if ($globalDebug) {
1789
+				echo 'Count all airlines by months...'."\n";
1790
+			}
1557 1791
 			$alldata = $Spotter->countAllMonthsAirlines();
1558 1792
 			foreach ($alldata as $number) {
1559 1793
 				$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'])));
1560 1794
 			}
1561
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1795
+			if ($globalDebug) {
1796
+				echo 'Count all aircrafts by months...'."\n";
1797
+			}
1562 1798
 			$alldata = $Spotter->countAllMonthsAircrafts();
1563 1799
 			foreach ($alldata as $number) {
1564 1800
 				$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'])));
1565 1801
 			}
1566
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1802
+			if ($globalDebug) {
1803
+				echo 'Count all real arrivals by months...'."\n";
1804
+			}
1567 1805
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1568 1806
 			foreach ($alldata as $number) {
1569 1807
 				$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'])));
1570 1808
 			}
1571
-			if ($globalDebug) echo 'Airports data...'."\n";
1572
-			if ($globalDebug) echo '...Departure'."\n";
1809
+			if ($globalDebug) {
1810
+				echo 'Airports data...'."\n";
1811
+			}
1812
+			if ($globalDebug) {
1813
+				echo '...Departure'."\n";
1814
+			}
1573 1815
 			$this->deleteStatAirport('daily');
1574 1816
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1575 1817
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1690,44 +1932,62 @@  discard block
 block discarded – undo
1690 1932
 			// Count by airlines
1691 1933
 			echo '--- Stats by airlines ---'."\n";
1692 1934
 			if ($Connection->tableExists('countries')) {
1693
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1935
+				if ($globalDebug) {
1936
+					echo 'Count all flights by countries by airlines...'."\n";
1937
+				}
1694 1938
 				$SpotterArchive = new SpotterArchive();
1695 1939
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1696 1940
 				foreach ($alldata as $number) {
1697 1941
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1698 1942
 				}
1699 1943
 			}
1700
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1944
+			if ($globalDebug) {
1945
+				echo 'Count all aircraft types by airlines...'."\n";
1946
+			}
1701 1947
 			$Spotter = new Spotter($this->db);
1702 1948
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1703 1949
 			foreach ($alldata as $number) {
1704 1950
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1705 1951
 			}
1706
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1952
+			if ($globalDebug) {
1953
+				echo 'Count all aircraft registrations by airlines...'."\n";
1954
+			}
1707 1955
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1708 1956
 			foreach ($alldata as $number) {
1709 1957
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1710 1958
 			}
1711
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1959
+			if ($globalDebug) {
1960
+				echo 'Count all callsigns by airlines...'."\n";
1961
+			}
1712 1962
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1713 1963
 			foreach ($alldata as $number) {
1714 1964
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1715 1965
 			}
1716
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1966
+			if ($globalDebug) {
1967
+				echo 'Count all owners by airlines...'."\n";
1968
+			}
1717 1969
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1718 1970
 			foreach ($alldata as $number) {
1719 1971
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1720 1972
 			}
1721
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1973
+			if ($globalDebug) {
1974
+				echo 'Count all pilots by airlines...'."\n";
1975
+			}
1722 1976
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1723 1977
 			foreach ($alldata as $number) {
1724 1978
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1725 1979
 			}
1726
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1980
+			if ($globalDebug) {
1981
+				echo 'Count all departure airports by airlines...'."\n";
1982
+			}
1727 1983
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1728
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1984
+			if ($globalDebug) {
1985
+				echo 'Count all detected departure airports by airlines...'."\n";
1986
+			}
1729 1987
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1730
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1988
+			if ($globalDebug) {
1989
+				echo 'Order detected departure airports by airlines...'."\n";
1990
+			}
1731 1991
 	        	//$alldata = array();
1732 1992
     			foreach ($dall as $value) {
1733 1993
     				$icao = $value['airport_departure_icao'];
@@ -1748,11 +2008,17 @@  discard block
 block discarded – undo
1748 2008
 			foreach ($alldata as $number) {
1749 2009
 				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);
1750 2010
 			}
1751
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2011
+			if ($globalDebug) {
2012
+				echo 'Count all arrival airports by airlines...'."\n";
2013
+			}
1752 2014
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1753
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2015
+			if ($globalDebug) {
2016
+				echo 'Count all detected arrival airports by airlines...'."\n";
2017
+			}
1754 2018
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1755
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2019
+			if ($globalDebug) {
2020
+				echo 'Order arrival airports by airlines...'."\n";
2021
+			}
1756 2022
 	        	//$alldata = array();
1757 2023
     			foreach ($dall as $value) {
1758 2024
     				$icao = $value['airport_arrival_icao'];
@@ -1771,37 +2037,53 @@  discard block
 block discarded – undo
1771 2037
     			}
1772 2038
     			$alldata = $pall;
1773 2039
                         foreach ($alldata as $number) {
1774
-				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);
2040
+				if ($number['airline_icao'] != '') {
2041
+					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);
2042
+				}
2043
+			}
2044
+			if ($globalDebug) {
2045
+				echo 'Count all flights by months by airlines...'."\n";
1775 2046
 			}
1776
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1777 2047
 			$Spotter = new Spotter($this->db);
1778 2048
 			$alldata = $Spotter->countAllMonthsByAirlines();
1779 2049
 			$lastyear = false;
1780 2050
 			foreach ($alldata as $number) {
1781
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2051
+				if ($number['year_name'] != date('Y')) {
2052
+					$lastyear = true;
2053
+				}
1782 2054
 				$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']);
1783 2055
 			}
1784
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2056
+			if ($globalDebug) {
2057
+				echo 'Count all owners by months by airlines...'."\n";
2058
+			}
1785 2059
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1786 2060
 			foreach ($alldata as $number) {
1787 2061
 				$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']);
1788 2062
 			}
1789
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2063
+			if ($globalDebug) {
2064
+				echo 'Count all pilots by months by airlines...'."\n";
2065
+			}
1790 2066
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1791 2067
 			foreach ($alldata as $number) {
1792 2068
 				$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']);
1793 2069
 			}
1794
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2070
+			if ($globalDebug) {
2071
+				echo 'Count all aircrafts by months by airlines...'."\n";
2072
+			}
1795 2073
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1796 2074
 			foreach ($alldata as $number) {
1797 2075
 				$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']);
1798 2076
 			}
1799
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2077
+			if ($globalDebug) {
2078
+				echo 'Count all real arrivals by months by airlines...'."\n";
2079
+			}
1800 2080
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1801 2081
 			foreach ($alldata as $number) {
1802 2082
 				$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']);
1803 2083
 			}
1804
-			if ($globalDebug) echo '...Departure'."\n";
2084
+			if ($globalDebug) {
2085
+				echo '...Departure'."\n";
2086
+			}
1805 2087
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1806 2088
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1807 2089
     			foreach ($dall as $value) {
@@ -1824,7 +2106,9 @@  discard block
 block discarded – undo
1824 2106
 			foreach ($alldata as $number) {
1825 2107
 				$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']);
1826 2108
 			}
1827
-			if ($globalDebug) echo '...Arrival'."\n";
2109
+			if ($globalDebug) {
2110
+				echo '...Arrival'."\n";
2111
+			}
1828 2112
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1829 2113
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1830 2114
     			foreach ($dall as $value) {
@@ -1848,13 +2132,19 @@  discard block
 block discarded – undo
1848 2132
 				$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']);
1849 2133
 			}
1850 2134
 
1851
-			if ($globalDebug) echo 'Flights data...'."\n";
1852
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2135
+			if ($globalDebug) {
2136
+				echo 'Flights data...'."\n";
2137
+			}
2138
+			if ($globalDebug) {
2139
+				echo '-> countAllDatesLastMonth...'."\n";
2140
+			}
1853 2141
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1854 2142
 			foreach ($alldata as $number) {
1855 2143
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1856 2144
 			}
1857
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2145
+			if ($globalDebug) {
2146
+				echo '-> countAllDates...'."\n";
2147
+			}
1858 2148
 			//$previousdata = $this->countAllDatesByAirlines();
1859 2149
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1860 2150
 			$values = array();
@@ -1867,7 +2157,9 @@  discard block
 block discarded – undo
1867 2157
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1868 2158
 			}
1869 2159
 			
1870
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2160
+			if ($globalDebug) {
2161
+				echo '-> countAllHours...'."\n";
2162
+			}
1871 2163
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1872 2164
 			foreach ($alldata as $number) {
1873 2165
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1875,7 +2167,9 @@  discard block
 block discarded – undo
1875 2167
 			
1876 2168
 
1877 2169
 			// Stats by filters
1878
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2170
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2171
+				$globalStatsFilters = array();
2172
+			}
1879 2173
 			foreach ($globalStatsFilters as $name => $filter) {
1880 2174
 				//$filter_name = $filter['name'];
1881 2175
 				$filter_name = $name;
@@ -1883,11 +2177,15 @@  discard block
 block discarded – undo
1883 2177
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1884 2178
 				if (isset($last_update[0]['value'])) {
1885 2179
 					$last_update_day = $last_update[0]['value'];
1886
-				} else $last_update_day = '2012-12-12 12:12:12';
2180
+				} else {
2181
+					$last_update_day = '2012-12-12 12:12:12';
2182
+				}
1887 2183
 				$reset = false;
1888 2184
 
1889 2185
 				// Count by filter
1890
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2186
+				if ($globalDebug) {
2187
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2188
+				}
1891 2189
 				$Spotter = new Spotter($this->db);
1892 2190
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1893 2191
 				foreach ($alldata as $number) {
@@ -1924,7 +2222,9 @@  discard block
 block discarded – undo
1924 2222
 	    				$icao = $value['airport_departure_icao'];
1925 2223
         				if (isset($alldata[$icao])) {
1926 2224
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1927
-        				} else $alldata[$icao] = $value;
2225
+        				} else {
2226
+        					$alldata[$icao] = $value;
2227
+        				}
1928 2228
 				}
1929 2229
 	    			$count = array();
1930 2230
     				foreach ($alldata as $key => $row) {
@@ -1945,7 +2245,9 @@  discard block
 block discarded – undo
1945 2245
 	    				$icao = $value['airport_arrival_icao'];
1946 2246
         				if (isset($alldata[$icao])) {
1947 2247
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1948
-		        		} else $alldata[$icao] = $value;
2248
+		        		} else {
2249
+		        			$alldata[$icao] = $value;
2250
+		        		}
1949 2251
 	    			}
1950 2252
         			$count = array();
1951 2253
         			foreach ($alldata as $key => $row) {
@@ -1959,7 +2261,9 @@  discard block
 block discarded – undo
1959 2261
 				$alldata = $Spotter->countAllMonths($filter);
1960 2262
 				$lastyear = false;
1961 2263
 				foreach ($alldata as $number) {
1962
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2264
+					if ($number['year_name'] != date('Y')) {
2265
+						$lastyear = true;
2266
+					}
1963 2267
 					$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);
1964 2268
 				}
1965 2269
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.
install/class.update_schema.php 3 patches
Indentation   +598 added lines, -598 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);
431 416
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
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
+			$sth->execute();
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 {
@@ -1490,165 +1490,165 @@  discard block
 block discarded – undo
1490 1490
 	}
1491 1491
 
1492 1492
 
1493
-    	public static function check_version($update = false) {
1494
-    	    global $globalDBname;
1495
-    	    $version = 0;
1496
-    	    $Connection = new Connection();
1497
-    	    if ($Connection->tableExists('aircraft')) {
1498
-    		if (!$Connection->tableExists('config')) {
1499
-    		    $version = '1';
1500
-    		    if ($update) return self::update_from_1();
1501
-    		    else return $version;
1493
+		public static function check_version($update = false) {
1494
+			global $globalDBname;
1495
+			$version = 0;
1496
+			$Connection = new Connection();
1497
+			if ($Connection->tableExists('aircraft')) {
1498
+			if (!$Connection->tableExists('config')) {
1499
+				$version = '1';
1500
+				if ($update) return self::update_from_1();
1501
+				else return $version;
1502 1502
 		} else {
1503
-    		    $Connection = new Connection();
1504
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1505
-		    try {
1506
-            		$sth = $Connection->db->prepare($query);
1507
-		        $sth->execute();
1508
-		    } catch(PDOException $e) {
1503
+				$Connection = new Connection();
1504
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1505
+			try {
1506
+					$sth = $Connection->db->prepare($query);
1507
+				$sth->execute();
1508
+			} catch(PDOException $e) {
1509 1509
 			return "error : ".$e->getMessage()."\n";
1510
-    		    }
1511
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
1512
-    		    if ($update) {
1513
-    			if ($result['value'] == '2') {
1514
-    			    $error = self::update_from_2();
1515
-    			    if ($error != '') return $error;
1516
-    			    else return self::check_version(true);
1517
-    			} elseif ($result['value'] == '3') {
1518
-    			    $error = self::update_from_3();
1519
-    			    if ($error != '') return $error;
1520
-    			    else return self::check_version(true);
1521
-    			} elseif ($result['value'] == '4') {
1522
-    			    $error = self::update_from_4();
1523
-    			    if ($error != '') return $error;
1524
-    			    else return self::check_version(true);
1525
-    			} elseif ($result['value'] == '5') {
1526
-    			    $error = self::update_from_5();
1527
-    			    if ($error != '') return $error;
1528
-    			    else return self::check_version(true);
1529
-    			} elseif ($result['value'] == '6') {
1530
-    			    $error = self::update_from_6();
1531
-    			    if ($error != '') return $error;
1532
-    			    else return self::check_version(true);
1533
-    			} elseif ($result['value'] == '7') {
1534
-    			    $error = self::update_from_7();
1535
-    			    if ($error != '') return $error;
1536
-    			    else return self::check_version(true);
1537
-    			} elseif ($result['value'] == '8') {
1538
-    			    $error = self::update_from_8();
1539
-    			    if ($error != '') return $error;
1540
-    			    else return self::check_version(true);
1541
-    			} elseif ($result['value'] == '9') {
1542
-    			    $error = self::update_from_9();
1543
-    			    if ($error != '') return $error;
1544
-    			    else return self::check_version(true);
1545
-    			} elseif ($result['value'] == '10') {
1546
-    			    $error = self::update_from_10();
1547
-    			    if ($error != '') return $error;
1548
-    			    else return self::check_version(true);
1549
-    			} elseif ($result['value'] == '11') {
1550
-    			    $error = self::update_from_11();
1551
-    			    if ($error != '') return $error;
1552
-    			    else return self::check_version(true);
1553
-    			} elseif ($result['value'] == '12') {
1554
-    			    $error = self::update_from_12();
1555
-    			    if ($error != '') return $error;
1556
-    			    else return self::check_version(true);
1557
-    			} elseif ($result['value'] == '13') {
1558
-    			    $error = self::update_from_13();
1559
-    			    if ($error != '') return $error;
1560
-    			    else return self::check_version(true);
1561
-    			} elseif ($result['value'] == '14') {
1562
-    			    $error = self::update_from_14();
1563
-    			    if ($error != '') return $error;
1564
-    			    else return self::check_version(true);
1565
-    			} elseif ($result['value'] == '15') {
1566
-    			    $error = self::update_from_15();
1567
-    			    if ($error != '') return $error;
1568
-    			    else return self::check_version(true);
1569
-    			} elseif ($result['value'] == '16') {
1570
-    			    $error = self::update_from_16();
1571
-    			    if ($error != '') return $error;
1572
-    			    else return self::check_version(true);
1573
-    			} elseif ($result['value'] == '17') {
1574
-    			    $error = self::update_from_17();
1575
-    			    if ($error != '') return $error;
1576
-    			    else return self::check_version(true);
1577
-    			} elseif ($result['value'] == '18') {
1578
-    			    $error = self::update_from_18();
1579
-    			    if ($error != '') return $error;
1580
-    			    else return self::check_version(true);
1581
-    			} elseif ($result['value'] == '19') {
1582
-    			    $error = self::update_from_19();
1583
-    			    if ($error != '') return $error;
1584
-    			    else return self::check_version(true);
1585
-    			} elseif ($result['value'] == '20') {
1586
-    			    $error = self::update_from_20();
1587
-    			    if ($error != '') return $error;
1588
-    			    else return self::check_version(true);
1589
-    			} elseif ($result['value'] == '21') {
1590
-    			    $error = self::update_from_21();
1591
-    			    if ($error != '') return $error;
1592
-    			    else return self::check_version(true);
1593
-    			} elseif ($result['value'] == '22') {
1594
-    			    $error = self::update_from_22();
1595
-    			    if ($error != '') return $error;
1596
-    			    else return self::check_version(true);
1597
-    			} elseif ($result['value'] == '23') {
1598
-    			    $error = self::update_from_23();
1599
-    			    if ($error != '') return $error;
1600
-    			    else return self::check_version(true);
1601
-    			} elseif ($result['value'] == '24') {
1602
-    			    $error = self::update_from_24();
1603
-    			    if ($error != '') return $error;
1604
-    			    else return self::check_version(true);
1605
-    			} elseif ($result['value'] == '25') {
1606
-    			    $error = self::update_from_25();
1607
-    			    if ($error != '') return $error;
1608
-    			    else return self::check_version(true);
1609
-    			} elseif ($result['value'] == '26') {
1610
-    			    $error = self::update_from_26();
1611
-    			    if ($error != '') return $error;
1612
-    			    else return self::check_version(true);
1613
-    			} elseif ($result['value'] == '27') {
1614
-    			    $error = self::update_from_27();
1615
-    			    if ($error != '') return $error;
1616
-    			    else return self::check_version(true);
1617
-    			} elseif ($result['value'] == '28') {
1618
-    			    $error = self::update_from_28();
1619
-    			    if ($error != '') return $error;
1620
-    			    else return self::check_version(true);
1621
-    			} elseif ($result['value'] == '29') {
1622
-    			    $error = self::update_from_29();
1623
-    			    if ($error != '') return $error;
1624
-    			    else return self::check_version(true);
1625
-    			} elseif ($result['value'] == '30') {
1626
-    			    $error = self::update_from_30();
1627
-    			    if ($error != '') return $error;
1628
-    			    else return self::check_version(true);
1629
-    			} elseif ($result['value'] == '31') {
1630
-    			    $error = self::update_from_31();
1631
-    			    if ($error != '') return $error;
1632
-    			    else return self::check_version(true);
1633
-    			} elseif ($result['value'] == '32') {
1634
-    			    $error = self::update_from_32();
1635
-    			    if ($error != '') return $error;
1636
-    			    else return self::check_version(true);
1637
-    			} elseif ($result['value'] == '33') {
1638
-    			    $error = self::update_from_33();
1639
-    			    if ($error != '') return $error;
1640
-    			    else return self::check_version(true);
1641
-    			} elseif ($result['value'] == '34') {
1642
-    			    $error = self::update_from_34();
1643
-    			    if ($error != '') return $error;
1644
-    			    else return self::check_version(true);
1645
-    			} else return '';
1646
-    		    }
1647
-    		    else return $result['value'];
1510
+				}
1511
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
1512
+				if ($update) {
1513
+				if ($result['value'] == '2') {
1514
+					$error = self::update_from_2();
1515
+					if ($error != '') return $error;
1516
+					else return self::check_version(true);
1517
+				} elseif ($result['value'] == '3') {
1518
+					$error = self::update_from_3();
1519
+					if ($error != '') return $error;
1520
+					else return self::check_version(true);
1521
+				} elseif ($result['value'] == '4') {
1522
+					$error = self::update_from_4();
1523
+					if ($error != '') return $error;
1524
+					else return self::check_version(true);
1525
+				} elseif ($result['value'] == '5') {
1526
+					$error = self::update_from_5();
1527
+					if ($error != '') return $error;
1528
+					else return self::check_version(true);
1529
+				} elseif ($result['value'] == '6') {
1530
+					$error = self::update_from_6();
1531
+					if ($error != '') return $error;
1532
+					else return self::check_version(true);
1533
+				} elseif ($result['value'] == '7') {
1534
+					$error = self::update_from_7();
1535
+					if ($error != '') return $error;
1536
+					else return self::check_version(true);
1537
+				} elseif ($result['value'] == '8') {
1538
+					$error = self::update_from_8();
1539
+					if ($error != '') return $error;
1540
+					else return self::check_version(true);
1541
+				} elseif ($result['value'] == '9') {
1542
+					$error = self::update_from_9();
1543
+					if ($error != '') return $error;
1544
+					else return self::check_version(true);
1545
+				} elseif ($result['value'] == '10') {
1546
+					$error = self::update_from_10();
1547
+					if ($error != '') return $error;
1548
+					else return self::check_version(true);
1549
+				} elseif ($result['value'] == '11') {
1550
+					$error = self::update_from_11();
1551
+					if ($error != '') return $error;
1552
+					else return self::check_version(true);
1553
+				} elseif ($result['value'] == '12') {
1554
+					$error = self::update_from_12();
1555
+					if ($error != '') return $error;
1556
+					else return self::check_version(true);
1557
+				} elseif ($result['value'] == '13') {
1558
+					$error = self::update_from_13();
1559
+					if ($error != '') return $error;
1560
+					else return self::check_version(true);
1561
+				} elseif ($result['value'] == '14') {
1562
+					$error = self::update_from_14();
1563
+					if ($error != '') return $error;
1564
+					else return self::check_version(true);
1565
+				} elseif ($result['value'] == '15') {
1566
+					$error = self::update_from_15();
1567
+					if ($error != '') return $error;
1568
+					else return self::check_version(true);
1569
+				} elseif ($result['value'] == '16') {
1570
+					$error = self::update_from_16();
1571
+					if ($error != '') return $error;
1572
+					else return self::check_version(true);
1573
+				} elseif ($result['value'] == '17') {
1574
+					$error = self::update_from_17();
1575
+					if ($error != '') return $error;
1576
+					else return self::check_version(true);
1577
+				} elseif ($result['value'] == '18') {
1578
+					$error = self::update_from_18();
1579
+					if ($error != '') return $error;
1580
+					else return self::check_version(true);
1581
+				} elseif ($result['value'] == '19') {
1582
+					$error = self::update_from_19();
1583
+					if ($error != '') return $error;
1584
+					else return self::check_version(true);
1585
+				} elseif ($result['value'] == '20') {
1586
+					$error = self::update_from_20();
1587
+					if ($error != '') return $error;
1588
+					else return self::check_version(true);
1589
+				} elseif ($result['value'] == '21') {
1590
+					$error = self::update_from_21();
1591
+					if ($error != '') return $error;
1592
+					else return self::check_version(true);
1593
+				} elseif ($result['value'] == '22') {
1594
+					$error = self::update_from_22();
1595
+					if ($error != '') return $error;
1596
+					else return self::check_version(true);
1597
+				} elseif ($result['value'] == '23') {
1598
+					$error = self::update_from_23();
1599
+					if ($error != '') return $error;
1600
+					else return self::check_version(true);
1601
+				} elseif ($result['value'] == '24') {
1602
+					$error = self::update_from_24();
1603
+					if ($error != '') return $error;
1604
+					else return self::check_version(true);
1605
+				} elseif ($result['value'] == '25') {
1606
+					$error = self::update_from_25();
1607
+					if ($error != '') return $error;
1608
+					else return self::check_version(true);
1609
+				} elseif ($result['value'] == '26') {
1610
+					$error = self::update_from_26();
1611
+					if ($error != '') return $error;
1612
+					else return self::check_version(true);
1613
+				} elseif ($result['value'] == '27') {
1614
+					$error = self::update_from_27();
1615
+					if ($error != '') return $error;
1616
+					else return self::check_version(true);
1617
+				} elseif ($result['value'] == '28') {
1618
+					$error = self::update_from_28();
1619
+					if ($error != '') return $error;
1620
+					else return self::check_version(true);
1621
+				} elseif ($result['value'] == '29') {
1622
+					$error = self::update_from_29();
1623
+					if ($error != '') return $error;
1624
+					else return self::check_version(true);
1625
+				} elseif ($result['value'] == '30') {
1626
+					$error = self::update_from_30();
1627
+					if ($error != '') return $error;
1628
+					else return self::check_version(true);
1629
+				} elseif ($result['value'] == '31') {
1630
+					$error = self::update_from_31();
1631
+					if ($error != '') return $error;
1632
+					else return self::check_version(true);
1633
+				} elseif ($result['value'] == '32') {
1634
+					$error = self::update_from_32();
1635
+					if ($error != '') return $error;
1636
+					else return self::check_version(true);
1637
+				} elseif ($result['value'] == '33') {
1638
+					$error = self::update_from_33();
1639
+					if ($error != '') return $error;
1640
+					else return self::check_version(true);
1641
+				} elseif ($result['value'] == '34') {
1642
+					$error = self::update_from_34();
1643
+					if ($error != '') return $error;
1644
+					else return self::check_version(true);
1645
+				} else return '';
1646
+				}
1647
+				else return $result['value'];
1648 1648
 		}
1649 1649
 		
1650
-	    } else return $version;
1651
-    	}
1650
+		} else return $version;
1651
+		}
1652 1652
     	
1653 1653
 }
1654 1654
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
Spacing   +173 added lines, -173 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,12 +1388,12 @@  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 MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
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 (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1398 1398
 				}
1399 1399
 				
@@ -1401,19 +1401,19 @@  discard block
 block discarded – undo
1401 1401
 				try {
1402 1402
 					$sth = $Connection->db->prepare($query);
1403 1403
 					$sth->execute();
1404
-				} catch(PDOException $e) {
1404
+				} catch (PDOException $e) {
1405 1405
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1406 1406
 				}
1407 1407
 				$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 50";
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 (get date diff from spotter_output) : ".$e->getMessage()."\n";
1413 1413
 				}
1414 1414
 				$stats = array();
1415
-				while($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1416
-					$hours = gmdate('H',strtotime($row['last_seen']) - strtotime($row['date']));
1415
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1416
+					$hours = gmdate('H', strtotime($row['last_seen']) - strtotime($row['date']));
1417 1417
 					if (isset($stats[$hours])) $stats[$hours] = $stats[$hours] + 1;
1418 1418
 					else $stats[$hours] = 1;
1419 1419
 				}
@@ -1428,14 +1428,14 @@  discard block
 block discarded – undo
1428 1428
 						try {
1429 1429
 							$sth = $Connection->db->prepare($query);
1430 1430
 							$sth->execute();
1431
-						} catch(PDOException $e) {
1431
+						} catch (PDOException $e) {
1432 1432
 							return "error (fix date) : ".$e->getMessage()."\n";
1433 1433
 						}
1434 1434
 						try {
1435 1435
 							$sth_chk = $Connection->db->prepare($query_chk);
1436 1436
 							$sth_chk->execute();
1437 1437
 							$result = $sth_chk->fetchAll(PDO::FETCH_ASSOC);
1438
-						} catch(PDOException $e) {
1438
+						} catch (PDOException $e) {
1439 1439
 							return "error (fix date chk) : ".$e->getMessage()."\n";
1440 1440
 						}
1441 1441
 						$i = $result[0]['nb'];
@@ -1443,31 +1443,31 @@  discard block
 block discarded – undo
1443 1443
 					}
1444 1444
 				}
1445 1445
 			}
1446
-			if ($Connection->getColumnType('spotter_archive_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_archive_output','last_seen') != 'TIMESTAMP') {
1446
+			if ($Connection->getColumnType('spotter_archive_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_archive_output', 'last_seen') != 'TIMESTAMP') {
1447 1447
 				$query = "ALTER TABLE spotter_archive_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1448 1448
 				try {
1449 1449
 					$sth = $Connection->db->prepare($query);
1450 1450
 					$sth->execute();
1451
-				} catch(PDOException $e) {
1451
+				} catch (PDOException $e) {
1452 1452
 					return "error (convert spotter_archive_output last_seen to timestamp) : ".$e->getMessage()."\n";
1453 1453
 				}
1454 1454
 				$query = "ALTER TABLE spotter_archive_output ALTER COLUMN last_seen DROP DEFAULT";
1455 1455
 				try {
1456 1456
 					$sth = $Connection->db->prepare($query);
1457 1457
 					$sth->execute();
1458
-				} catch(PDOException $e) {
1458
+				} catch (PDOException $e) {
1459 1459
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1460 1460
 				}
1461 1461
 				$query = "SELECT date,last_seen FROM spotter_archive_output WHERE last_seen < date ORDER BY date DESC LIMIT 50";
1462 1462
 				try {
1463 1463
 					$sth = $Connection->db->prepare($query);
1464 1464
 					$sth->execute();
1465
-				} catch(PDOException $e) {
1465
+				} catch (PDOException $e) {
1466 1466
 					return "error (get diff from spotter_archive_output) : ".$e->getMessage()."\n";
1467 1467
 				}
1468 1468
 				$stats = array();
1469
-				while($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1470
-					$hours = gmdate('H',strtotime($row['last_seen']) - strtotime($row['date']));
1469
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1470
+					$hours = gmdate('H', strtotime($row['last_seen']) - strtotime($row['date']));
1471 1471
 					if (isset($stats[$hours])) $stats[$hours] = $stats[$hours] + 1;
1472 1472
 					else $stats[$hours] = 1;
1473 1473
 				}
@@ -1482,14 +1482,14 @@  discard block
 block discarded – undo
1482 1482
 						try {
1483 1483
 							$sth = $Connection->db->prepare($query);
1484 1484
 							$sth->execute();
1485
-						} catch(PDOException $e) {
1485
+						} catch (PDOException $e) {
1486 1486
 							return "error (fix date) : ".$e->getMessage()."\n";
1487 1487
 						}
1488 1488
 						try {
1489 1489
 							$sth_chk = $Connection->db->prepare($query_chk);
1490 1490
 							$sth_chk->execute();
1491 1491
 							$result = $sth_chk->fetchAll(PDO::FETCH_ASSOC);
1492
-						} catch(PDOException $e) {
1492
+						} catch (PDOException $e) {
1493 1493
 							return "error (fix date chk) : ".$e->getMessage()."\n";
1494 1494
 						}
1495 1495
 						$i = $result[0]['nb'];
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
 		try {
1503 1503
 			$sth = $Connection->db->prepare($query);
1504 1504
 			$sth->execute();
1505
-		} catch(PDOException $e) {
1505
+		} catch (PDOException $e) {
1506 1506
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1507 1507
 		}
1508 1508
 		return $error;
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
 		    try {
1525 1525
             		$sth = $Connection->db->prepare($query);
1526 1526
 		        $sth->execute();
1527
-		    } catch(PDOException $e) {
1527
+		    } catch (PDOException $e) {
1528 1528
 			return "error : ".$e->getMessage()."\n";
1529 1529
     		    }
1530 1530
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +287 added lines, -108 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
 
@@ -1414,8 +1480,11 @@  discard block
 block discarded – undo
1414 1480
 				$stats = array();
1415 1481
 				while($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1416 1482
 					$hours = gmdate('H',strtotime($row['last_seen']) - strtotime($row['date']));
1417
-					if (isset($stats[$hours])) $stats[$hours] = $stats[$hours] + 1;
1418
-					else $stats[$hours] = 1;
1483
+					if (isset($stats[$hours])) {
1484
+						$stats[$hours] = $stats[$hours] + 1;
1485
+					} else {
1486
+						$stats[$hours] = 1;
1487
+					}
1419 1488
 				}
1420 1489
 				if (!empty($stats)) {
1421 1490
 					asort($stats);
@@ -1468,8 +1537,11 @@  discard block
 block discarded – undo
1468 1537
 				$stats = array();
1469 1538
 				while($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1470 1539
 					$hours = gmdate('H',strtotime($row['last_seen']) - strtotime($row['date']));
1471
-					if (isset($stats[$hours])) $stats[$hours] = $stats[$hours] + 1;
1472
-					else $stats[$hours] = 1;
1540
+					if (isset($stats[$hours])) {
1541
+						$stats[$hours] = $stats[$hours] + 1;
1542
+					} else {
1543
+						$stats[$hours] = 1;
1544
+					}
1473 1545
 				}
1474 1546
 				if (!empty($stats)) {
1475 1547
 					asort($stats);
@@ -1516,8 +1588,11 @@  discard block
 block discarded – undo
1516 1588
     	    if ($Connection->tableExists('aircraft')) {
1517 1589
     		if (!$Connection->tableExists('config')) {
1518 1590
     		    $version = '1';
1519
-    		    if ($update) return self::update_from_1();
1520
-    		    else return $version;
1591
+    		    if ($update) {
1592
+    		    	return self::update_from_1();
1593
+    		    } else {
1594
+    		    	return $version;
1595
+    		    }
1521 1596
 		} else {
1522 1597
     		    $Connection = new Connection();
1523 1598
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1531,142 +1606,246 @@  discard block
 block discarded – undo
1531 1606
     		    if ($update) {
1532 1607
     			if ($result['value'] == '2') {
1533 1608
     			    $error = self::update_from_2();
1534
-    			    if ($error != '') return $error;
1535
-    			    else return self::check_version(true);
1609
+    			    if ($error != '') {
1610
+    			    	return $error;
1611
+    			    } else {
1612
+    			    	return self::check_version(true);
1613
+    			    }
1536 1614
     			} elseif ($result['value'] == '3') {
1537 1615
     			    $error = self::update_from_3();
1538
-    			    if ($error != '') return $error;
1539
-    			    else return self::check_version(true);
1616
+    			    if ($error != '') {
1617
+    			    	return $error;
1618
+    			    } else {
1619
+    			    	return self::check_version(true);
1620
+    			    }
1540 1621
     			} elseif ($result['value'] == '4') {
1541 1622
     			    $error = self::update_from_4();
1542
-    			    if ($error != '') return $error;
1543
-    			    else return self::check_version(true);
1623
+    			    if ($error != '') {
1624
+    			    	return $error;
1625
+    			    } else {
1626
+    			    	return self::check_version(true);
1627
+    			    }
1544 1628
     			} elseif ($result['value'] == '5') {
1545 1629
     			    $error = self::update_from_5();
1546
-    			    if ($error != '') return $error;
1547
-    			    else return self::check_version(true);
1630
+    			    if ($error != '') {
1631
+    			    	return $error;
1632
+    			    } else {
1633
+    			    	return self::check_version(true);
1634
+    			    }
1548 1635
     			} elseif ($result['value'] == '6') {
1549 1636
     			    $error = self::update_from_6();
1550
-    			    if ($error != '') return $error;
1551
-    			    else return self::check_version(true);
1637
+    			    if ($error != '') {
1638
+    			    	return $error;
1639
+    			    } else {
1640
+    			    	return self::check_version(true);
1641
+    			    }
1552 1642
     			} elseif ($result['value'] == '7') {
1553 1643
     			    $error = self::update_from_7();
1554
-    			    if ($error != '') return $error;
1555
-    			    else return self::check_version(true);
1644
+    			    if ($error != '') {
1645
+    			    	return $error;
1646
+    			    } else {
1647
+    			    	return self::check_version(true);
1648
+    			    }
1556 1649
     			} elseif ($result['value'] == '8') {
1557 1650
     			    $error = self::update_from_8();
1558
-    			    if ($error != '') return $error;
1559
-    			    else return self::check_version(true);
1651
+    			    if ($error != '') {
1652
+    			    	return $error;
1653
+    			    } else {
1654
+    			    	return self::check_version(true);
1655
+    			    }
1560 1656
     			} elseif ($result['value'] == '9') {
1561 1657
     			    $error = self::update_from_9();
1562
-    			    if ($error != '') return $error;
1563
-    			    else return self::check_version(true);
1658
+    			    if ($error != '') {
1659
+    			    	return $error;
1660
+    			    } else {
1661
+    			    	return self::check_version(true);
1662
+    			    }
1564 1663
     			} elseif ($result['value'] == '10') {
1565 1664
     			    $error = self::update_from_10();
1566
-    			    if ($error != '') return $error;
1567
-    			    else return self::check_version(true);
1665
+    			    if ($error != '') {
1666
+    			    	return $error;
1667
+    			    } else {
1668
+    			    	return self::check_version(true);
1669
+    			    }
1568 1670
     			} elseif ($result['value'] == '11') {
1569 1671
     			    $error = self::update_from_11();
1570
-    			    if ($error != '') return $error;
1571
-    			    else return self::check_version(true);
1672
+    			    if ($error != '') {
1673
+    			    	return $error;
1674
+    			    } else {
1675
+    			    	return self::check_version(true);
1676
+    			    }
1572 1677
     			} elseif ($result['value'] == '12') {
1573 1678
     			    $error = self::update_from_12();
1574
-    			    if ($error != '') return $error;
1575
-    			    else return self::check_version(true);
1679
+    			    if ($error != '') {
1680
+    			    	return $error;
1681
+    			    } else {
1682
+    			    	return self::check_version(true);
1683
+    			    }
1576 1684
     			} elseif ($result['value'] == '13') {
1577 1685
     			    $error = self::update_from_13();
1578
-    			    if ($error != '') return $error;
1579
-    			    else return self::check_version(true);
1686
+    			    if ($error != '') {
1687
+    			    	return $error;
1688
+    			    } else {
1689
+    			    	return self::check_version(true);
1690
+    			    }
1580 1691
     			} elseif ($result['value'] == '14') {
1581 1692
     			    $error = self::update_from_14();
1582
-    			    if ($error != '') return $error;
1583
-    			    else return self::check_version(true);
1693
+    			    if ($error != '') {
1694
+    			    	return $error;
1695
+    			    } else {
1696
+    			    	return self::check_version(true);
1697
+    			    }
1584 1698
     			} elseif ($result['value'] == '15') {
1585 1699
     			    $error = self::update_from_15();
1586
-    			    if ($error != '') return $error;
1587
-    			    else return self::check_version(true);
1700
+    			    if ($error != '') {
1701
+    			    	return $error;
1702
+    			    } else {
1703
+    			    	return self::check_version(true);
1704
+    			    }
1588 1705
     			} elseif ($result['value'] == '16') {
1589 1706
     			    $error = self::update_from_16();
1590
-    			    if ($error != '') return $error;
1591
-    			    else return self::check_version(true);
1707
+    			    if ($error != '') {
1708
+    			    	return $error;
1709
+    			    } else {
1710
+    			    	return self::check_version(true);
1711
+    			    }
1592 1712
     			} elseif ($result['value'] == '17') {
1593 1713
     			    $error = self::update_from_17();
1594
-    			    if ($error != '') return $error;
1595
-    			    else return self::check_version(true);
1714
+    			    if ($error != '') {
1715
+    			    	return $error;
1716
+    			    } else {
1717
+    			    	return self::check_version(true);
1718
+    			    }
1596 1719
     			} elseif ($result['value'] == '18') {
1597 1720
     			    $error = self::update_from_18();
1598
-    			    if ($error != '') return $error;
1599
-    			    else return self::check_version(true);
1721
+    			    if ($error != '') {
1722
+    			    	return $error;
1723
+    			    } else {
1724
+    			    	return self::check_version(true);
1725
+    			    }
1600 1726
     			} elseif ($result['value'] == '19') {
1601 1727
     			    $error = self::update_from_19();
1602
-    			    if ($error != '') return $error;
1603
-    			    else return self::check_version(true);
1728
+    			    if ($error != '') {
1729
+    			    	return $error;
1730
+    			    } else {
1731
+    			    	return self::check_version(true);
1732
+    			    }
1604 1733
     			} elseif ($result['value'] == '20') {
1605 1734
     			    $error = self::update_from_20();
1606
-    			    if ($error != '') return $error;
1607
-    			    else return self::check_version(true);
1735
+    			    if ($error != '') {
1736
+    			    	return $error;
1737
+    			    } else {
1738
+    			    	return self::check_version(true);
1739
+    			    }
1608 1740
     			} elseif ($result['value'] == '21') {
1609 1741
     			    $error = self::update_from_21();
1610
-    			    if ($error != '') return $error;
1611
-    			    else return self::check_version(true);
1742
+    			    if ($error != '') {
1743
+    			    	return $error;
1744
+    			    } else {
1745
+    			    	return self::check_version(true);
1746
+    			    }
1612 1747
     			} elseif ($result['value'] == '22') {
1613 1748
     			    $error = self::update_from_22();
1614
-    			    if ($error != '') return $error;
1615
-    			    else return self::check_version(true);
1749
+    			    if ($error != '') {
1750
+    			    	return $error;
1751
+    			    } else {
1752
+    			    	return self::check_version(true);
1753
+    			    }
1616 1754
     			} elseif ($result['value'] == '23') {
1617 1755
     			    $error = self::update_from_23();
1618
-    			    if ($error != '') return $error;
1619
-    			    else return self::check_version(true);
1756
+    			    if ($error != '') {
1757
+    			    	return $error;
1758
+    			    } else {
1759
+    			    	return self::check_version(true);
1760
+    			    }
1620 1761
     			} elseif ($result['value'] == '24') {
1621 1762
     			    $error = self::update_from_24();
1622
-    			    if ($error != '') return $error;
1623
-    			    else return self::check_version(true);
1763
+    			    if ($error != '') {
1764
+    			    	return $error;
1765
+    			    } else {
1766
+    			    	return self::check_version(true);
1767
+    			    }
1624 1768
     			} elseif ($result['value'] == '25') {
1625 1769
     			    $error = self::update_from_25();
1626
-    			    if ($error != '') return $error;
1627
-    			    else return self::check_version(true);
1770
+    			    if ($error != '') {
1771
+    			    	return $error;
1772
+    			    } else {
1773
+    			    	return self::check_version(true);
1774
+    			    }
1628 1775
     			} elseif ($result['value'] == '26') {
1629 1776
     			    $error = self::update_from_26();
1630
-    			    if ($error != '') return $error;
1631
-    			    else return self::check_version(true);
1777
+    			    if ($error != '') {
1778
+    			    	return $error;
1779
+    			    } else {
1780
+    			    	return self::check_version(true);
1781
+    			    }
1632 1782
     			} elseif ($result['value'] == '27') {
1633 1783
     			    $error = self::update_from_27();
1634
-    			    if ($error != '') return $error;
1635
-    			    else return self::check_version(true);
1784
+    			    if ($error != '') {
1785
+    			    	return $error;
1786
+    			    } else {
1787
+    			    	return self::check_version(true);
1788
+    			    }
1636 1789
     			} elseif ($result['value'] == '28') {
1637 1790
     			    $error = self::update_from_28();
1638
-    			    if ($error != '') return $error;
1639
-    			    else return self::check_version(true);
1791
+    			    if ($error != '') {
1792
+    			    	return $error;
1793
+    			    } else {
1794
+    			    	return self::check_version(true);
1795
+    			    }
1640 1796
     			} elseif ($result['value'] == '29') {
1641 1797
     			    $error = self::update_from_29();
1642
-    			    if ($error != '') return $error;
1643
-    			    else return self::check_version(true);
1798
+    			    if ($error != '') {
1799
+    			    	return $error;
1800
+    			    } else {
1801
+    			    	return self::check_version(true);
1802
+    			    }
1644 1803
     			} elseif ($result['value'] == '30') {
1645 1804
     			    $error = self::update_from_30();
1646
-    			    if ($error != '') return $error;
1647
-    			    else return self::check_version(true);
1805
+    			    if ($error != '') {
1806
+    			    	return $error;
1807
+    			    } else {
1808
+    			    	return self::check_version(true);
1809
+    			    }
1648 1810
     			} elseif ($result['value'] == '31') {
1649 1811
     			    $error = self::update_from_31();
1650
-    			    if ($error != '') return $error;
1651
-    			    else return self::check_version(true);
1812
+    			    if ($error != '') {
1813
+    			    	return $error;
1814
+    			    } else {
1815
+    			    	return self::check_version(true);
1816
+    			    }
1652 1817
     			} elseif ($result['value'] == '32') {
1653 1818
     			    $error = self::update_from_32();
1654
-    			    if ($error != '') return $error;
1655
-    			    else return self::check_version(true);
1819
+    			    if ($error != '') {
1820
+    			    	return $error;
1821
+    			    } else {
1822
+    			    	return self::check_version(true);
1823
+    			    }
1656 1824
     			} elseif ($result['value'] == '33') {
1657 1825
     			    $error = self::update_from_33();
1658
-    			    if ($error != '') return $error;
1659
-    			    else return self::check_version(true);
1826
+    			    if ($error != '') {
1827
+    			    	return $error;
1828
+    			    } else {
1829
+    			    	return self::check_version(true);
1830
+    			    }
1660 1831
     			} elseif ($result['value'] == '34') {
1661 1832
     			    $error = self::update_from_34();
1662
-    			    if ($error != '') return $error;
1663
-    			    else return self::check_version(true);
1664
-    			} else return '';
1833
+    			    if ($error != '') {
1834
+    			    	return $error;
1835
+    			    } else {
1836
+    			    	return self::check_version(true);
1837
+    			    }
1838
+    			} else {
1839
+    				return '';
1840
+    			}
1841
+    		    } else {
1842
+    		    	return $result['value'];
1665 1843
     		    }
1666
-    		    else return $result['value'];
1667 1844
 		}
1668 1845
 		
1669
-	    } else return $version;
1846
+	    } else {
1847
+	    	return $version;
1848
+	    }
1670 1849
     	}
1671 1850
     	
1672 1851
 }
Please login to merge, or discard this patch.