Completed
Push — master ( a3214e...3969e1 )
by Yannick
111:17 queued 84:43
created
statistics-sub-menu.php 1 patch
Braces   +110 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,7 +6,13 @@  discard block
 block discarded – undo
6 6
 	if (!isset($type) || $type != 'satellite') {
7 7
 ?>
8 8
 		<form id="changedate" method="post">
9
-			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') echo $year.'-'; ?><?php if (isset($month) && $month != '') echo $month; ?>" />
9
+			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') {
10
+	echo $year.'-';
11
+}
12
+?><?php if (isset($month) && $month != '') {
13
+	echo $month;
14
+}
15
+?>" />
10 16
 		</form>
11 17
 <?php
12 18
 	}
@@ -38,7 +44,9 @@  discard block
 block discarded – undo
38 44
 						print '<option disabled>──────────</option>';
39 45
 					}
40 46
 					$Stats = new Stats();
41
-					if (!isset($filter_name)) $filter_name = '';
47
+					if (!isset($filter_name)) {
48
+						$filter_name = '';
49
+					}
42 50
 					$airlines = $Stats->getAllAirlineNames($filter_name);
43 51
 					foreach($airlines as $airline) {
44 52
 						if (isset($airline_icao) && $airline_icao == $airline['airline_icao']) {
@@ -67,10 +75,22 @@  discard block
 block discarded – undo
67 75
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
68 76
 		    </a>
69 77
 		    <ul class="dropdown-menu">
70
-			<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>
71
-			<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>
72
-			<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>
73
-			<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>
78
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
79
+	echo '/'.$airline_icao;
80
+}
81
+?>"><?php echo _("Aircraft"); ?></a></li>
82
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
83
+	echo '/'.$airline_icao;
84
+}
85
+?>"><?php echo _("Registration"); ?></a></li>
86
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
87
+	echo '/'.$airline_icao;
88
+}
89
+?>"><?php echo _("Manufacturer"); ?></a></li>
90
+			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
91
+	echo '/'.$airline_icao;
92
+}
93
+?>"><?php echo _("Country"); ?></a></li>
74 94
 		    </ul>
75 95
 		</li>
76 96
 		<li class="dropdown">
@@ -81,12 +101,21 @@  discard block
 block discarded – undo
81 101
 <?php
82 102
 		if (!isset($airline_icao) || $airline_icao == 'all') {
83 103
 ?>
84
-		      <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>
85
-		      <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>
104
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
105
+	echo '/'.$airline_icao;
106
+}
107
+?>"><?php echo _("Airline"); ?></a></li>
108
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
109
+	echo '/'.$airline_icao;
110
+}
111
+?>"><?php echo _("Airline by Country"); ?></a></li>
86 112
 <?php
87 113
 		}
88 114
 ?>
89
-		      <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>
115
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
116
+	echo '/'.$airline_icao;
117
+}
118
+?>"><?php echo _("Callsign"); ?></a></li>
90 119
 		    </ul>
91 120
 		</li>
92 121
 		<li class="dropdown">
@@ -94,10 +123,22 @@  discard block
 block discarded – undo
94 123
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
95 124
 		    </a>
96 125
 		    <ul class="dropdown-menu" role="menu">
97
-		      <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>
98
-		      <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>
99
-		      <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>
100
-		      <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>
126
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
127
+	echo '/'.$airline_icao;
128
+}
129
+?>"><?php echo _("Departure Airport"); ?></a></li>
130
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
131
+	echo '/'.$airline_icao;
132
+}
133
+?>"><?php echo _("Departure Airport by Country"); ?></a></li>
134
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
135
+	echo '/'.$airline_icao;
136
+}
137
+?>"><?php echo _("Arrival Airport"); ?></a></li>
138
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
139
+	echo '/'.$airline_icao;
140
+}
141
+?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
101 142
 		    </ul>
102 143
 		</li>
103 144
 		<li class="dropdown">
@@ -105,8 +146,14 @@  discard block
 block discarded – undo
105 146
 		      <?php echo _("Route"); ?> <span class="caret"></span>
106 147
 		    </a>
107 148
 		    <ul class="dropdown-menu" role="menu">
108
-		      <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>
109
-		      <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>
149
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
150
+	echo '/'.$airline_icao;
151
+}
152
+?>"><?php echo _("Route by Airport"); ?></a></li>
153
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
154
+	echo '/'.$airline_icao;
155
+}
156
+?>"><?php echo _("Route by Waypoint"); ?></a></li>
110 157
 		    </ul>
111 158
 		</li>
112 159
 		<li class="dropdown">
@@ -114,8 +161,14 @@  discard block
 block discarded – undo
114 161
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
115 162
 		    </a>
116 163
 		    <ul class="dropdown-menu" role="menu">
117
-		      <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>
118
-			  <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>
164
+		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
165
+	echo '/'.$airline_icao;
166
+}
167
+?>"><?php echo _("Date"); ?></a></li>
168
+			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
169
+	echo '/'.$airline_icao;
170
+}
171
+?>"><?php echo _("Time"); ?></a></li>
119 172
 		    </ul>
120 173
 		</li>
121 174
 		<?php
@@ -163,9 +216,18 @@  discard block
 block discarded – undo
163 216
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
164 217
 		    </a>
165 218
 		    <ul class="dropdown-menu">
166
-			<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>
167
-			<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>
168
-			<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>
219
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
220
+	echo '/'.$airline_icao;
221
+}
222
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
223
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
224
+	echo '/'.$airline_icao;
225
+}
226
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
227
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
228
+	echo '/'.$airline_icao;
229
+}
230
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
169 231
 			<!-- <li><a href="<?php print $globalURL; ?>/statistics/country"><?php echo _("Country"); ?></a></li> -->
170 232
 		    </ul>
171 233
 		</li>
@@ -177,12 +239,21 @@  discard block
 block discarded – undo
177 239
 <?php
178 240
 		if (!isset($airline_icao) || $airline_icao == 'all') {
179 241
 ?>
180
-		      <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>
181
-		      <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>
242
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
243
+	echo '/'.$airline_icao;
244
+}
245
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
246
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
247
+	echo '/'.$airline_icao;
248
+}
249
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
182 250
 <?php
183 251
 		}
184 252
 ?>
185
-		      <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>
253
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
254
+	echo '/'.$airline_icao;
255
+}
256
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
186 257
 		    </ul>
187 258
 		</li>
188 259
 		<li class="dropdown">
@@ -190,10 +261,22 @@  discard block
 block discarded – undo
190 261
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
191 262
 		    </a>
192 263
 		    <ul class="dropdown-menu" role="menu">
193
-		      <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>
194
-		      <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>
195
-		      <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>
196
-		      <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>
264
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
265
+	echo '/'.$airline_icao;
266
+}
267
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
268
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
269
+	echo '/'.$airline_icao;
270
+}
271
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
272
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
273
+	echo '/'.$airline_icao;
274
+}
275
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
276
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
277
+	echo '/'.$airline_icao;
278
+}
279
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
197 280
 		    </ul>
198 281
 		</li>
199 282
 		<!--
Please login to merge, or discard this patch.
js/map-aircraft.3d.js.php 1 patch
Braces   +24 added lines, -4 removed lines patch added patch discarded remove patch
@@ -257,7 +257,12 @@  discard block
 block discarded – undo
257 257
 //				viewer.dataSources.get(dsn).entities.remove(entity);
258 258
 //			}
259 259
 			//console.log(entity.lastupdate);
260
-			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
260
+			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
261
+	print $globalMapRefresh*2000;
262
+} else {
263
+	print '60000';
264
+}
265
+?>)) {
261 266
 //				console.log('Remove an entity date');
262 267
 				viewer.dataSources.get(dsn).entities.remove(entity);
263 268
 			} else {
@@ -544,7 +549,12 @@  discard block
 block discarded – undo
544 549
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
545 550
 ?>
546 551
 update_polarLayer();
547
-setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
552
+setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) {
553
+	print $globalMapRefresh*1000*2;
554
+} else {
555
+	print '60000';
556
+}
557
+?>);
548 558
 <?php
549 559
 		}
550 560
 ?>
@@ -642,7 +652,12 @@  discard block
 block discarded – undo
642 652
 				}
643 653
 			}
644 654
 		}
645
-	,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
655
+	,<?php if (isset($globalMapRefresh)) {
656
+	print $globalMapRefresh*1000;
657
+} else {
658
+	print '30000';
659
+}
660
+?>);
646 661
 } else {
647 662
 	//var widget = new Cesium.CesiumWidget('archivebox');
648 663
 //	var timeline = new Cesium.Timeline(viewer);
@@ -661,7 +676,12 @@  discard block
 block discarded – undo
661 676
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
662 677
 ?>
663 678
 update_atcLayer();
664
-setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
679
+setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) {
680
+	print $globalMapRefresh*1000*2;
681
+} else {
682
+	print '60000';
683
+}
684
+?>);
665 685
 <?php
666 686
     }
667 687
 ?>
Please login to merge, or discard this patch.
js/map-satellite.3d.js.php 1 patch
Braces   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,12 @@
 block discarded – undo
52 52
 	} else {
53 53
 		for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) {
54 54
 			var entity = viewer.dataSources.get(dsn).entities.values[i];
55
-			if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
55
+			if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
56
+	print $globalMapRefresh*2000;
57
+} else {
58
+	print '60000';
59
+}
60
+?>)) {
56 61
 				viewer.dataSources.get(dsn).entities.remove(entity);
57 62
 			}
58 63
 		}
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +506 added lines, -136 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
236 284
 			</div>
@@ -238,7 +286,10 @@  discard block
 block discarded – undo
238 286
 			<div id="openweathermap_data">
239 287
 				<p>
240 288
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
241
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
289
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
290
+	print $globalOpenWeatherMapKey;
291
+}
292
+?>" />
242 293
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
243 294
 				</p>
244 295
 			</div>
@@ -248,42 +299,86 @@  discard block
 block discarded – undo
248 299
 			<legend>Coverage area</legend>
249 300
 			<p>
250 301
 				<label for="latitudemax">The maximum latitude (north)</label>
251
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
302
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
303
+	print $globalLatitudeMax;
304
+}
305
+?>" />
252 306
 			</p>
253 307
 			<p>
254 308
 				<label for="latitudemin">The minimum latitude (south)</label>
255
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
309
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
310
+	print $globalLatitudeMin;
311
+}
312
+?>" />
256 313
 			</p>
257 314
 			<p>
258 315
 				<label for="longitudemax">The maximum longitude (west)</label>
259
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
316
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
317
+	print $globalLongitudeMax;
318
+}
319
+?>" />
260 320
 			</p>
261 321
 			<p>
262 322
 				<label for="longitudemin">The minimum longitude (east)</label>
263
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
323
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
324
+	print $globalLongitudeMin;
325
+}
326
+?>" />
264 327
 			</p>
265 328
 			<p>
266 329
 				<label for="latitudecenter">The latitude center</label>
267
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
330
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
331
+	print $globalCenterLatitude;
332
+}
333
+?>" />
268 334
 			</p>
269 335
 			<p>
270 336
 				<label for="longitudecenter">The longitude center</label>
271
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
337
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
338
+	print $globalCenterLongitude;
339
+}
340
+?>" />
272 341
 			</p>
273 342
 			<p>
274 343
 				<label for="livezoom">Default Zoom on live map</label>
275
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
344
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
345
+	print $globalLiveZoom;
346
+} else {
347
+	print '9';
348
+}
349
+?>" />
276 350
 			</p>
277 351
 			<p>
278 352
 				<label for="squawk_country">Country for squawk usage</label>
279 353
 				<select name="squawk_country" id="squawk_country">
280
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
281
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
282
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
283
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
284
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
285
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
286
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
354
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
355
+	print ' selected ';
356
+}
357
+?>>UK</option>
358
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
359
+	print ' selected ';
360
+}
361
+?>>NZ</option>
362
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
363
+	print ' selected ';
364
+}
365
+?>>US</option>
366
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
367
+	print ' selected ';
368
+}
369
+?>>AU</option>
370
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
371
+	print ' selected ';
372
+}
373
+?>>NL</option>
374
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
375
+	print ' selected ';
376
+}
377
+?>>FR</option>
378
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
379
+	print ' selected ';
380
+}
381
+?>>TR</option>
287 382
 				</select>
288 383
 			</p>
289 384
 		</fieldset>
@@ -292,15 +387,24 @@  discard block
 block discarded – undo
292 387
 			<p><i>Only put in DB flights that are inside a circle</i></p>
293 388
 			<p>
294 389
 				<label for="latitude">Center latitude</label>
295
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
390
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
391
+	echo $globalDistanceIgnore['latitude'];
392
+}
393
+?>" />
296 394
 			</p>
297 395
 			<p>
298 396
 				<label for="longitude">Center longitude</label>
299
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
397
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
398
+	echo $globalDistanceIgnore['longitude'];
399
+}
400
+?>" />
300 401
 			</p>
301 402
 			<p>
302 403
 				<label for="Distance">Distance (in km)</label>
303
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
404
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
405
+	echo $globalDistanceIgnore['distance'];
406
+}
407
+?>" />
304 408
 			</p>
305 409
 		</fieldset>
306 410
 		<fieldset id="sourceloc">
@@ -411,11 +515,17 @@  discard block
 block discarded – undo
411 515
 			<div id="flightaware_data">
412 516
 				<p>
413 517
 					<label for="flightawareusername">FlightAware username</label>
414
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
518
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
519
+	print $globalFlightAwareUsername;
520
+}
521
+?>" />
415 522
 				</p>
416 523
 				<p>
417 524
 					<label for="flightawarepassword">FlightAware password/API key</label>
418
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
525
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
526
+	print $globalFlightAwarePassword;
527
+}
528
+?>" />
419 529
 				</p>
420 530
 			</div>
421 531
 -->
@@ -457,7 +567,10 @@  discard block
 block discarded – undo
457 567
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
458 568
 								?>
459 569
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
460
-								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
570
+								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
571
+	print $source['port'];
572
+}
573
+?>" /></td>
461 574
 								<?php
462 575
 								    } else {
463 576
 									$hostport = explode(':',$source['host']);
@@ -476,33 +589,102 @@  discard block
 block discarded – undo
476 589
 								?>
477 590
 								<td>
478 591
 									<select name="format[]" id="format">
479
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
480
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
481
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
482
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
483
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
484
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
485
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
486
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
487
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
488
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
489
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
490
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
491
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
492
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
493
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
494
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
495
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
496
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
497
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
498
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
592
+										<option value="auto" <?php if (!isset($source['format'])) {
593
+	print 'selected';
594
+}
595
+?>>Auto</option>
596
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
597
+	print 'selected';
598
+}
599
+?>>SBS</option>
600
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
601
+	print 'selected';
602
+}
603
+?>>TSV</option>
604
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
605
+	print 'selected';
606
+}
607
+?>>Raw</option>
608
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
609
+	print 'selected';
610
+}
611
+?>>APRS</option>
612
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
613
+	print 'selected';
614
+}
615
+?>>Radarcape deltadb.txt</option>
616
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
617
+	print 'selected';
618
+}
619
+?>>Vatsim</option>
620
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
621
+	print 'selected';
622
+}
623
+?>>Virtual Radar Server AircraftList.json</option>
624
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
625
+	print 'selected';
626
+}
627
+?>>Virtual Radar Server TCP</option>
628
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
629
+	print 'selected';
630
+}
631
+?>>phpVMS</option>
632
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
633
+	print 'selected';
634
+}
635
+?>>Virtual Airlines Manager</option>
636
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
637
+	print 'selected';
638
+}
639
+?>>IVAO</option>
640
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
641
+	print 'selected';
642
+}
643
+?>>FlightGear Multiplayer</option>
644
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
645
+	print 'selected';
646
+}
647
+?>>FlightGear Singleplayer</option>
648
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
649
+	print 'selected';
650
+}
651
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
652
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
653
+	print 'selected';
654
+}
655
+?>>ACARS SBS-3 over TCP</option>
656
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
657
+	print 'selected';
658
+}
659
+?>>NMEA AIS over TCP</option>
660
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
661
+	print 'selected';
662
+}
663
+?>>AirWhere website</option>
664
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
665
+	print 'selected';
666
+}
667
+?>>HidnSeek Callback</option>
668
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
669
+	print 'selected';
670
+}
671
+?>>Blitzortung</option>
499 672
 									</select>
500 673
 								</td>
501 674
 								<td>
502
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
675
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
676
+	print $source['name'];
677
+}
678
+?>" />
503 679
 								</td>
504
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
505
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
680
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
681
+	print 'checked';
682
+}
683
+?> /></td>
684
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
685
+	print 'checked';
686
+}
687
+?> /></td>
506 688
 								<td>
507 689
 									<select name="timezones[]" id="timezones">
508 690
 								<?php
@@ -512,7 +694,9 @@  discard block
 block discarded – undo
512 694
 											print '<option selected>'.$timezones.'</option>';
513 695
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
514 696
 											print '<option selected>'.$timezones.'</option>';
515
-										} else print '<option>'.$timezones.'</option>';
697
+										} else {
698
+											print '<option>'.$timezones.'</option>';
699
+										}
516 700
 									}
517 701
 								?>
518 702
 									</select>
@@ -562,7 +746,9 @@  discard block
 block discarded – undo
562 746
 									foreach($timezonelist as $timezones){
563 747
 										if ($timezones == 'UTC') {
564 748
 											print '<option selected>'.$timezones.'</option>';
565
-										} else print '<option>'.$timezones.'</option>';
749
+										} else {
750
+											print '<option>'.$timezones.'</option>';
751
+										}
566 752
 									}
567 753
 								?>
568 754
 									</select>
@@ -585,11 +771,17 @@  discard block
 block discarded – undo
585 771
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
586 772
 					<p>
587 773
 						<label for="acarshost">ACARS UDP host</label>
588
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
774
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
775
+	print $globalACARSHost;
776
+}
777
+?>" />
589 778
 					</p>
590 779
 					<p>
591 780
 						<label for="acarsport">ACARS UDP port</label>
592
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
781
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
782
+	print $globalACARSPort;
783
+}
784
+?>" />
593 785
 					</p>
594 786
 				</fieldset>
595 787
 			</div>
@@ -671,13 +863,19 @@  discard block
 block discarded – undo
671 863
 			<div id="schedules_options">
672 864
 				<p>
673 865
 					<label for="britishairways">British Airways API Key</label>
674
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
866
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
867
+	print $globalBritishAirwaysKey;
868
+}
869
+?>" />
675 870
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
676 871
 				</p>
677 872
 				<!--
678 873
 				<p>
679 874
 					<label for="transavia">Transavia Test API Consumer Key</label>
680
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
875
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
876
+	print $globalTransaviaKey;
877
+}
878
+?>" />
681 879
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
682 880
 				</p>
683 881
 				-->
@@ -686,10 +884,16 @@  discard block
 block discarded – undo
686 884
 						<b>Lufthansa API Key</b>
687 885
 						<p>
688 886
 							<label for="lufthansakey">Key</label>
689
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
887
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
888
+	print $globalLufthansaKey['key'];
889
+}
890
+?>" />
690 891
 						</p><p>
691 892
 							<label for="lufthansasecret">Secret</label>
692
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
893
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
894
+	print $globalLufthansaKey['secret'];
895
+}
896
+?>" />
693 897
 						</p>
694 898
 					</div>
695 899
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -709,7 +913,10 @@  discard block
 block discarded – undo
709 913
 			</p>
710 914
 			<p>
711 915
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
712
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
916
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
917
+	print $globalNOTAMSource;
918
+}
919
+?>" />
713 920
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
714 921
 			</p>
715 922
 			<br />
@@ -725,14 +932,20 @@  discard block
 block discarded – undo
725 932
 			<div id="metarsrc">
726 933
 				<p>
727 934
 					<label for="metarsource">URL of your METAR source</label>
728
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
935
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
936
+	print $globalMETARurl;
937
+}
938
+?>" />
729 939
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
730 940
 				</p>
731 941
 			</div>
732 942
 			<br />
733 943
 			<p>
734 944
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
735
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
945
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
946
+	print $globalBitlyAccessToken;
947
+}
948
+?>" />
736 949
 			</p>
737 950
 			<br />
738 951
 			<p>
@@ -748,11 +961,26 @@  discard block
 block discarded – undo
748 961
 			<p>
749 962
 				<label for="geoid_source">Geoid Source</label>
750 963
 				<select name="geoid_source" id="geoid_source">
751
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
752
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
753
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
754
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
755
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
964
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
965
+	print ' selected="selected"';
966
+}
967
+?>>EGM96 15' (2.1MB)</option>
968
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
969
+	print ' selected="selected"';
970
+}
971
+?>>EGM96 5' (19MB)</option>
972
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
973
+	print ' selected="selected"';
974
+}
975
+?>>EGM2008 5' (19MB)</option>
976
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
977
+	print ' selected="selected"';
978
+}
979
+?>>EGM2008 2.5' (75MB)</option>
980
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
981
+	print ' selected="selected"';
982
+}
983
+?>>EGM2008 1' (470MB)</option>
756 984
 				</select>
757 985
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
758 986
 			</p>
@@ -770,7 +998,12 @@  discard block
 block discarded – undo
770 998
 			</p>
771 999
 			<p>
772 1000
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
773
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1001
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1002
+	print $globalArchiveMonths;
1003
+} else {
1004
+	echo '1';
1005
+}
1006
+?>" />
774 1007
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
775 1008
 			</p>
776 1009
 			<p>
@@ -780,12 +1013,22 @@  discard block
 block discarded – undo
780 1013
 			</p>
781 1014
 			<p>
782 1015
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
783
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1016
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1017
+	print $globalArchiveKeepMonths;
1018
+} else {
1019
+	echo '1';
1020
+}
1021
+?>" />
784 1022
 				<p class="help-block">0 to disable</p>
785 1023
 			</p>
786 1024
 			<p>
787 1025
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
788
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1026
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1027
+	print $globalArchiveKeepTrackMonths;
1028
+} else {
1029
+	echo '1';
1030
+}
1031
+?>" />
789 1032
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
790 1033
 			</p>
791 1034
 			<br />
@@ -795,7 +1038,12 @@  discard block
 block discarded – undo
795 1038
 				<p class="help-block">Uncheck if the script is running as cron job</p>
796 1039
 				<div id="cronends"> 
797 1040
 					<label for="cronend">Run script for xx seconds</label>
798
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1041
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1042
+	print $globalCronEnd;
1043
+} else {
1044
+	print '0';
1045
+}
1046
+?>" />
799 1047
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
800 1048
 				</div>
801 1049
 			</p>
@@ -848,15 +1096,30 @@  discard block
 block discarded – undo
848 1096
 			<br />
849 1097
 			<p>
850 1098
 				<label for="refresh">Show flights detected since xxx seconds</label>
851
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1099
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1100
+	echo $globalLiveInterval;
1101
+} else {
1102
+	echo '200';
1103
+}
1104
+?>" />
852 1105
 			</p>
853 1106
 			<p>
854 1107
 				<label for="maprefresh">Live map refresh (in seconds)</label>
855
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1108
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1109
+	echo $globalMapRefresh;
1110
+} else {
1111
+	echo '30';
1112
+}
1113
+?>" />
856 1114
 			</p>
857 1115
 			<p>
858 1116
 				<label for="mapidle">Map idle timeout (in minutes)</label>
859
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1117
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1118
+	echo $globalMapIdleTimeout;
1119
+} else {
1120
+	echo '30';
1121
+}
1122
+?>" />
860 1123
 				<p class="help-block">0 to disable</p>
861 1124
 			</p>
862 1125
 			<p>
@@ -871,12 +1134,20 @@  discard block
 block discarded – undo
871 1134
 			<br />
872 1135
 			<p>
873 1136
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
874
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1137
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1138
+	echo $globalClosestMinDist;
1139
+} else {
1140
+	echo '50';
1141
+}
1142
+?>" />
875 1143
 			</p>
876 1144
 			<br />
877 1145
 			<p>
878 1146
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
879
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1147
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1148
+	echo $globalAircraftSize;
1149
+}
1150
+?>" />
880 1151
 			</p>
881 1152
 			<br />
882 1153
 			<p>
@@ -889,7 +1160,12 @@  discard block
 block discarded – undo
889 1160
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
890 1161
 			?>
891 1162
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
892
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1163
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1164
+	echo $globalAircraftIconColor;
1165
+} else {
1166
+	echo '1a3151';
1167
+}
1168
+?>" />
893 1169
 			<?php
894 1170
 				if (!is_writable('../cache')) {
895 1171
 			?>
@@ -907,14 +1183,27 @@  discard block
 block discarded – undo
907 1183
 			<p>
908 1184
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
909 1185
 				<div class="range">
910
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
911
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1186
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1187
+	echo $globalAirportZoom;
1188
+} else {
1189
+	echo '7';
1190
+}
1191
+?>" />
1192
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1193
+	echo $globalAirportZoom;
1194
+} else {
1195
+	echo '7';
1196
+}
1197
+?></output>
912 1198
 				</div>
913 1199
 			</p>
914 1200
 			<br />
915 1201
 			<p>
916 1202
 				<label for="customcss">Custom CSS web path</label>
917
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1203
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1204
+	echo $globalCustomCSS;
1205
+}
1206
+?>" />
918 1207
 			</p>
919 1208
 		</fieldset>
920 1209
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -941,8 +1230,12 @@  discard block
 block discarded – undo
941 1230
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
942 1231
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
943 1232
 
944
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
945
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1233
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1234
+		$error .= 'Mysql driver for PDO must be loaded';
1235
+	}
1236
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1237
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1238
+	}
946 1239
 	
947 1240
 	$_SESSION['database_root'] = $dbroot;
948 1241
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1010,15 +1303,23 @@  discard block
 block discarded – undo
1010 1303
 	$source_city = $_POST['source_city'];
1011 1304
 	$source_country = $_POST['source_country'];
1012 1305
 	$source_ref = $_POST['source_ref'];
1013
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1014
-	else $source_id = array();
1306
+	if (isset($source_id)) {
1307
+		$source_id = $_POST['source_id'];
1308
+	} else {
1309
+		$source_id = array();
1310
+	}
1015 1311
 	
1016 1312
 	$sources = array();
1017 1313
 	foreach ($source_name as $keys => $name) {
1018
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1019
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1314
+	    if (isset($source_id[$keys])) {
1315
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1316
+	    } else {
1317
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1318
+	    }
1319
+	}
1320
+	if (count($sources) > 0) {
1321
+		$_SESSION['sources'] = $sources;
1020 1322
 	}
1021
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1022 1323
 
1023 1324
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1024 1325
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1039,17 +1340,29 @@  discard block
 block discarded – undo
1039 1340
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1040 1341
 
1041 1342
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1042
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1043
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1343
+	if ($globalaircraft == 'aircraft') {
1344
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1345
+	} else {
1346
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1347
+	}
1044 1348
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1045
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1046
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1349
+	if ($globaltracker == 'tracker') {
1350
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1351
+	} else {
1352
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1353
+	}
1047 1354
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1048
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1049
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1355
+	if ($globalmarine == 'marine') {
1356
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1357
+	} else {
1358
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1359
+	}
1050 1360
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1051
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1052
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1361
+	if ($globalsatellite == 'satellite') {
1362
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1363
+	} else {
1364
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1365
+	}
1053 1366
 
1054 1367
 /*	
1055 1368
 	$globalSBS1Hosts = array();
@@ -1071,23 +1384,37 @@  discard block
 block discarded – undo
1071 1384
 	$name = $_POST['name'];
1072 1385
 	$format = $_POST['format'];
1073 1386
 	$timezones = $_POST['timezones'];
1074
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1075
-	else $sourcestats = array();
1076
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1077
-	else $noarchive = array();
1387
+	if (isset($_POST['sourcestats'])) {
1388
+		$sourcestats = $_POST['sourcestats'];
1389
+	} else {
1390
+		$sourcestats = array();
1391
+	}
1392
+	if (isset($_POST['noarchive'])) {
1393
+		$noarchive = $_POST['noarchive'];
1394
+	} else {
1395
+		$noarchive = array();
1396
+	}
1078 1397
 	$gSources = array();
1079 1398
 	$forcepilots = false;
1080 1399
 	foreach ($host as $key => $h) {
1081
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1082
-		else $cov = 'FALSE';
1083
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1084
-		else $arch = 'FALSE';
1400
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1401
+			$cov = 'TRUE';
1402
+		} else {
1403
+			$cov = 'FALSE';
1404
+		}
1405
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1406
+			$arch = 'TRUE';
1407
+		} else {
1408
+			$arch = 'FALSE';
1409
+		}
1085 1410
 		if (strpos($format[$key],'_callback')) {
1086 1411
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1087 1412
 		} elseif ($h != '' || $name[$key] != '') {
1088 1413
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1089 1414
 		}
1090
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1415
+		if ($format[$key] == 'airwhere') {
1416
+			$forcepilots = true;
1417
+		}
1091 1418
 	}
1092 1419
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1093 1420
 
@@ -1115,7 +1442,9 @@  discard block
 block discarded – undo
1115 1442
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1116 1443
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1117 1444
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1118
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1445
+	} else {
1446
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1447
+	}
1119 1448
 
1120 1449
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1121 1450
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1154,7 +1483,9 @@  discard block
 block discarded – undo
1154 1483
 
1155 1484
 	// Create in settings.php keys not yet configurable if not already here
1156 1485
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1157
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1486
+	if (!isset($globalDebug)) {
1487
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1488
+	}
1158 1489
 
1159 1490
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1160 1491
 	if ($resetyearstats == 'resetyearstats') {
@@ -1191,37 +1522,56 @@  discard block
 block discarded – undo
1191 1522
 	}
1192 1523
 */
1193 1524
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1194
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1195
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1196
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1197
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1525
+	if ($globalsbs == 'sbs') {
1526
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1527
+	} else {
1528
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1529
+	}
1530
+	if ($globalaprs == 'aprs') {
1531
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1532
+	} else {
1533
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1534
+	}
1198 1535
 	$va = false;
1199 1536
 	if ($globalivao == 'ivao') {
1200 1537
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1201 1538
 		$va = true;
1202
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1539
+	} else {
1540
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1541
+	}
1203 1542
 	if ($globalvatsim == 'vatsim') {
1204 1543
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1205 1544
 		$va = true;
1206
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1545
+	} else {
1546
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1547
+	}
1207 1548
 	if ($globalphpvms == 'phpvms') {
1208 1549
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1209 1550
 		$va = true;
1210
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1551
+	} else {
1552
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1553
+	}
1211 1554
 	if ($globalvam == 'vam') {
1212 1555
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1213 1556
 		$va = true;
1214
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1557
+	} else {
1558
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1559
+	}
1215 1560
 	if ($va) {
1216 1561
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1217
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1562
+	} else {
1563
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1564
+	}
1218 1565
 	if ($globalva == 'va' || $va) {
1219 1566
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1220 1567
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1221 1568
 	} else {
1222 1569
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1223
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1224
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1570
+		if ($forcepilots) {
1571
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1572
+		} else {
1573
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1574
+		}
1225 1575
 	}
1226 1576
 	
1227 1577
 	
@@ -1397,7 +1747,9 @@  discard block
 block discarded – undo
1397 1747
 		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1398 1748
 	}
1399 1749
 
1400
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1750
+	if (!isset($globalTransaction)) {
1751
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1752
+	}
1401 1753
 
1402 1754
 	// Set some defaults values...
1403 1755
 	if (!isset($globalAircraftImageSources)) {
@@ -1412,15 +1764,23 @@  discard block
 block discarded – undo
1412 1764
 
1413 1765
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1414 1766
 
1415
-	if ($error == '') settings::modify_settings($settings);
1416
-	if ($error == '') settings::comment_settings($settings_comment);
1767
+	if ($error == '') {
1768
+		settings::modify_settings($settings);
1769
+	}
1770
+	if ($error == '') {
1771
+		settings::comment_settings($settings_comment);
1772
+	}
1417 1773
 	if ($error != '') {
1418 1774
 		print '<div class="info column">'.$error.'</div>';
1419 1775
 		require('../footer.php');
1420 1776
 		exit;
1421 1777
 	} else {
1422
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1423
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1778
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1779
+			$_SESSION['waypoints'] = 1;
1780
+		}
1781
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1782
+			$_SESSION['owner'] = 1;
1783
+		}
1424 1784
 		if (isset($_POST['createdb'])) {
1425 1785
 			$_SESSION['install'] = 'database_create';
1426 1786
 		} else {
@@ -1456,10 +1816,18 @@  discard block
 block discarded – undo
1456 1816
 	$popw = false;
1457 1817
 	foreach ($_SESSION['done'] as $done) {
1458 1818
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1459
-	    if ($done == 'Create database') $pop = true;
1460
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1461
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1462
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1819
+	    if ($done == 'Create database') {
1820
+	    	$pop = true;
1821
+	    }
1822
+	    if ($_SESSION['install'] == 'database_create') {
1823
+	    	$pop = true;
1824
+	    }
1825
+	    if ($_SESSION['install'] == 'database_import') {
1826
+	    	$popi = true;
1827
+	    }
1828
+	    if ($_SESSION['install'] == 'waypoints') {
1829
+	    	$popw = true;
1830
+	    }
1463 1831
 	}
1464 1832
 	if ($pop) {
1465 1833
 	    sleep(5);
@@ -1470,7 +1838,9 @@  discard block
 block discarded – undo
1470 1838
 	} else if ($popw) {
1471 1839
 	    sleep(5);
1472 1840
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1473
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1841
+	} else {
1842
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1843
+	}
1474 1844
 	print '</div></ul>';
1475 1845
 	print '<div id="error"></div>';
1476 1846
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
scripts/update_db.php 1 patch
Braces   +27 added lines, -10 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -29,14 +31,18 @@  discard block
 block discarded – undo
29 31
 			$update_db->update_notam();
30 32
 		}
31 33
 		$update_db->insert_last_notam_update();
32
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
34
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
35
+		echo "NOTAM are only updated once a day.\n";
36
+	}
33 37
 	if ($update_db->check_last_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
34 38
 		$update_db->update_all();
35 39
 	//	require_once(dirname(__FILE__).'/../require/class.Spotter.php');
36 40
 	//	$Spotter = new Spotter();
37 41
 	//	$Spotter->updateFieldsFromOtherTables();
38 42
 		$update_db->insert_last_update();
39
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
43
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
44
+		echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
45
+	}
40 46
 	if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) {
41 47
 		echo "Check if new airspace version exist...";
42 48
 		echo $update_db->update_airspace_fam();
@@ -45,8 +51,11 @@  discard block
 block discarded – undo
45 51
 	if (isset($globalGeoid) && $globalGeoid && $update_db->check_last_geoid_update()) {
46 52
 		echo "Check if new geoid version exist...";
47 53
 		$error = $update_db->update_geoid_fam();
48
-		if ($error == '') $update_db->insert_last_geoid_update();
49
-		else echo $error;
54
+		if ($error == '') {
55
+			$update_db->insert_last_geoid_update();
56
+		} else {
57
+			echo $error;
58
+		}
50 59
 	}
51 60
 	if (isset($globalMarine) && $globalMarine && $update_db->check_last_marine_identity_update()) {
52 61
 		echo "Check if new marine identity version exist...";
@@ -64,7 +73,9 @@  discard block
 block discarded – undo
64 73
 			//echo "Done";
65 74
 		}
66 75
 		$update_db->insert_last_owner_update();
67
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
76
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
77
+		echo "Owner are only updated every 15 days.\n";
78
+	}
68 79
 
69 80
 	if (isset($globalAccidents) && $globalAccidents && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
70 81
 		require_once(dirname(__FILE__).'/../require/class.Accident.php');
@@ -73,7 +84,9 @@  discard block
 block discarded – undo
73 84
 		if ($Accident->check_last_accidents_update()) {
74 85
 			$Accident->download_update();
75 86
 			$Accident->insert_last_accidents_update();
76
-		} else echo "Accidents are updated once a day.\n";
87
+		} else {
88
+			echo "Accidents are updated once a day.\n";
89
+		}
77 90
 	}
78 91
   
79 92
 }
@@ -86,15 +99,19 @@  discard block
 block discarded – undo
86 99
 	if ($METAR->check_last_update()) {
87 100
 		$METAR->addMETARCycle();
88 101
 		$METAR->insert_last_update();
89
-	} else echo "METAR are only updated every 30 minutes.\n";
90
-}
102
+	} else {
103
+		echo "METAR are only updated every 30 minutes.\n";
104
+	}
105
+	}
91 106
 
92 107
 if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
93 108
 	echo "Updating schedules...";
94 109
 	//$update_db->update_oneworld();
95 110
 	$update_db->update_skyteam();
96 111
 	$update_db->insert_last_schedules_update();
97
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
112
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
113
+	echo "Schedules are only updated every 15 days.\n";
114
+}
98 115
 
99 116
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
100 117
 	echo "Updating statistics and archive old data...";
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +428 added lines, -158 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
 
@@ -1608,41 +1674,65 @@  discard block
 block discarded – undo
1608 1674
 		if ($globalDBdriver == 'mysql') {
1609 1675
 			if (!$Connection->tableExists('tracker_output')) {
1610 1676
 				$error .= create_db::import_file('../db/tracker_output.sql');
1611
-				if ($error != '') return $error;
1677
+				if ($error != '') {
1678
+					return $error;
1679
+				}
1612 1680
 			}
1613 1681
 			if (!$Connection->tableExists('tracker_live')) {
1614 1682
 				$error .= create_db::import_file('../db/tracker_live.sql');
1615
-				if ($error != '') return $error;
1683
+				if ($error != '') {
1684
+					return $error;
1685
+				}
1616 1686
 			}
1617 1687
 			if (!$Connection->tableExists('marine_output')) {
1618 1688
 				$error .= create_db::import_file('../db/marine_output.sql');
1619
-				if ($error != '') return $error;
1689
+				if ($error != '') {
1690
+					return $error;
1691
+				}
1620 1692
 			}
1621 1693
 			if (!$Connection->tableExists('marine_live')) {
1622 1694
 				$error .= create_db::import_file('../db/marine_live.sql');
1623
-				if ($error != '') return $error;
1695
+				if ($error != '') {
1696
+					return $error;
1697
+				}
1624 1698
 			}
1625 1699
 			if (!$Connection->tableExists('marine_identity')) {
1626 1700
 				$error .= create_db::import_file('../db/marine_identity.sql');
1627
-				if ($error != '') return $error;
1701
+				if ($error != '') {
1702
+					return $error;
1703
+				}
1628 1704
 			}
1629 1705
 			if (!$Connection->tableExists('marine_mid')) {
1630 1706
 				$error .= create_db::import_file('../db/marine_mid.sql');
1631
-				if ($error != '') return $error;
1707
+				if ($error != '') {
1708
+					return $error;
1709
+				}
1632 1710
 			}
1633 1711
 		} else {
1634 1712
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1635
-			if ($error != '') return $error;
1713
+			if ($error != '') {
1714
+				return $error;
1715
+			}
1636 1716
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1637
-			if ($error != '') return $error;
1717
+			if ($error != '') {
1718
+				return $error;
1719
+			}
1638 1720
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1639
-			if ($error != '') return $error;
1721
+			if ($error != '') {
1722
+				return $error;
1723
+			}
1640 1724
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1641
-			if ($error != '') return $error;
1725
+			if ($error != '') {
1726
+				return $error;
1727
+			}
1642 1728
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1643
-			if ($error != '') return $error;
1729
+			if ($error != '') {
1730
+				return $error;
1731
+			}
1644 1732
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1645
-			if ($error != '') return $error;
1733
+			if ($error != '') {
1734
+				return $error;
1735
+			}
1646 1736
 		}
1647 1737
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1648 1738
 		try {
@@ -1661,39 +1751,61 @@  discard block
 block discarded – undo
1661 1751
 		if ($globalDBdriver == 'mysql') {
1662 1752
 			if (!$Connection->tableExists('marine_image')) {
1663 1753
 				$error .= create_db::import_file('../db/marine_image.sql');
1664
-				if ($error != '') return $error;
1754
+				if ($error != '') {
1755
+					return $error;
1756
+				}
1665 1757
 			}
1666 1758
 			if (!$Connection->tableExists('marine_archive')) {
1667 1759
 				$error .= create_db::import_file('../db/marine_archive.sql');
1668
-				if ($error != '') return $error;
1760
+				if ($error != '') {
1761
+					return $error;
1762
+				}
1669 1763
 			}
1670 1764
 			if (!$Connection->tableExists('marine_archive_output')) {
1671 1765
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1672
-				if ($error != '') return $error;
1766
+				if ($error != '') {
1767
+					return $error;
1768
+				}
1673 1769
 			}
1674 1770
 			if (!$Connection->tableExists('tracker_archive')) {
1675 1771
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1676
-				if ($error != '') return $error;
1772
+				if ($error != '') {
1773
+					return $error;
1774
+				}
1677 1775
 			}
1678 1776
 			if (!$Connection->tableExists('tracker_archive_output')) {
1679 1777
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1680
-				if ($error != '') return $error;
1778
+				if ($error != '') {
1779
+					return $error;
1780
+				}
1681 1781
 			}
1682 1782
 			if (!$Connection->tableExists('marine_archive_output')) {
1683 1783
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1684
-				if ($error != '') return $error;
1784
+				if ($error != '') {
1785
+					return $error;
1786
+				}
1685 1787
 			}
1686 1788
 		} else {
1687 1789
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1688
-			if ($error != '') return $error;
1790
+			if ($error != '') {
1791
+				return $error;
1792
+			}
1689 1793
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1690
-			if ($error != '') return $error;
1794
+			if ($error != '') {
1795
+				return $error;
1796
+			}
1691 1797
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1692
-			if ($error != '') return $error;
1798
+			if ($error != '') {
1799
+				return $error;
1800
+			}
1693 1801
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1694
-			if ($error != '') return $error;
1802
+			if ($error != '') {
1803
+				return $error;
1804
+			}
1695 1805
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1696
-			if ($error != '') return $error;
1806
+			if ($error != '') {
1807
+				return $error;
1808
+			}
1697 1809
 		}
1698 1810
 		if ($globalDBdriver == 'mysql') {
1699 1811
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2064,7 +2176,9 @@  discard block
 block discarded – undo
2064 2176
 		if ($globalDBdriver == 'mysql') {
2065 2177
 			if (!$Connection->tableExists('tracker_archive_output')) {
2066 2178
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2067
-				if ($error != '') return $error;
2179
+				if ($error != '') {
2180
+					return $error;
2181
+				}
2068 2182
 			}
2069 2183
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2070 2184
 		} else {
@@ -2092,14 +2206,22 @@  discard block
 block discarded – undo
2092 2206
 		$error = '';
2093 2207
 		if ($globalDBdriver == 'mysql') {
2094 2208
 			$error .= create_db::import_file('../db/airport.sql');
2095
-			if ($error != '') return $error;
2209
+			if ($error != '') {
2210
+				return $error;
2211
+			}
2096 2212
 			$error .= create_db::import_file('../db/airlines.sql');
2097
-			if ($error != '') return $error;
2213
+			if ($error != '') {
2214
+				return $error;
2215
+			}
2098 2216
 		} else {
2099 2217
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2100
-			if ($error != '') return $error;
2218
+			if ($error != '') {
2219
+				return $error;
2220
+			}
2101 2221
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2102
-			if ($error != '') return $error;
2222
+			if ($error != '') {
2223
+				return $error;
2224
+			}
2103 2225
 		}
2104 2226
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2105 2227
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2116,7 +2238,9 @@  discard block
 block discarded – undo
2116 2238
 				$error .= update_db::update_vatsim();
2117 2239
 			}
2118 2240
 		}
2119
-		if ($error != '') return $error;
2241
+		if ($error != '') {
2242
+			return $error;
2243
+		}
2120 2244
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2121 2245
 		try {
2122 2246
 			$sth = $Connection->db->prepare($query);
@@ -2134,10 +2258,14 @@  discard block
 block discarded – undo
2134 2258
 		if (!$Connection->tableExists('satellite')) {
2135 2259
 			if ($globalDBdriver == 'mysql') {
2136 2260
 				$error .= create_db::import_file('../db/satellite.sql');
2137
-				if ($error != '') return $error;
2261
+				if ($error != '') {
2262
+					return $error;
2263
+				}
2138 2264
 			} else {
2139 2265
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2140
-				if ($error != '') return $error;
2266
+				if ($error != '') {
2267
+					return $error;
2268
+				}
2141 2269
 			}
2142 2270
 		}
2143 2271
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2159,8 +2287,11 @@  discard block
 block discarded – undo
2159 2287
     	    if ($Connection->tableExists('aircraft')) {
2160 2288
     		if (!$Connection->tableExists('config')) {
2161 2289
     		    $version = '1';
2162
-    		    if ($update) return self::update_from_1();
2163
-    		    else return $version;
2290
+    		    if ($update) {
2291
+    		    	return self::update_from_1();
2292
+    		    } else {
2293
+    		    	return $version;
2294
+    		    }
2164 2295
 		} else {
2165 2296
     		    $Connection = new Connection();
2166 2297
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -2174,188 +2305,327 @@  discard block
 block discarded – undo
2174 2305
     		    if ($update) {
2175 2306
     			if ($result['value'] == '2') {
2176 2307
     			    $error = self::update_from_2();
2177
-    			    if ($error != '') return $error;
2178
-    			    else return self::check_version(true);
2308
+    			    if ($error != '') {
2309
+    			    	return $error;
2310
+    			    } else {
2311
+    			    	return self::check_version(true);
2312
+    			    }
2179 2313
     			} elseif ($result['value'] == '3') {
2180 2314
     			    $error = self::update_from_3();
2181
-    			    if ($error != '') return $error;
2182
-    			    else return self::check_version(true);
2315
+    			    if ($error != '') {
2316
+    			    	return $error;
2317
+    			    } else {
2318
+    			    	return self::check_version(true);
2319
+    			    }
2183 2320
     			} elseif ($result['value'] == '4') {
2184 2321
     			    $error = self::update_from_4();
2185
-    			    if ($error != '') return $error;
2186
-    			    else return self::check_version(true);
2322
+    			    if ($error != '') {
2323
+    			    	return $error;
2324
+    			    } else {
2325
+    			    	return self::check_version(true);
2326
+    			    }
2187 2327
     			} elseif ($result['value'] == '5') {
2188 2328
     			    $error = self::update_from_5();
2189
-    			    if ($error != '') return $error;
2190
-    			    else return self::check_version(true);
2329
+    			    if ($error != '') {
2330
+    			    	return $error;
2331
+    			    } else {
2332
+    			    	return self::check_version(true);
2333
+    			    }
2191 2334
     			} elseif ($result['value'] == '6') {
2192 2335
     			    $error = self::update_from_6();
2193
-    			    if ($error != '') return $error;
2194
-    			    else return self::check_version(true);
2336
+    			    if ($error != '') {
2337
+    			    	return $error;
2338
+    			    } else {
2339
+    			    	return self::check_version(true);
2340
+    			    }
2195 2341
     			} elseif ($result['value'] == '7') {
2196 2342
     			    $error = self::update_from_7();
2197
-    			    if ($error != '') return $error;
2198
-    			    else return self::check_version(true);
2343
+    			    if ($error != '') {
2344
+    			    	return $error;
2345
+    			    } else {
2346
+    			    	return self::check_version(true);
2347
+    			    }
2199 2348
     			} elseif ($result['value'] == '8') {
2200 2349
     			    $error = self::update_from_8();
2201
-    			    if ($error != '') return $error;
2202
-    			    else return self::check_version(true);
2350
+    			    if ($error != '') {
2351
+    			    	return $error;
2352
+    			    } else {
2353
+    			    	return self::check_version(true);
2354
+    			    }
2203 2355
     			} elseif ($result['value'] == '9') {
2204 2356
     			    $error = self::update_from_9();
2205
-    			    if ($error != '') return $error;
2206
-    			    else return self::check_version(true);
2357
+    			    if ($error != '') {
2358
+    			    	return $error;
2359
+    			    } else {
2360
+    			    	return self::check_version(true);
2361
+    			    }
2207 2362
     			} elseif ($result['value'] == '10') {
2208 2363
     			    $error = self::update_from_10();
2209
-    			    if ($error != '') return $error;
2210
-    			    else return self::check_version(true);
2364
+    			    if ($error != '') {
2365
+    			    	return $error;
2366
+    			    } else {
2367
+    			    	return self::check_version(true);
2368
+    			    }
2211 2369
     			} elseif ($result['value'] == '11') {
2212 2370
     			    $error = self::update_from_11();
2213
-    			    if ($error != '') return $error;
2214
-    			    else return self::check_version(true);
2371
+    			    if ($error != '') {
2372
+    			    	return $error;
2373
+    			    } else {
2374
+    			    	return self::check_version(true);
2375
+    			    }
2215 2376
     			} elseif ($result['value'] == '12') {
2216 2377
     			    $error = self::update_from_12();
2217
-    			    if ($error != '') return $error;
2218
-    			    else return self::check_version(true);
2378
+    			    if ($error != '') {
2379
+    			    	return $error;
2380
+    			    } else {
2381
+    			    	return self::check_version(true);
2382
+    			    }
2219 2383
     			} elseif ($result['value'] == '13') {
2220 2384
     			    $error = self::update_from_13();
2221
-    			    if ($error != '') return $error;
2222
-    			    else return self::check_version(true);
2385
+    			    if ($error != '') {
2386
+    			    	return $error;
2387
+    			    } else {
2388
+    			    	return self::check_version(true);
2389
+    			    }
2223 2390
     			} elseif ($result['value'] == '14') {
2224 2391
     			    $error = self::update_from_14();
2225
-    			    if ($error != '') return $error;
2226
-    			    else return self::check_version(true);
2392
+    			    if ($error != '') {
2393
+    			    	return $error;
2394
+    			    } else {
2395
+    			    	return self::check_version(true);
2396
+    			    }
2227 2397
     			} elseif ($result['value'] == '15') {
2228 2398
     			    $error = self::update_from_15();
2229
-    			    if ($error != '') return $error;
2230
-    			    else return self::check_version(true);
2399
+    			    if ($error != '') {
2400
+    			    	return $error;
2401
+    			    } else {
2402
+    			    	return self::check_version(true);
2403
+    			    }
2231 2404
     			} elseif ($result['value'] == '16') {
2232 2405
     			    $error = self::update_from_16();
2233
-    			    if ($error != '') return $error;
2234
-    			    else return self::check_version(true);
2406
+    			    if ($error != '') {
2407
+    			    	return $error;
2408
+    			    } else {
2409
+    			    	return self::check_version(true);
2410
+    			    }
2235 2411
     			} elseif ($result['value'] == '17') {
2236 2412
     			    $error = self::update_from_17();
2237
-    			    if ($error != '') return $error;
2238
-    			    else return self::check_version(true);
2413
+    			    if ($error != '') {
2414
+    			    	return $error;
2415
+    			    } else {
2416
+    			    	return self::check_version(true);
2417
+    			    }
2239 2418
     			} elseif ($result['value'] == '18') {
2240 2419
     			    $error = self::update_from_18();
2241
-    			    if ($error != '') return $error;
2242
-    			    else return self::check_version(true);
2420
+    			    if ($error != '') {
2421
+    			    	return $error;
2422
+    			    } else {
2423
+    			    	return self::check_version(true);
2424
+    			    }
2243 2425
     			} elseif ($result['value'] == '19') {
2244 2426
     			    $error = self::update_from_19();
2245
-    			    if ($error != '') return $error;
2246
-    			    else return self::check_version(true);
2427
+    			    if ($error != '') {
2428
+    			    	return $error;
2429
+    			    } else {
2430
+    			    	return self::check_version(true);
2431
+    			    }
2247 2432
     			} elseif ($result['value'] == '20') {
2248 2433
     			    $error = self::update_from_20();
2249
-    			    if ($error != '') return $error;
2250
-    			    else return self::check_version(true);
2434
+    			    if ($error != '') {
2435
+    			    	return $error;
2436
+    			    } else {
2437
+    			    	return self::check_version(true);
2438
+    			    }
2251 2439
     			} elseif ($result['value'] == '21') {
2252 2440
     			    $error = self::update_from_21();
2253
-    			    if ($error != '') return $error;
2254
-    			    else return self::check_version(true);
2441
+    			    if ($error != '') {
2442
+    			    	return $error;
2443
+    			    } else {
2444
+    			    	return self::check_version(true);
2445
+    			    }
2255 2446
     			} elseif ($result['value'] == '22') {
2256 2447
     			    $error = self::update_from_22();
2257
-    			    if ($error != '') return $error;
2258
-    			    else return self::check_version(true);
2448
+    			    if ($error != '') {
2449
+    			    	return $error;
2450
+    			    } else {
2451
+    			    	return self::check_version(true);
2452
+    			    }
2259 2453
     			} elseif ($result['value'] == '23') {
2260 2454
     			    $error = self::update_from_23();
2261
-    			    if ($error != '') return $error;
2262
-    			    else return self::check_version(true);
2455
+    			    if ($error != '') {
2456
+    			    	return $error;
2457
+    			    } else {
2458
+    			    	return self::check_version(true);
2459
+    			    }
2263 2460
     			} elseif ($result['value'] == '24') {
2264 2461
     			    $error = self::update_from_24();
2265
-    			    if ($error != '') return $error;
2266
-    			    else return self::check_version(true);
2462
+    			    if ($error != '') {
2463
+    			    	return $error;
2464
+    			    } else {
2465
+    			    	return self::check_version(true);
2466
+    			    }
2267 2467
     			} elseif ($result['value'] == '25') {
2268 2468
     			    $error = self::update_from_25();
2269
-    			    if ($error != '') return $error;
2270
-    			    else return self::check_version(true);
2469
+    			    if ($error != '') {
2470
+    			    	return $error;
2471
+    			    } else {
2472
+    			    	return self::check_version(true);
2473
+    			    }
2271 2474
     			} elseif ($result['value'] == '26') {
2272 2475
     			    $error = self::update_from_26();
2273
-    			    if ($error != '') return $error;
2274
-    			    else return self::check_version(true);
2476
+    			    if ($error != '') {
2477
+    			    	return $error;
2478
+    			    } else {
2479
+    			    	return self::check_version(true);
2480
+    			    }
2275 2481
     			} elseif ($result['value'] == '27') {
2276 2482
     			    $error = self::update_from_27();
2277
-    			    if ($error != '') return $error;
2278
-    			    else return self::check_version(true);
2483
+    			    if ($error != '') {
2484
+    			    	return $error;
2485
+    			    } else {
2486
+    			    	return self::check_version(true);
2487
+    			    }
2279 2488
     			} elseif ($result['value'] == '28') {
2280 2489
     			    $error = self::update_from_28();
2281
-    			    if ($error != '') return $error;
2282
-    			    else return self::check_version(true);
2490
+    			    if ($error != '') {
2491
+    			    	return $error;
2492
+    			    } else {
2493
+    			    	return self::check_version(true);
2494
+    			    }
2283 2495
     			} elseif ($result['value'] == '29') {
2284 2496
     			    $error = self::update_from_29();
2285
-    			    if ($error != '') return $error;
2286
-    			    else return self::check_version(true);
2497
+    			    if ($error != '') {
2498
+    			    	return $error;
2499
+    			    } else {
2500
+    			    	return self::check_version(true);
2501
+    			    }
2287 2502
     			} elseif ($result['value'] == '30') {
2288 2503
     			    $error = self::update_from_30();
2289
-    			    if ($error != '') return $error;
2290
-    			    else return self::check_version(true);
2504
+    			    if ($error != '') {
2505
+    			    	return $error;
2506
+    			    } else {
2507
+    			    	return self::check_version(true);
2508
+    			    }
2291 2509
     			} elseif ($result['value'] == '31') {
2292 2510
     			    $error = self::update_from_31();
2293
-    			    if ($error != '') return $error;
2294
-    			    else return self::check_version(true);
2511
+    			    if ($error != '') {
2512
+    			    	return $error;
2513
+    			    } else {
2514
+    			    	return self::check_version(true);
2515
+    			    }
2295 2516
     			} elseif ($result['value'] == '32') {
2296 2517
     			    $error = self::update_from_32();
2297
-    			    if ($error != '') return $error;
2298
-    			    else return self::check_version(true);
2518
+    			    if ($error != '') {
2519
+    			    	return $error;
2520
+    			    } else {
2521
+    			    	return self::check_version(true);
2522
+    			    }
2299 2523
     			} elseif ($result['value'] == '33') {
2300 2524
     			    $error = self::update_from_33();
2301
-    			    if ($error != '') return $error;
2302
-    			    else return self::check_version(true);
2525
+    			    if ($error != '') {
2526
+    			    	return $error;
2527
+    			    } else {
2528
+    			    	return self::check_version(true);
2529
+    			    }
2303 2530
     			} elseif ($result['value'] == '34') {
2304 2531
     			    $error = self::update_from_34();
2305
-    			    if ($error != '') return $error;
2306
-    			    else return self::check_version(true);
2532
+    			    if ($error != '') {
2533
+    			    	return $error;
2534
+    			    } else {
2535
+    			    	return self::check_version(true);
2536
+    			    }
2307 2537
     			} elseif ($result['value'] == '35') {
2308 2538
     			    $error = self::update_from_35();
2309
-    			    if ($error != '') return $error;
2310
-    			    else return self::check_version(true);
2539
+    			    if ($error != '') {
2540
+    			    	return $error;
2541
+    			    } else {
2542
+    			    	return self::check_version(true);
2543
+    			    }
2311 2544
     			} elseif ($result['value'] == '36') {
2312 2545
     			    $error = self::update_from_36();
2313
-    			    if ($error != '') return $error;
2314
-    			    else return self::check_version(true);
2546
+    			    if ($error != '') {
2547
+    			    	return $error;
2548
+    			    } else {
2549
+    			    	return self::check_version(true);
2550
+    			    }
2315 2551
     			} elseif ($result['value'] == '37') {
2316 2552
     			    $error = self::update_from_37();
2317
-    			    if ($error != '') return $error;
2318
-    			    else return self::check_version(true);
2553
+    			    if ($error != '') {
2554
+    			    	return $error;
2555
+    			    } else {
2556
+    			    	return self::check_version(true);
2557
+    			    }
2319 2558
     			} elseif ($result['value'] == '38') {
2320 2559
     			    $error = self::update_from_38();
2321
-    			    if ($error != '') return $error;
2322
-    			    else return self::check_version(true);
2560
+    			    if ($error != '') {
2561
+    			    	return $error;
2562
+    			    } else {
2563
+    			    	return self::check_version(true);
2564
+    			    }
2323 2565
     			} elseif ($result['value'] == '39') {
2324 2566
     			    $error = self::update_from_39();
2325
-    			    if ($error != '') return $error;
2326
-    			    else return self::check_version(true);
2567
+    			    if ($error != '') {
2568
+    			    	return $error;
2569
+    			    } else {
2570
+    			    	return self::check_version(true);
2571
+    			    }
2327 2572
     			} elseif ($result['value'] == '40') {
2328 2573
     			    $error = self::update_from_40();
2329
-    			    if ($error != '') return $error;
2330
-    			    else return self::check_version(true);
2574
+    			    if ($error != '') {
2575
+    			    	return $error;
2576
+    			    } else {
2577
+    			    	return self::check_version(true);
2578
+    			    }
2331 2579
     			} elseif ($result['value'] == '41') {
2332 2580
     			    $error = self::update_from_41();
2333
-    			    if ($error != '') return $error;
2334
-    			    else return self::check_version(true);
2581
+    			    if ($error != '') {
2582
+    			    	return $error;
2583
+    			    } else {
2584
+    			    	return self::check_version(true);
2585
+    			    }
2335 2586
     			} elseif ($result['value'] == '42') {
2336 2587
     			    $error = self::update_from_42();
2337
-    			    if ($error != '') return $error;
2338
-    			    else return self::check_version(true);
2588
+    			    if ($error != '') {
2589
+    			    	return $error;
2590
+    			    } else {
2591
+    			    	return self::check_version(true);
2592
+    			    }
2339 2593
     			} elseif ($result['value'] == '43') {
2340 2594
     			    $error = self::update_from_43();
2341
-    			    if ($error != '') return $error;
2342
-    			    else return self::check_version(true);
2595
+    			    if ($error != '') {
2596
+    			    	return $error;
2597
+    			    } else {
2598
+    			    	return self::check_version(true);
2599
+    			    }
2343 2600
     			} elseif ($result['value'] == '44') {
2344 2601
     			    $error = self::update_from_44();
2345
-    			    if ($error != '') return $error;
2346
-    			    else return self::check_version(true);
2602
+    			    if ($error != '') {
2603
+    			    	return $error;
2604
+    			    } else {
2605
+    			    	return self::check_version(true);
2606
+    			    }
2347 2607
     			} elseif ($result['value'] == '45') {
2348 2608
     			    $error = self::update_from_45();
2349
-    			    if ($error != '') return $error;
2350
-    			    else return self::check_version(true);
2351
-    			} else return '';
2609
+    			    if ($error != '') {
2610
+    			    	return $error;
2611
+    			    } else {
2612
+    			    	return self::check_version(true);
2613
+    			    }
2614
+    			} else {
2615
+    				return '';
2616
+    			}
2352 2617
     		    } else {
2353
-    			if (isset($result['value']) && $result['value'] != '') return $result['value'];
2354
-    			else return 0;
2618
+    			if (isset($result['value']) && $result['value'] != '') {
2619
+    				return $result['value'];
2620
+    			} else {
2621
+    				return 0;
2622
+    			}
2355 2623
     		    }
2356 2624
 		}
2357 2625
 		
2358
-	    } else return $version;
2626
+	    } else {
2627
+	    	return $version;
2628
+	    }
2359 2629
     	}
2360 2630
     	
2361 2631
 }
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +1026 added lines, -356 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19 19
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
20
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
20
+		if ($referer != '') {
21
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
22
+		}
21 23
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
22 24
 		curl_setopt($ch, CURLOPT_FILE, $fp);
23 25
 		curl_exec($ch);
@@ -28,12 +30,16 @@  discard block
 block discarded – undo
28 30
 	public static function gunzip($in_file,$out_file_name = '') {
29 31
 		//echo $in_file.' -> '.$out_file_name."\n";
30 32
 		$buffer_size = 4096; // read 4kb at a time
31
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
33
+		if ($out_file_name == '') {
34
+			$out_file_name = str_replace('.gz', '', $in_file);
35
+		}
32 36
 		if ($in_file != '' && file_exists($in_file)) {
33 37
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
36
-			else {
38
+			if (function_exists('gzopen')) {
39
+				$file = gzopen($in_file,'rb');
40
+			} elseif (function_exists('gzopen64')) {
41
+				$file = gzopen64($in_file,'rb');
42
+			} else {
37 43
 				echo 'gzopen not available';
38 44
 				die;
39 45
 			}
@@ -54,8 +60,12 @@  discard block
 block discarded – undo
54 60
 			if ($res === TRUE) {
55 61
 				$zip->extractTo($path);
56 62
 				$zip->close();
57
-			} else return false;
58
-		} else return false;
63
+			} else {
64
+				return false;
65
+			}
66
+		} else {
67
+			return false;
68
+		}
59 69
 	}
60 70
 	
61 71
 	public static function connect_sqlite($database) {
@@ -70,7 +80,9 @@  discard block
 block discarded – undo
70 80
 	public static function retrieve_route_sqlite_to_dest($database_file) {
71 81
 		global $globalDebug, $globalTransaction;
72 82
 		//$query = 'TRUNCATE TABLE routes';
73
-		if ($globalDebug) echo " - Delete previous routes from DB -";
83
+		if ($globalDebug) {
84
+			echo " - Delete previous routes from DB -";
85
+		}
74 86
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
75 87
 		$Connection = new Connection();
76 88
 		try {
@@ -81,7 +93,9 @@  discard block
 block discarded – undo
81 93
                         return "error : ".$e->getMessage();
82 94
                 }
83 95
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
96
+    		if ($globalDebug) {
97
+    			echo " - Add routes to DB -";
98
+    		}
85 99
     		update_db::connect_sqlite($database_file);
86 100
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
87 101
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -96,15 +110,21 @@  discard block
 block discarded – undo
96 110
 		$Connection = new Connection();
97 111
 		$sth_dest = $Connection->db->prepare($query_dest);
98 112
 		try {
99
-			if ($globalTransaction) $Connection->db->beginTransaction();
113
+			if ($globalTransaction) {
114
+				$Connection->db->beginTransaction();
115
+			}
100 116
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 117
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
103 119
 				$sth_dest->execute($query_dest_values);
104 120
             		}
105
-			if ($globalTransaction) $Connection->db->commit();
121
+			if ($globalTransaction) {
122
+				$Connection->db->commit();
123
+			}
106 124
 		} catch(PDOException $e) {
107
-			if ($globalTransaction) $Connection->db->rollBack(); 
125
+			if ($globalTransaction) {
126
+				$Connection->db->rollBack();
127
+			}
108 128
 			return "error : ".$e->getMessage();
109 129
 		}
110 130
                 return '';
@@ -112,7 +132,9 @@  discard block
 block discarded – undo
112 132
 	public static function retrieve_route_oneworld($database_file) {
113 133
 		global $globalDebug, $globalTransaction;
114 134
 		//$query = 'TRUNCATE TABLE routes';
115
-		if ($globalDebug) echo " - Delete previous routes from DB -";
135
+		if ($globalDebug) {
136
+			echo " - Delete previous routes from DB -";
137
+		}
116 138
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
117 139
 		$Connection = new Connection();
118 140
 		try {
@@ -123,14 +145,18 @@  discard block
 block discarded – undo
123 145
                         return "error : ".$e->getMessage();
124 146
                 }
125 147
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
148
+    		if ($globalDebug) {
149
+    			echo " - Add routes to DB -";
150
+    		}
127 151
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 152
 		$Spotter = new Spotter();
129 153
 		if ($fh = fopen($database_file,"r")) {
130 154
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 155
 			$Connection = new Connection();
132 156
 			$sth_dest = $Connection->db->prepare($query_dest);
133
-			if ($globalTransaction) $Connection->db->beginTransaction();
157
+			if ($globalTransaction) {
158
+				$Connection->db->beginTransaction();
159
+			}
134 160
 			while (!feof($fh)) {
135 161
 				$line = fgetcsv($fh,9999,',');
136 162
 				if ($line[0] != '') {
@@ -139,13 +165,17 @@  discard block
 block discarded – undo
139 165
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
140 166
 							$sth_dest->execute($query_dest_values);
141 167
 						} catch(PDOException $e) {
142
-							if ($globalTransaction) $Connection->db->rollBack(); 
168
+							if ($globalTransaction) {
169
+								$Connection->db->rollBack();
170
+							}
143 171
 							return "error : ".$e->getMessage();
144 172
 						}
145 173
 					}
146 174
 				}
147 175
 			}
148
-			if ($globalTransaction) $Connection->db->commit();
176
+			if ($globalTransaction) {
177
+				$Connection->db->commit();
178
+			}
149 179
 		}
150 180
                 return '';
151 181
 	}
@@ -153,7 +183,9 @@  discard block
 block discarded – undo
153 183
 	public static function retrieve_route_skyteam($database_file) {
154 184
 		global $globalDebug, $globalTransaction;
155 185
 		//$query = 'TRUNCATE TABLE routes';
156
-		if ($globalDebug) echo " - Delete previous routes from DB -";
186
+		if ($globalDebug) {
187
+			echo " - Delete previous routes from DB -";
188
+		}
157 189
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
158 190
 		$Connection = new Connection();
159 191
 		try {
@@ -164,7 +196,9 @@  discard block
 block discarded – undo
164 196
                         return "error : ".$e->getMessage();
165 197
                 }
166 198
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
199
+    		if ($globalDebug) {
200
+    			echo " - Add routes to DB -";
201
+    		}
168 202
 
169 203
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 204
 		$Spotter = new Spotter();
@@ -173,7 +207,9 @@  discard block
 block discarded – undo
173 207
 			$Connection = new Connection();
174 208
 			$sth_dest = $Connection->db->prepare($query_dest);
175 209
 			try {
176
-				if ($globalTransaction) $Connection->db->beginTransaction();
210
+				if ($globalTransaction) {
211
+					$Connection->db->beginTransaction();
212
+				}
177 213
 				while (!feof($fh)) {
178 214
 					$line = fgetcsv($fh,9999,',');
179 215
 					if ($line[0] != '') {
@@ -184,9 +220,13 @@  discard block
 block discarded – undo
184 220
 						}
185 221
 					}
186 222
 				}
187
-				if ($globalTransaction) $Connection->db->commit();
223
+				if ($globalTransaction) {
224
+					$Connection->db->commit();
225
+				}
188 226
 			} catch(PDOException $e) {
189
-				if ($globalTransaction) $Connection->db->rollBack(); 
227
+				if ($globalTransaction) {
228
+					$Connection->db->rollBack();
229
+				}
190 230
 				return "error : ".$e->getMessage();
191 231
 			}
192 232
 		}
@@ -229,11 +269,16 @@  discard block
 block discarded – undo
229 269
 		$sth_dest = $Connection->db->prepare($query_dest);
230 270
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 271
 		try {
232
-			if ($globalTransaction) $Connection->db->beginTransaction();
272
+			if ($globalTransaction) {
273
+				$Connection->db->beginTransaction();
274
+			}
233 275
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 276
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235
-				if ($values['UserString4'] == 'M') $type = 'military';
236
-				else $type = null;
277
+				if ($values['UserString4'] == 'M') {
278
+					$type = 'military';
279
+				} else {
280
+					$type = null;
281
+				}
237 282
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 283
 				$sth_dest->execute($query_dest_values);
239 284
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -241,7 +286,9 @@  discard block
 block discarded – undo
241 286
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 287
 				}
243 288
             		}
244
-			if ($globalTransaction) $Connection->db->commit();
289
+			if ($globalTransaction) {
290
+				$Connection->db->commit();
291
+			}
245 292
 		} catch(PDOException $e) {
246 293
 			return "error : ".$e->getMessage();
247 294
 		}
@@ -278,7 +325,9 @@  discard block
 block discarded – undo
278 325
 			$Connection = new Connection();
279 326
 			$sth_dest = $Connection->db->prepare($query_dest);
280 327
 			try {
281
-				if ($globalTransaction) $Connection->db->beginTransaction();
328
+				if ($globalTransaction) {
329
+					$Connection->db->beginTransaction();
330
+				}
282 331
             			while (!feof($fh)) {
283 332
             				$values = array();
284 333
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -289,7 +338,9 @@  discard block
 block discarded – undo
289 338
             				// Check if we can find ICAO, else set it to GLID
290 339
             				$aircraft_name_split = explode(' ',$aircraft_name);
291 340
             				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
341
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
342
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
343
+            				}
293 344
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294 345
             				$sth_search = $Connection->db->prepare($query_search);
295 346
 					try {
@@ -302,7 +353,9 @@  discard block
 block discarded – undo
302 353
 					} catch(PDOException $e) {
303 354
 						return "error : ".$e->getMessage();
304 355
 					}
305
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
356
+					if (!isset($values['ICAOTypeCode'])) {
357
+						$values['ICAOTypeCode'] = 'GLID';
358
+					}
306 359
 					// Add data to db
307 360
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 361
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -311,7 +364,9 @@  discard block
 block discarded – undo
311 364
 						$sth_dest->execute($query_dest_values);
312 365
 					}
313 366
 				}
314
-				if ($globalTransaction) $Connection->db->commit();
367
+				if ($globalTransaction) {
368
+					$Connection->db->commit();
369
+				}
315 370
 			} catch(PDOException $e) {
316 371
 				return "error : ".$e->getMessage();
317 372
 			}
@@ -347,7 +402,9 @@  discard block
 block discarded – undo
347 402
 			$Connection = new Connection();
348 403
 			$sth_dest = $Connection->db->prepare($query_dest);
349 404
 			try {
350
-				if ($globalTransaction) $Connection->db->beginTransaction();
405
+				if ($globalTransaction) {
406
+					$Connection->db->beginTransaction();
407
+				}
351 408
 				$tmp = fgetcsv($fh,9999,',',"'");
352 409
             			while (!feof($fh)) {
353 410
             				$line = fgetcsv($fh,9999,',',"'");
@@ -361,13 +418,17 @@  discard block
 block discarded – undo
361 418
             				// Check if we can find ICAO, else set it to GLID
362 419
             				$aircraft_name_split = explode(' ',$aircraft_name);
363 420
             				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
422
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
423
+            				}
365 424
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366 425
             				$sth_search = $Connection->db->prepare($query_search);
367 426
 					try {
368 427
                                     		$sth_search->execute();
369 428
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
429
+	            				if (isset($result['icao']) && $result['icao'] != '') {
430
+	            					$values['ICAOTypeCode'] = $result['icao'];
431
+	            				}
371 432
 					} catch(PDOException $e) {
372 433
 						return "error : ".$e->getMessage();
373 434
 					}
@@ -380,7 +441,9 @@  discard block
 block discarded – undo
380 441
 						$sth_dest->execute($query_dest_values);
381 442
 					}
382 443
 				}
383
-				if ($globalTransaction) $Connection->db->commit();
444
+				if ($globalTransaction) {
445
+					$Connection->db->commit();
446
+				}
384 447
 			} catch(PDOException $e) {
385 448
 				return "error : ".$e->getMessage();
386 449
 			}
@@ -419,7 +482,9 @@  discard block
 block discarded – undo
419 482
 			$sth_dest = $Connection->db->prepare($query_dest);
420 483
 			$sth_modes = $Connection->db->prepare($query_modes);
421 484
 			try {
422
-				if ($globalTransaction) $Connection->db->beginTransaction();
485
+				if ($globalTransaction) {
486
+					$Connection->db->beginTransaction();
487
+				}
423 488
 				$tmp = fgetcsv($fh,9999,',','"');
424 489
             			while (!feof($fh)) {
425 490
             				$line = fgetcsv($fh,9999,',','"');
@@ -429,16 +494,22 @@  discard block
 block discarded – undo
429 494
             				    $values['registration'] = $line[0];
430 495
             				    $values['base'] = $line[4];
431 496
             				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+            				    if ($line[6] == '') {
498
+            				    	$values['date_first_reg'] = null;
499
+            				    } else {
500
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
501
+					    }
434 502
 					    $values['cancel'] = $line[7];
435 503
 					} elseif ($country == 'EI') {
436 504
 					    // TODO : add modeS & reg to aircraft_modes
437 505
             				    $values['registration'] = $line[0];
438 506
             				    $values['base'] = $line[3];
439 507
             				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
508
+            				    if ($line[1] == '') {
509
+            				    	$values['date_first_reg'] = null;
510
+            				    } else {
511
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
512
+					    }
442 513
 					    $values['cancel'] = '';
443 514
 					    $values['modes'] = $line[7];
444 515
 					    $values['icao'] = $line[8];
@@ -457,16 +528,22 @@  discard block
 block discarded – undo
457 528
             				    $values['registration'] = $line[3];
458 529
             				    $values['base'] = null;
459 530
             				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
531
+            				    if ($line[18] == '') {
532
+            				    	$values['date_first_reg'] = null;
533
+            				    } else {
534
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
535
+					    }
462 536
 					    $values['cancel'] = '';
463 537
 					} elseif ($country == 'VH') {
464 538
 					    // TODO : add modeS & reg to aircraft_modes
465 539
             				    $values['registration'] = $line[0];
466 540
             				    $values['base'] = null;
467 541
             				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
542
+            				    if ($line[28] == '') {
543
+            				    	$values['date_first_reg'] = null;
544
+            				    } else {
545
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
546
+					    }
470 547
 
471 548
 					    $values['cancel'] = $line[39];
472 549
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -485,29 +562,41 @@  discard block
 block discarded – undo
485 562
             				    $values['registration'] = $line[0];
486 563
             				    $values['base'] = null;
487 564
             				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
565
+            				    if ($line[7] == '') {
566
+            				    	$values['date_first_reg'] = null;
567
+            				    } else {
568
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
569
+					    }
490 570
 					    $values['cancel'] = '';
491 571
 					} elseif ($country == 'PP') {
492 572
             				    $values['registration'] = $line[0];
493 573
             				    $values['base'] = null;
494 574
             				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
575
+            				    if ($line[6] == '') {
576
+            				    	$values['date_first_reg'] = null;
577
+            				    } else {
578
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
579
+					    }
497 580
 					    $values['cancel'] = $line[7];
498 581
 					} elseif ($country == 'E7') {
499 582
             				    $values['registration'] = $line[0];
500 583
             				    $values['base'] = null;
501 584
             				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
585
+            				    if ($line[5] == '') {
586
+            				    	$values['date_first_reg'] = null;
587
+            				    } else {
588
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
589
+					    }
504 590
 					    $values['cancel'] = '';
505 591
 					} elseif ($country == '8Q') {
506 592
             				    $values['registration'] = $line[0];
507 593
             				    $values['base'] = null;
508 594
             				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
595
+            				    if ($line[7] == '') {
596
+            				    	$values['date_first_reg'] = null;
597
+            				    } else {
598
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
599
+					    }
511 600
 					    $values['cancel'] = '';
512 601
 					} elseif ($country == 'ZK') {
513 602
             				    $values['registration'] = $line[0];
@@ -552,7 +641,9 @@  discard block
 block discarded – undo
552 641
 						$sth_modes->execute($query_modes_values);
553 642
 					}
554 643
 				}
555
-				if ($globalTransaction) $Connection->db->commit();
644
+				if ($globalTransaction) {
645
+					$Connection->db->commit();
646
+				}
556 647
 			} catch(PDOException $e) {
557 648
 				return "error : ".$e->getMessage();
558 649
 			}
@@ -688,25 +779,45 @@  discard block
 block discarded – undo
688 779
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
689 780
 		$Connection = new Connection();
690 781
 		$sth_dest = $Connection->db->prepare($query_dest);
691
-		if ($globalTransaction) $Connection->db->beginTransaction();
782
+		if ($globalTransaction) {
783
+			$Connection->db->beginTransaction();
784
+		}
692 785
   
693 786
 		$i = 0;
694 787
 		while($row = sparql_fetch_array($result))
695 788
 		{
696 789
 			if ($i >= 1) {
697 790
 			//print_r($row);
698
-			if (!isset($row['iata'])) $row['iata'] = '';
699
-			if (!isset($row['icao'])) $row['icao'] = '';
700
-			if (!isset($row['type'])) $row['type'] = '';
701
-			if (!isset($row['altitude'])) $row['altitude'] = '';
791
+			if (!isset($row['iata'])) {
792
+				$row['iata'] = '';
793
+			}
794
+			if (!isset($row['icao'])) {
795
+				$row['icao'] = '';
796
+			}
797
+			if (!isset($row['type'])) {
798
+				$row['type'] = '';
799
+			}
800
+			if (!isset($row['altitude'])) {
801
+				$row['altitude'] = '';
802
+			}
702 803
 			if (isset($row['city_bis'])) {
703 804
 				$row['city'] = $row['city_bis'];
704 805
 			}
705
-			if (!isset($row['city'])) $row['city'] = '';
706
-			if (!isset($row['country'])) $row['country'] = '';
707
-			if (!isset($row['homepage'])) $row['homepage'] = '';
708
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
709
-			if (!isset($row['name'])) continue;
806
+			if (!isset($row['city'])) {
807
+				$row['city'] = '';
808
+			}
809
+			if (!isset($row['country'])) {
810
+				$row['country'] = '';
811
+			}
812
+			if (!isset($row['homepage'])) {
813
+				$row['homepage'] = '';
814
+			}
815
+			if (!isset($row['wikipedia_page'])) {
816
+				$row['wikipedia_page'] = '';
817
+			}
818
+			if (!isset($row['name'])) {
819
+				continue;
820
+			}
710 821
 			if (!isset($row['image'])) {
711 822
 				$row['image'] = '';
712 823
 				$row['image_thumb'] = '';
@@ -762,7 +873,9 @@  discard block
 block discarded – undo
762 873
 
763 874
 			$i++;
764 875
 		}
765
-		if ($globalTransaction) $Connection->db->commit();
876
+		if ($globalTransaction) {
877
+			$Connection->db->commit();
878
+		}
766 879
 		/*
767 880
 		echo "Delete duplicate rows...\n";
768 881
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -805,7 +918,9 @@  discard block
 block discarded – undo
805 918
 		$delimiter = ',';
806 919
 		$out_file = $tmp_dir.'airports.csv';
807 920
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
808
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
921
+		if (!file_exists($out_file) || !is_readable($out_file)) {
922
+			return FALSE;
923
+		}
809 924
 		echo "Add data from ourairports.com...\n";
810 925
 
811 926
 		$header = NULL;
@@ -815,8 +930,9 @@  discard block
 block discarded – undo
815 930
 			//$Connection->db->beginTransaction();
816 931
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
817 932
 			{
818
-				if(!$header) $header = $row;
819
-				else {
933
+				if(!$header) {
934
+					$header = $row;
935
+				} else {
820 936
 					$data = array();
821 937
 					$data = array_combine($header, $row);
822 938
 					try {
@@ -857,7 +973,9 @@  discard block
 block discarded – undo
857 973
 		echo "Download data from another free database...\n";
858 974
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
859 975
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
860
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
976
+		if (!file_exists($out_file) || !is_readable($out_file)) {
977
+			return FALSE;
978
+		}
861 979
 		update_db::unzip($out_file);
862 980
 		$header = NULL;
863 981
 		echo "Add data from another free database...\n";
@@ -868,8 +986,9 @@  discard block
 block discarded – undo
868 986
 			//$Connection->db->beginTransaction();
869 987
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 988
 			{
871
-				if(!$header) $header = $row;
872
-				else {
989
+				if(!$header) {
990
+					$header = $row;
991
+				} else {
873 992
 					$data = $row;
874 993
 
875 994
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1038,7 +1157,9 @@  discard block
 block discarded – undo
1038 1157
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1039 1158
 		{
1040 1159
 			$i = 0;
1041
-			if ($globalTransaction) $Connection->db->beginTransaction();
1160
+			if ($globalTransaction) {
1161
+				$Connection->db->beginTransaction();
1162
+			}
1042 1163
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1043 1164
 			{
1044 1165
 				if ($i > 0) {
@@ -1051,7 +1172,9 @@  discard block
 block discarded – undo
1051 1172
 					}
1052 1173
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1053 1174
 					if (!empty($result_search)) {
1054
-						if ($globalDebug) echo '.';
1175
+						if ($globalDebug) {
1176
+							echo '.';
1177
+						}
1055 1178
 							//if ($globalDBdriver == 'mysql') {
1056 1179
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1057 1180
 							//} else {
@@ -1073,8 +1196,12 @@  discard block
 block discarded – undo
1073 1196
 						}
1074 1197
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1075 1198
 						if (!empty($result_search_mfr)) {
1076
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1077
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1199
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1200
+								$data[16] = $data[23];
1201
+							}
1202
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1203
+								$data[16] = $data[15];
1204
+							}
1078 1205
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1079 1206
 							try {
1080 1207
 								$sthf = $Connection->db->prepare($queryf);
@@ -1085,7 +1212,9 @@  discard block
 block discarded – undo
1085 1212
 						}
1086 1213
 					}
1087 1214
 					if (strtotime($data[29]) > time()) {
1088
-						if ($globalDebug) echo 'i';
1215
+						if ($globalDebug) {
1216
+							echo 'i';
1217
+						}
1089 1218
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1090 1219
 						try {
1091 1220
 							$sth = $Connection->db->prepare($query);
@@ -1096,13 +1225,19 @@  discard block
 block discarded – undo
1096 1225
 					}
1097 1226
 				}
1098 1227
 				if ($i % 90 == 0) {
1099
-					if ($globalTransaction) $Connection->db->commit();
1100
-					if ($globalTransaction) $Connection->db->beginTransaction();
1228
+					if ($globalTransaction) {
1229
+						$Connection->db->commit();
1230
+					}
1231
+					if ($globalTransaction) {
1232
+						$Connection->db->beginTransaction();
1233
+					}
1101 1234
 				}
1102 1235
 				$i++;
1103 1236
 			}
1104 1237
 			fclose($handle);
1105
-			if ($globalTransaction) $Connection->db->commit();
1238
+			if ($globalTransaction) {
1239
+				$Connection->db->commit();
1240
+			}
1106 1241
 		}
1107 1242
 		//print_r($mfr);
1108 1243
 		return '';
@@ -1127,11 +1262,15 @@  discard block
 block discarded – undo
1127 1262
 			$i = 0;
1128 1263
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1129 1264
 			//$Connection->db->beginTransaction();
1130
-			if ($globalTransaction) $Connection->db->beginTransaction();
1265
+			if ($globalTransaction) {
1266
+				$Connection->db->beginTransaction();
1267
+			}
1131 1268
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1132 1269
 			{
1133 1270
 				if ($i > 0) {
1134
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1271
+					if ($data[1] == 'NULL') {
1272
+						$data[1] = $data[0];
1273
+					}
1135 1274
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1136 1275
 					try {
1137 1276
 						$sth = $Connection->db->prepare($query);
@@ -1143,7 +1282,9 @@  discard block
 block discarded – undo
1143 1282
 				$i++;
1144 1283
 			}
1145 1284
 			fclose($handle);
1146
-			if ($globalTransaction) $Connection->db->commit();
1285
+			if ($globalTransaction) {
1286
+				$Connection->db->commit();
1287
+			}
1147 1288
 		}
1148 1289
 		return '';
1149 1290
         }
@@ -1164,7 +1305,9 @@  discard block
 block discarded – undo
1164 1305
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1165 1306
 		{
1166 1307
 			$i = 0;
1167
-			if ($globalTransaction) $Connection->db->beginTransaction();
1308
+			if ($globalTransaction) {
1309
+				$Connection->db->beginTransaction();
1310
+			}
1168 1311
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1169 1312
 			{
1170 1313
 				if ($i > 0) {
@@ -1180,7 +1323,9 @@  discard block
 block discarded – undo
1180 1323
 				$i++;
1181 1324
 			}
1182 1325
 			fclose($handle);
1183
-			if ($globalTransaction) $Connection->db->commit();
1326
+			if ($globalTransaction) {
1327
+				$Connection->db->commit();
1328
+			}
1184 1329
 		}
1185 1330
 		return '';
1186 1331
         }
@@ -1200,7 +1345,9 @@  discard block
 block discarded – undo
1200 1345
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1201 1346
 		{
1202 1347
 			$i = 0;
1203
-			if ($globalTransaction) $Connection->db->beginTransaction();
1348
+			if ($globalTransaction) {
1349
+				$Connection->db->beginTransaction();
1350
+			}
1204 1351
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1205 1352
 			{
1206 1353
 				if ($i > 0) {
@@ -1209,13 +1356,17 @@  discard block
 block discarded – undo
1209 1356
 						$sth = $Connection->db->prepare($query);
1210 1357
 						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1211 1358
 					} catch(PDOException $e) {
1212
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1359
+						if ($globalDebug) {
1360
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1361
+						}
1213 1362
 					}
1214 1363
 				}
1215 1364
 				$i++;
1216 1365
 			}
1217 1366
 			fclose($handle);
1218
-			if ($globalTransaction) $Connection->db->commit();
1367
+			if ($globalTransaction) {
1368
+				$Connection->db->commit();
1369
+			}
1219 1370
 		}
1220 1371
 		return '';
1221 1372
         }
@@ -1240,7 +1391,9 @@  discard block
 block discarded – undo
1240 1391
 			$i = 0;
1241 1392
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1242 1393
 			//$Connection->db->beginTransaction();
1243
-			if ($globalTransaction) $Connection->db->beginTransaction();
1394
+			if ($globalTransaction) {
1395
+				$Connection->db->beginTransaction();
1396
+			}
1244 1397
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1245 1398
 			{
1246 1399
 				if ($i > 0) {
@@ -1256,7 +1409,9 @@  discard block
 block discarded – undo
1256 1409
 				$i++;
1257 1410
 			}
1258 1411
 			fclose($handle);
1259
-			if ($globalTransaction) $Connection->db->commit();
1412
+			if ($globalTransaction) {
1413
+				$Connection->db->commit();
1414
+			}
1260 1415
 		}
1261 1416
 		return '';
1262 1417
         }
@@ -1276,7 +1431,9 @@  discard block
 block discarded – undo
1276 1431
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1277 1432
 		{
1278 1433
 			$i = 0;
1279
-			if ($globalTransaction) $Connection->db->beginTransaction();
1434
+			if ($globalTransaction) {
1435
+				$Connection->db->beginTransaction();
1436
+			}
1280 1437
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1281 1438
 			{
1282 1439
 				if ($i > 0) {
@@ -1293,7 +1450,9 @@  discard block
 block discarded – undo
1293 1450
 				$i++;
1294 1451
 			}
1295 1452
 			fclose($handle);
1296
-			if ($globalTransaction) $Connection->db->commit();
1453
+			if ($globalTransaction) {
1454
+				$Connection->db->commit();
1455
+			}
1297 1456
 		}
1298 1457
 		return '';
1299 1458
 	}
@@ -1312,7 +1471,9 @@  discard block
 block discarded – undo
1312 1471
 		$Connection = new Connection();
1313 1472
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1314 1473
 		{
1315
-			if ($globalTransaction) $Connection->db->beginTransaction();
1474
+			if ($globalTransaction) {
1475
+				$Connection->db->beginTransaction();
1476
+			}
1316 1477
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1317 1478
 			{
1318 1479
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1327,7 +1488,9 @@  discard block
 block discarded – undo
1327 1488
 				}
1328 1489
 			}
1329 1490
 			fclose($handle);
1330
-			if ($globalTransaction) $Connection->db->commit();
1491
+			if ($globalTransaction) {
1492
+				$Connection->db->commit();
1493
+			}
1331 1494
 		}
1332 1495
 		return '';
1333 1496
         }
@@ -1403,9 +1566,14 @@  discard block
 block discarded – undo
1403 1566
 				if ($i > 0 && $data[0] != '') {
1404 1567
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1405 1568
 					$period = str_replace(',','',$data[14]);
1406
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1407
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1408
-					else $launch_date = NULL;
1569
+					if (!empty($period) && strpos($period,'days')) {
1570
+						$period = str_replace(' days','',$period)*24*60;
1571
+					}
1572
+					if ($data[18] != '') {
1573
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1574
+					} else {
1575
+						$launch_date = NULL;
1576
+					}
1409 1577
 					$data = array_map(function($value) {
1410 1578
 						return trim($value) === '' ? null : $value;
1411 1579
 					}, $data);
@@ -1755,7 +1923,9 @@  discard block
 block discarded – undo
1755 1923
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1756 1924
 		{
1757 1925
 			$i = 0;
1758
-			if ($globalTransaction) $Connection->db->beginTransaction();
1926
+			if ($globalTransaction) {
1927
+				$Connection->db->beginTransaction();
1928
+			}
1759 1929
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1760 1930
 			{
1761 1931
 				$i++;
@@ -1783,7 +1953,9 @@  discard block
 block discarded – undo
1783 1953
 				}
1784 1954
 			}
1785 1955
 			fclose($handle);
1786
-			if ($globalTransaction) $Connection->db->commit();
1956
+			if ($globalTransaction) {
1957
+				$Connection->db->commit();
1958
+			}
1787 1959
 		}
1788 1960
 		return '';
1789 1961
         }
@@ -1806,7 +1978,9 @@  discard block
 block discarded – undo
1806 1978
 		$Connection = new Connection();
1807 1979
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1808 1980
 		{
1809
-			if ($globalTransaction) $Connection->db->beginTransaction();
1981
+			if ($globalTransaction) {
1982
+				$Connection->db->beginTransaction();
1983
+			}
1810 1984
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1811 1985
 			{
1812 1986
 				if(count($row) > 1) {
@@ -1820,7 +1994,9 @@  discard block
 block discarded – undo
1820 1994
 				}
1821 1995
 			}
1822 1996
 			fclose($handle);
1823
-			if ($globalTransaction) $Connection->db->commit();
1997
+			if ($globalTransaction) {
1998
+				$Connection->db->commit();
1999
+			}
1824 2000
 		}
1825 2001
 		return '';
1826 2002
         }
@@ -1840,8 +2016,9 @@  discard block
 block discarded – undo
1840 2016
 	        }
1841 2017
 
1842 2018
 
1843
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1844
-		else {
2019
+		if ($globalDBdriver == 'mysql') {
2020
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2021
+		} else {
1845 2022
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1846 2023
 			$query = "CREATE EXTENSION postgis";
1847 2024
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1860,20 +2037,30 @@  discard block
 block discarded – undo
1860 2037
 		global $tmp_dir, $globalDebug;
1861 2038
 		include_once('class.create_db.php');
1862 2039
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1863
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2040
+		if ($globalDebug) {
2041
+			echo "NOTAM from FlightAirMap website : Download...";
2042
+		}
1864 2043
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1865 2044
 		$error = '';
1866 2045
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1867
-			if ($globalDebug) echo "Gunzip...";
2046
+			if ($globalDebug) {
2047
+				echo "Gunzip...";
2048
+			}
1868 2049
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1869
-			if ($globalDebug) echo "Add to DB...";
2050
+			if ($globalDebug) {
2051
+				echo "Add to DB...";
2052
+			}
1870 2053
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1871 2054
 			$NOTAM = new NOTAM();
1872 2055
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1873
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2056
+		} else {
2057
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2058
+		}
1874 2059
 		if ($error != '') {
1875 2060
 			return $error;
1876
-		} elseif ($globalDebug) echo "Done\n";
2061
+		} elseif ($globalDebug) {
2062
+			echo "Done\n";
2063
+		}
1877 2064
 		return '';
1878 2065
 	}
1879 2066
 
@@ -1927,67 +2114,111 @@  discard block
 block discarded – undo
1927 2114
 		//if ($globalDebug) echo "IVAO : Download...";
1928 2115
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1929 2116
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1930
-			if ($globalDebug) echo "Unzip...";
2117
+			if ($globalDebug) {
2118
+				echo "Unzip...";
2119
+			}
1931 2120
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1932
-			if ($globalDebug) echo "Add to DB...";
2121
+			if ($globalDebug) {
2122
+				echo "Add to DB...";
2123
+			}
1933 2124
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1934
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2125
+			if ($globalDebug) {
2126
+				echo "Copy airlines logos to airlines images directory...";
2127
+			}
1935 2128
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1936
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1937
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1938
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2129
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2130
+					$error = "Failed to copy airlines logo.";
2131
+				}
2132
+			} else {
2133
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2134
+			}
2135
+		} else {
2136
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2137
+		}
1939 2138
 		if ($error != '') {
1940 2139
 			return $error;
1941
-		} elseif ($globalDebug) echo "Done\n";
2140
+		} elseif ($globalDebug) {
2141
+			echo "Done\n";
2142
+		}
1942 2143
 		return '';
1943 2144
 	}
1944 2145
 
1945 2146
 	public static function update_routes() {
1946 2147
 		global $tmp_dir, $globalDebug;
1947 2148
 		$error = '';
1948
-		if ($globalDebug) echo "Routes : Download...";
2149
+		if ($globalDebug) {
2150
+			echo "Routes : Download...";
2151
+		}
1949 2152
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1950 2153
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1951
-			if ($globalDebug) echo "Gunzip...";
2154
+			if ($globalDebug) {
2155
+				echo "Gunzip...";
2156
+			}
1952 2157
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1953
-			if ($globalDebug) echo "Add to DB...";
2158
+			if ($globalDebug) {
2159
+				echo "Add to DB...";
2160
+			}
1954 2161
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1955
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2162
+		} else {
2163
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2164
+		}
1956 2165
 		if ($error != '') {
1957 2166
 			return $error;
1958
-		} elseif ($globalDebug) echo "Done\n";
2167
+		} elseif ($globalDebug) {
2168
+			echo "Done\n";
2169
+		}
1959 2170
 		return '';
1960 2171
 	}
1961 2172
 	public static function update_oneworld() {
1962 2173
 		global $tmp_dir, $globalDebug;
1963 2174
 		$error = '';
1964
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2175
+		if ($globalDebug) {
2176
+			echo "Schedules Oneworld : Download...";
2177
+		}
1965 2178
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1966 2179
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1967
-			if ($globalDebug) echo "Gunzip...";
2180
+			if ($globalDebug) {
2181
+				echo "Gunzip...";
2182
+			}
1968 2183
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1969
-			if ($globalDebug) echo "Add to DB...";
2184
+			if ($globalDebug) {
2185
+				echo "Add to DB...";
2186
+			}
1970 2187
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1971
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2188
+		} else {
2189
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2190
+		}
1972 2191
 		if ($error != '') {
1973 2192
 			return $error;
1974
-		} elseif ($globalDebug) echo "Done\n";
2193
+		} elseif ($globalDebug) {
2194
+			echo "Done\n";
2195
+		}
1975 2196
 		return '';
1976 2197
 	}
1977 2198
 	public static function update_skyteam() {
1978 2199
 		global $tmp_dir, $globalDebug;
1979 2200
 		$error = '';
1980
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2201
+		if ($globalDebug) {
2202
+			echo "Schedules Skyteam : Download...";
2203
+		}
1981 2204
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1982 2205
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1983
-			if ($globalDebug) echo "Gunzip...";
2206
+			if ($globalDebug) {
2207
+				echo "Gunzip...";
2208
+			}
1984 2209
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1985
-			if ($globalDebug) echo "Add to DB...";
2210
+			if ($globalDebug) {
2211
+				echo "Add to DB...";
2212
+			}
1986 2213
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1987
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2214
+		} else {
2215
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2216
+		}
1988 2217
 		if ($error != '') {
1989 2218
 			return $error;
1990
-		} elseif ($globalDebug) echo "Done\n";
2219
+		} elseif ($globalDebug) {
2220
+			echo "Done\n";
2221
+		}
1991 2222
 		return '';
1992 2223
 	}
1993 2224
 	public static function update_ModeS() {
@@ -2004,355 +2235,619 @@  discard block
 block discarded – undo
2004 2235
 			exit;
2005 2236
 		} elseif ($globalDebug) echo "Done\n";
2006 2237
 */
2007
-		if ($globalDebug) echo "Modes : Download...";
2008
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2238
+		if ($globalDebug) {
2239
+			echo "Modes : Download...";
2240
+		}
2241
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2009 2242
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2010 2243
 
2011 2244
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2012 2245
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2013
-			if ($globalDebug) echo "Unzip...";
2014
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2246
+			if ($globalDebug) {
2247
+				echo "Unzip...";
2248
+			}
2249
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2015 2250
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2016
-			if ($globalDebug) echo "Add to DB...";
2251
+			if ($globalDebug) {
2252
+				echo "Add to DB...";
2253
+			}
2017 2254
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2018 2255
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2019
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2256
+		} else {
2257
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2258
+		}
2020 2259
 		if ($error != '') {
2021 2260
 			return $error;
2022
-		} elseif ($globalDebug) echo "Done\n";
2261
+		} elseif ($globalDebug) {
2262
+			echo "Done\n";
2263
+		}
2023 2264
 		return '';
2024 2265
 	}
2025 2266
 
2026 2267
 	public static function update_ModeS_faa() {
2027 2268
 		global $tmp_dir, $globalDebug;
2028
-		if ($globalDebug) echo "Modes FAA: Download...";
2269
+		if ($globalDebug) {
2270
+			echo "Modes FAA: Download...";
2271
+		}
2029 2272
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2030 2273
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2031
-			if ($globalDebug) echo "Unzip...";
2274
+			if ($globalDebug) {
2275
+				echo "Unzip...";
2276
+			}
2032 2277
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2033
-			if ($globalDebug) echo "Add to DB...";
2278
+			if ($globalDebug) {
2279
+				echo "Add to DB...";
2280
+			}
2034 2281
 			$error = update_db::modes_faa();
2035
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2282
+		} else {
2283
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2284
+		}
2036 2285
 		if ($error != '') {
2037 2286
 			return $error;
2038
-		} elseif ($globalDebug) echo "Done\n";
2287
+		} elseif ($globalDebug) {
2288
+			echo "Done\n";
2289
+		}
2039 2290
 		return '';
2040 2291
 	}
2041 2292
 
2042 2293
 	public static function update_ModeS_flarm() {
2043 2294
 		global $tmp_dir, $globalDebug;
2044
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2295
+		if ($globalDebug) {
2296
+			echo "Modes Flarmnet: Download...";
2297
+		}
2045 2298
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2046 2299
 		if (file_exists($tmp_dir.'data.fln')) {
2047
-			if ($globalDebug) echo "Add to DB...";
2300
+			if ($globalDebug) {
2301
+				echo "Add to DB...";
2302
+			}
2048 2303
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2049
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2304
+		} else {
2305
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2306
+		}
2050 2307
 		if ($error != '') {
2051 2308
 			return $error;
2052
-		} elseif ($globalDebug) echo "Done\n";
2309
+		} elseif ($globalDebug) {
2310
+			echo "Done\n";
2311
+		}
2053 2312
 		return '';
2054 2313
 	}
2055 2314
 
2056 2315
 	public static function update_ModeS_ogn() {
2057 2316
 		global $tmp_dir, $globalDebug;
2058
-		if ($globalDebug) echo "Modes OGN: Download...";
2317
+		if ($globalDebug) {
2318
+			echo "Modes OGN: Download...";
2319
+		}
2059 2320
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2060 2321
 		if (file_exists($tmp_dir.'ogn.csv')) {
2061
-			if ($globalDebug) echo "Add to DB...";
2322
+			if ($globalDebug) {
2323
+				echo "Add to DB...";
2324
+			}
2062 2325
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2063
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2326
+		} else {
2327
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2328
+		}
2064 2329
 		if ($error != '') {
2065 2330
 			return $error;
2066
-		} elseif ($globalDebug) echo "Done\n";
2331
+		} elseif ($globalDebug) {
2332
+			echo "Done\n";
2333
+		}
2067 2334
 		return '';
2068 2335
 	}
2069 2336
 
2070 2337
 	public static function update_owner() {
2071 2338
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2072 2339
 		
2073
-		if ($globalDebug) echo "Owner France: Download...";
2340
+		if ($globalDebug) {
2341
+			echo "Owner France: Download...";
2342
+		}
2074 2343
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2075 2344
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2076
-			if ($globalDebug) echo "Add to DB...";
2345
+			if ($globalDebug) {
2346
+				echo "Add to DB...";
2347
+			}
2077 2348
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2078
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2349
+		} else {
2350
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2351
+		}
2079 2352
 		if ($error != '') {
2080 2353
 			return $error;
2081
-		} elseif ($globalDebug) echo "Done\n";
2354
+		} elseif ($globalDebug) {
2355
+			echo "Done\n";
2356
+		}
2082 2357
 		
2083
-		if ($globalDebug) echo "Owner Ireland: Download...";
2358
+		if ($globalDebug) {
2359
+			echo "Owner Ireland: Download...";
2360
+		}
2084 2361
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2085 2362
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2086
-			if ($globalDebug) echo "Add to DB...";
2363
+			if ($globalDebug) {
2364
+				echo "Add to DB...";
2365
+			}
2087 2366
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2088
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2367
+		} else {
2368
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2369
+		}
2089 2370
 		if ($error != '') {
2090 2371
 			return $error;
2091
-		} elseif ($globalDebug) echo "Done\n";
2092
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2372
+		} elseif ($globalDebug) {
2373
+			echo "Done\n";
2374
+		}
2375
+		if ($globalDebug) {
2376
+			echo "Owner Switzerland: Download...";
2377
+		}
2093 2378
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2094 2379
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2095
-			if ($globalDebug) echo "Add to DB...";
2380
+			if ($globalDebug) {
2381
+				echo "Add to DB...";
2382
+			}
2096 2383
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2097
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2384
+		} else {
2385
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2386
+		}
2098 2387
 		if ($error != '') {
2099 2388
 			return $error;
2100
-		} elseif ($globalDebug) echo "Done\n";
2101
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2389
+		} elseif ($globalDebug) {
2390
+			echo "Done\n";
2391
+		}
2392
+		if ($globalDebug) {
2393
+			echo "Owner Czech Republic: Download...";
2394
+		}
2102 2395
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2103 2396
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2104
-			if ($globalDebug) echo "Add to DB...";
2397
+			if ($globalDebug) {
2398
+				echo "Add to DB...";
2399
+			}
2105 2400
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2106
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2401
+		} else {
2402
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2403
+		}
2107 2404
 		if ($error != '') {
2108 2405
 			return $error;
2109
-		} elseif ($globalDebug) echo "Done\n";
2110
-		if ($globalDebug) echo "Owner Australia: Download...";
2406
+		} elseif ($globalDebug) {
2407
+			echo "Done\n";
2408
+		}
2409
+		if ($globalDebug) {
2410
+			echo "Owner Australia: Download...";
2411
+		}
2111 2412
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2112 2413
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2113
-			if ($globalDebug) echo "Add to DB...";
2414
+			if ($globalDebug) {
2415
+				echo "Add to DB...";
2416
+			}
2114 2417
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2115
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2418
+		} else {
2419
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2420
+		}
2116 2421
 		if ($error != '') {
2117 2422
 			return $error;
2118
-		} elseif ($globalDebug) echo "Done\n";
2119
-		if ($globalDebug) echo "Owner Austria: Download...";
2423
+		} elseif ($globalDebug) {
2424
+			echo "Done\n";
2425
+		}
2426
+		if ($globalDebug) {
2427
+			echo "Owner Austria: Download...";
2428
+		}
2120 2429
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2121 2430
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2122
-			if ($globalDebug) echo "Add to DB...";
2431
+			if ($globalDebug) {
2432
+				echo "Add to DB...";
2433
+			}
2123 2434
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2124
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2435
+		} else {
2436
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2437
+		}
2125 2438
 		if ($error != '') {
2126 2439
 			return $error;
2127
-		} elseif ($globalDebug) echo "Done\n";
2128
-		if ($globalDebug) echo "Owner Chile: Download...";
2440
+		} elseif ($globalDebug) {
2441
+			echo "Done\n";
2442
+		}
2443
+		if ($globalDebug) {
2444
+			echo "Owner Chile: Download...";
2445
+		}
2129 2446
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2130 2447
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2131
-			if ($globalDebug) echo "Add to DB...";
2448
+			if ($globalDebug) {
2449
+				echo "Add to DB...";
2450
+			}
2132 2451
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2133
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2452
+		} else {
2453
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2454
+		}
2134 2455
 		if ($error != '') {
2135 2456
 			return $error;
2136
-		} elseif ($globalDebug) echo "Done\n";
2137
-		if ($globalDebug) echo "Owner Colombia: Download...";
2457
+		} elseif ($globalDebug) {
2458
+			echo "Done\n";
2459
+		}
2460
+		if ($globalDebug) {
2461
+			echo "Owner Colombia: Download...";
2462
+		}
2138 2463
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2139 2464
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2140
-			if ($globalDebug) echo "Add to DB...";
2465
+			if ($globalDebug) {
2466
+				echo "Add to DB...";
2467
+			}
2141 2468
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2142
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2469
+		} else {
2470
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2471
+		}
2143 2472
 		if ($error != '') {
2144 2473
 			return $error;
2145
-		} elseif ($globalDebug) echo "Done\n";
2146
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2474
+		} elseif ($globalDebug) {
2475
+			echo "Done\n";
2476
+		}
2477
+		if ($globalDebug) {
2478
+			echo "Owner Bosnia Herzegobina: Download...";
2479
+		}
2147 2480
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2148 2481
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2149
-			if ($globalDebug) echo "Add to DB...";
2482
+			if ($globalDebug) {
2483
+				echo "Add to DB...";
2484
+			}
2150 2485
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2151
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2486
+		} else {
2487
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2488
+		}
2152 2489
 		if ($error != '') {
2153 2490
 			return $error;
2154
-		} elseif ($globalDebug) echo "Done\n";
2155
-		if ($globalDebug) echo "Owner Brazil: Download...";
2491
+		} elseif ($globalDebug) {
2492
+			echo "Done\n";
2493
+		}
2494
+		if ($globalDebug) {
2495
+			echo "Owner Brazil: Download...";
2496
+		}
2156 2497
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2157 2498
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2158
-			if ($globalDebug) echo "Add to DB...";
2499
+			if ($globalDebug) {
2500
+				echo "Add to DB...";
2501
+			}
2159 2502
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2160
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2503
+		} else {
2504
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2505
+		}
2161 2506
 		if ($error != '') {
2162 2507
 			return $error;
2163
-		} elseif ($globalDebug) echo "Done\n";
2164
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2508
+		} elseif ($globalDebug) {
2509
+			echo "Done\n";
2510
+		}
2511
+		if ($globalDebug) {
2512
+			echo "Owner Cayman Islands: Download...";
2513
+		}
2165 2514
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2166 2515
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2167
-			if ($globalDebug) echo "Add to DB...";
2516
+			if ($globalDebug) {
2517
+				echo "Add to DB...";
2518
+			}
2168 2519
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2169
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2520
+		} else {
2521
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2522
+		}
2170 2523
 		if ($error != '') {
2171 2524
 			return $error;
2172
-		} elseif ($globalDebug) echo "Done\n";
2173
-		if ($globalDebug) echo "Owner Croatia: Download...";
2525
+		} elseif ($globalDebug) {
2526
+			echo "Done\n";
2527
+		}
2528
+		if ($globalDebug) {
2529
+			echo "Owner Croatia: Download...";
2530
+		}
2174 2531
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2175 2532
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2176
-			if ($globalDebug) echo "Add to DB...";
2533
+			if ($globalDebug) {
2534
+				echo "Add to DB...";
2535
+			}
2177 2536
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2178
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2537
+		} else {
2538
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2539
+		}
2179 2540
 		if ($error != '') {
2180 2541
 			return $error;
2181
-		} elseif ($globalDebug) echo "Done\n";
2182
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2542
+		} elseif ($globalDebug) {
2543
+			echo "Done\n";
2544
+		}
2545
+		if ($globalDebug) {
2546
+			echo "Owner Luxembourg: Download...";
2547
+		}
2183 2548
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2184 2549
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2185
-			if ($globalDebug) echo "Add to DB...";
2550
+			if ($globalDebug) {
2551
+				echo "Add to DB...";
2552
+			}
2186 2553
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2187
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2554
+		} else {
2555
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2556
+		}
2188 2557
 		if ($error != '') {
2189 2558
 			return $error;
2190
-		} elseif ($globalDebug) echo "Done\n";
2191
-		if ($globalDebug) echo "Owner Maldives: Download...";
2559
+		} elseif ($globalDebug) {
2560
+			echo "Done\n";
2561
+		}
2562
+		if ($globalDebug) {
2563
+			echo "Owner Maldives: Download...";
2564
+		}
2192 2565
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2193 2566
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2194
-			if ($globalDebug) echo "Add to DB...";
2567
+			if ($globalDebug) {
2568
+				echo "Add to DB...";
2569
+			}
2195 2570
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2196
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2571
+		} else {
2572
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2573
+		}
2197 2574
 		if ($error != '') {
2198 2575
 			return $error;
2199
-		} elseif ($globalDebug) echo "Done\n";
2200
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2576
+		} elseif ($globalDebug) {
2577
+			echo "Done\n";
2578
+		}
2579
+		if ($globalDebug) {
2580
+			echo "Owner New Zealand: Download...";
2581
+		}
2201 2582
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2202 2583
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2203
-			if ($globalDebug) echo "Add to DB...";
2584
+			if ($globalDebug) {
2585
+				echo "Add to DB...";
2586
+			}
2204 2587
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2205
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2588
+		} else {
2589
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2590
+		}
2206 2591
 		if ($error != '') {
2207 2592
 			return $error;
2208
-		} elseif ($globalDebug) echo "Done\n";
2209
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2593
+		} elseif ($globalDebug) {
2594
+			echo "Done\n";
2595
+		}
2596
+		if ($globalDebug) {
2597
+			echo "Owner Papua New Guinea: Download...";
2598
+		}
2210 2599
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2211 2600
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2212
-			if ($globalDebug) echo "Add to DB...";
2601
+			if ($globalDebug) {
2602
+				echo "Add to DB...";
2603
+			}
2213 2604
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2214
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2605
+		} else {
2606
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2607
+		}
2215 2608
 		if ($error != '') {
2216 2609
 			return $error;
2217
-		} elseif ($globalDebug) echo "Done\n";
2218
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2610
+		} elseif ($globalDebug) {
2611
+			echo "Done\n";
2612
+		}
2613
+		if ($globalDebug) {
2614
+			echo "Owner Slovakia: Download...";
2615
+		}
2219 2616
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2220 2617
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2221
-			if ($globalDebug) echo "Add to DB...";
2618
+			if ($globalDebug) {
2619
+				echo "Add to DB...";
2620
+			}
2222 2621
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2223
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2622
+		} else {
2623
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2624
+		}
2224 2625
 		if ($error != '') {
2225 2626
 			return $error;
2226
-		} elseif ($globalDebug) echo "Done\n";
2227
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2627
+		} elseif ($globalDebug) {
2628
+			echo "Done\n";
2629
+		}
2630
+		if ($globalDebug) {
2631
+			echo "Owner Ecuador: Download...";
2632
+		}
2228 2633
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2229 2634
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2230
-			if ($globalDebug) echo "Add to DB...";
2635
+			if ($globalDebug) {
2636
+				echo "Add to DB...";
2637
+			}
2231 2638
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2232
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2639
+		} else {
2640
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2641
+		}
2233 2642
 		if ($error != '') {
2234 2643
 			return $error;
2235
-		} elseif ($globalDebug) echo "Done\n";
2236
-		if ($globalDebug) echo "Owner Iceland: Download...";
2644
+		} elseif ($globalDebug) {
2645
+			echo "Done\n";
2646
+		}
2647
+		if ($globalDebug) {
2648
+			echo "Owner Iceland: Download...";
2649
+		}
2237 2650
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2238 2651
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2239
-			if ($globalDebug) echo "Add to DB...";
2652
+			if ($globalDebug) {
2653
+				echo "Add to DB...";
2654
+			}
2240 2655
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2241
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2656
+		} else {
2657
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2658
+		}
2242 2659
 		if ($error != '') {
2243 2660
 			return $error;
2244
-		} elseif ($globalDebug) echo "Done\n";
2245
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2661
+		} elseif ($globalDebug) {
2662
+			echo "Done\n";
2663
+		}
2664
+		if ($globalDebug) {
2665
+			echo "Owner Isle of Man: Download...";
2666
+		}
2246 2667
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2247 2668
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2248
-			if ($globalDebug) echo "Add to DB...";
2669
+			if ($globalDebug) {
2670
+				echo "Add to DB...";
2671
+			}
2249 2672
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2250
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2673
+		} else {
2674
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2675
+		}
2251 2676
 		if ($error != '') {
2252 2677
 			return $error;
2253
-		} elseif ($globalDebug) echo "Done\n";
2678
+		} elseif ($globalDebug) {
2679
+			echo "Done\n";
2680
+		}
2254 2681
 		if ($globalMasterSource) {
2255
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2682
+			if ($globalDebug) {
2683
+				echo "ModeS Netherlands: Download...";
2684
+			}
2256 2685
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2257 2686
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2258
-				if ($globalDebug) echo "Add to DB...";
2687
+				if ($globalDebug) {
2688
+					echo "Add to DB...";
2689
+				}
2259 2690
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2260
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2691
+			} else {
2692
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2693
+			}
2261 2694
 			if ($error != '') {
2262 2695
 				return $error;
2263
-			} elseif ($globalDebug) echo "Done\n";
2264
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2696
+			} elseif ($globalDebug) {
2697
+				echo "Done\n";
2698
+			}
2699
+			if ($globalDebug) {
2700
+				echo "ModeS Denmark: Download...";
2701
+			}
2265 2702
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2266 2703
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2267
-				if ($globalDebug) echo "Add to DB...";
2704
+				if ($globalDebug) {
2705
+					echo "Add to DB...";
2706
+				}
2268 2707
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2269
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2708
+			} else {
2709
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2710
+			}
2270 2711
 			if ($error != '') {
2271 2712
 				return $error;
2272
-			} elseif ($globalDebug) echo "Done\n";
2273
-		} elseif ($globalDebug) echo "Done\n";
2713
+			} elseif ($globalDebug) {
2714
+				echo "Done\n";
2715
+			}
2716
+		} elseif ($globalDebug) {
2717
+			echo "Done\n";
2718
+		}
2274 2719
 		return '';
2275 2720
 	}
2276 2721
 
2277 2722
 	public static function update_translation() {
2278 2723
 		global $tmp_dir, $globalDebug;
2279 2724
 		$error = '';
2280
-		if ($globalDebug) echo "Translation : Download...";
2725
+		if ($globalDebug) {
2726
+			echo "Translation : Download...";
2727
+		}
2281 2728
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2282 2729
 		if (file_exists($tmp_dir.'translation.zip')) {
2283
-			if ($globalDebug) echo "Unzip...";
2730
+			if ($globalDebug) {
2731
+				echo "Unzip...";
2732
+			}
2284 2733
 			update_db::unzip($tmp_dir.'translation.zip');
2285
-			if ($globalDebug) echo "Add to DB...";
2734
+			if ($globalDebug) {
2735
+				echo "Add to DB...";
2736
+			}
2286 2737
 			$error = update_db::translation();
2287
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2738
+		} else {
2739
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2740
+		}
2288 2741
 		if ($error != '') {
2289 2742
 			return $error;
2290
-		} elseif ($globalDebug) echo "Done\n";
2743
+		} elseif ($globalDebug) {
2744
+			echo "Done\n";
2745
+		}
2291 2746
 		return '';
2292 2747
 	}
2293 2748
 
2294 2749
 	public static function update_translation_fam() {
2295 2750
 		global $tmp_dir, $globalDebug;
2296
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2751
+		if ($globalDebug) {
2752
+			echo "Translation from FlightAirMap website : Download...";
2753
+		}
2297 2754
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2298 2755
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
2299
-			if ($globalDebug) echo "Gunzip...";
2756
+			if ($globalDebug) {
2757
+				echo "Gunzip...";
2758
+			}
2300 2759
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
2301
-			if ($globalDebug) echo "Add to DB...";
2760
+			if ($globalDebug) {
2761
+				echo "Add to DB...";
2762
+			}
2302 2763
 			$error = update_db::translation_fam();
2303
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2764
+		} else {
2765
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2766
+		}
2304 2767
 		if ($error != '') {
2305 2768
 			return $error;
2306
-		} elseif ($globalDebug) echo "Done\n";
2769
+		} elseif ($globalDebug) {
2770
+			echo "Done\n";
2771
+		}
2307 2772
 		return '';
2308 2773
 	}
2309 2774
 	public static function update_ModeS_fam() {
2310 2775
 		global $tmp_dir, $globalDebug;
2311
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2776
+		if ($globalDebug) {
2777
+			echo "ModeS from FlightAirMap website : Download...";
2778
+		}
2312 2779
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2313 2780
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
2314
-			if ($globalDebug) echo "Gunzip...";
2781
+			if ($globalDebug) {
2782
+				echo "Gunzip...";
2783
+			}
2315 2784
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
2316
-			if ($globalDebug) echo "Add to DB...";
2785
+			if ($globalDebug) {
2786
+				echo "Add to DB...";
2787
+			}
2317 2788
 			$error = update_db::modes_fam();
2318
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2789
+		} else {
2790
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2791
+		}
2319 2792
 		if ($error != '') {
2320 2793
 			return $error;
2321
-		} elseif ($globalDebug) echo "Done\n";
2794
+		} elseif ($globalDebug) {
2795
+			echo "Done\n";
2796
+		}
2322 2797
 		return '';
2323 2798
 	}
2324 2799
 	public static function update_owner_fam() {
2325 2800
 		global $tmp_dir, $globalDebug, $globalOwner;
2326
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2801
+		if ($globalDebug) {
2802
+			echo "owner from FlightAirMap website : Download...";
2803
+		}
2327 2804
 		if ($globalOwner === TRUE) {
2328 2805
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2329 2806
 		} else {
2330 2807
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2331 2808
 		}
2332 2809
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2333
-			if ($globalDebug) echo "Gunzip...";
2810
+			if ($globalDebug) {
2811
+				echo "Gunzip...";
2812
+			}
2334 2813
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
2335
-			if ($globalDebug) echo "Add to DB...";
2814
+			if ($globalDebug) {
2815
+				echo "Add to DB...";
2816
+			}
2336 2817
 			$error = update_db::owner_fam();
2337
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2818
+		} else {
2819
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2820
+		}
2338 2821
 		if ($error != '') {
2339 2822
 			return $error;
2340
-		} elseif ($globalDebug) echo "Done\n";
2823
+		} elseif ($globalDebug) {
2824
+			echo "Done\n";
2825
+		}
2341 2826
 		return '';
2342 2827
 	}
2343 2828
 	public static function update_routes_fam() {
2344 2829
 		global $tmp_dir, $globalDebug;
2345
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2830
+		if ($globalDebug) {
2831
+			echo "Routes from FlightAirMap website : Download...";
2832
+		}
2346 2833
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2347 2834
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2348
-			if ($globalDebug) echo "Gunzip...";
2835
+			if ($globalDebug) {
2836
+				echo "Gunzip...";
2837
+			}
2349 2838
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
2350
-			if ($globalDebug) echo "Add to DB...";
2839
+			if ($globalDebug) {
2840
+				echo "Add to DB...";
2841
+			}
2351 2842
 			$error = update_db::routes_fam();
2352
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2843
+		} else {
2844
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2845
+		}
2353 2846
 		if ($error != '') {
2354 2847
 			return $error;
2355
-		} elseif ($globalDebug) echo "Done\n";
2848
+		} elseif ($globalDebug) {
2849
+			echo "Done\n";
2850
+		}
2356 2851
 		return '';
2357 2852
 	}
2358 2853
 	public static function update_marine_identity_fam() {
@@ -2362,14 +2857,22 @@  discard block
 block discarded – undo
2362 2857
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2363 2858
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2364 2859
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2365
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2860
+				if ($globalDebug) {
2861
+					echo "Marine identity from FlightAirMap website : Download...";
2862
+				}
2366 2863
 				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2367 2864
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2368
-					if ($globalDebug) echo "Gunzip...";
2865
+					if ($globalDebug) {
2866
+						echo "Gunzip...";
2867
+					}
2369 2868
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2370
-					if ($globalDebug) echo "Add to DB...";
2869
+					if ($globalDebug) {
2870
+						echo "Add to DB...";
2871
+					}
2371 2872
 					$error = update_db::marine_identity_fam();
2372
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2873
+				} else {
2874
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2875
+				}
2373 2876
 				if ($error != '') {
2374 2877
 					return $error;
2375 2878
 				} elseif ($globalDebug) {
@@ -2388,14 +2891,22 @@  discard block
 block discarded – undo
2388 2891
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2389 2892
 			$satellite_md5 = $satellite_md5_file[0];
2390 2893
 			if (!update_db::check_satellite_version($satellite_md5)) {
2391
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2894
+				if ($globalDebug) {
2895
+					echo "Satellite from FlightAirMap website : Download...";
2896
+				}
2392 2897
 				update_db::download('http://data.flightairmap.fr/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2393 2898
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2394
-					if ($globalDebug) echo "Gunzip...";
2899
+					if ($globalDebug) {
2900
+						echo "Gunzip...";
2901
+					}
2395 2902
 					update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2396
-					if ($globalDebug) echo "Add to DB...";
2903
+					if ($globalDebug) {
2904
+						echo "Add to DB...";
2905
+					}
2397 2906
 					$error = update_db::satellite_fam();
2398
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
2907
+				} else {
2908
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
2909
+				}
2399 2910
 				if ($error != '') {
2400 2911
 					return $error;
2401 2912
 				} elseif ($globalDebug) {
@@ -2408,17 +2919,25 @@  discard block
 block discarded – undo
2408 2919
 	}
2409 2920
 	public static function update_banned_fam() {
2410 2921
 		global $tmp_dir, $globalDebug;
2411
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2922
+		if ($globalDebug) {
2923
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2924
+		}
2412 2925
 		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2413 2926
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2414 2927
 			//if ($globalDebug) echo "Gunzip...";
2415 2928
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2416
-			if ($globalDebug) echo "Add to DB...";
2929
+			if ($globalDebug) {
2930
+				echo "Add to DB...";
2931
+			}
2417 2932
 			$error = update_db::banned_fam();
2418
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2933
+		} else {
2934
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2935
+		}
2419 2936
 		if ($error != '') {
2420 2937
 			return $error;
2421
-		} elseif ($globalDebug) echo "Done\n";
2938
+		} elseif ($globalDebug) {
2939
+			echo "Done\n";
2940
+		}
2422 2941
 		return '';
2423 2942
 	}
2424 2943
 
@@ -2426,7 +2945,9 @@  discard block
 block discarded – undo
2426 2945
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2427 2946
 		include_once('class.create_db.php');
2428 2947
 		$error = '';
2429
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2948
+		if ($globalDebug) {
2949
+			echo "Airspace from FlightAirMap website : Download...";
2950
+		}
2430 2951
 		if ($globalDBdriver == 'mysql') {
2431 2952
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2432 2953
 		} else {
@@ -2442,9 +2963,13 @@  discard block
 block discarded – undo
2442 2963
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2443 2964
 				}
2444 2965
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2445
-					if ($globalDebug) echo "Gunzip...";
2966
+					if ($globalDebug) {
2967
+						echo "Gunzip...";
2968
+					}
2446 2969
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
2447
-					if ($globalDebug) echo "Add to DB...";
2970
+					if ($globalDebug) {
2971
+						echo "Add to DB...";
2972
+					}
2448 2973
 					$Connection = new Connection();
2449 2974
 					if ($Connection->tableExists('airspace')) {
2450 2975
 						$query = 'DROP TABLE airspace';
@@ -2457,19 +2982,27 @@  discard block
 block discarded – undo
2457 2982
 		    			}
2458 2983
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2459 2984
 					update_db::insert_airspace_version($airspace_md5);
2460
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2985
+				} else {
2986
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2987
+				}
2461 2988
 			}
2462
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2989
+		} else {
2990
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2991
+		}
2463 2992
 		if ($error != '') {
2464 2993
 			return $error;
2465
-		} elseif ($globalDebug) echo "Done\n";
2994
+		} elseif ($globalDebug) {
2995
+			echo "Done\n";
2996
+		}
2466 2997
 		return '';
2467 2998
 	}
2468 2999
 
2469 3000
 	public static function update_geoid_fam() {
2470 3001
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2471 3002
 		$error = '';
2472
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3003
+		if ($globalDebug) {
3004
+			echo "Geoid from FlightAirMap website : Download...";
3005
+		}
2473 3006
 		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2474 3007
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2475 3008
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2477,75 +3010,113 @@  discard block
 block discarded – undo
2477 3010
 			if (!update_db::check_geoid_version($geoid_md5)) {
2478 3011
 				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2479 3012
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2480
-					if ($globalDebug) echo "Gunzip...";
3013
+					if ($globalDebug) {
3014
+						echo "Gunzip...";
3015
+					}
2481 3016
 					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2482 3017
 					if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2483 3018
 						update_db::insert_geoid_version($geoid_md5);
2484 3019
 					}
2485
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3020
+				} else {
3021
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3022
+				}
2486 3023
 			}
2487
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3024
+		} else {
3025
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3026
+		}
2488 3027
 		if ($error != '') {
2489 3028
 			return $error;
2490
-		} elseif ($globalDebug) echo "Done\n";
3029
+		} elseif ($globalDebug) {
3030
+			echo "Done\n";
3031
+		}
2491 3032
 		return '';
2492 3033
 	}
2493 3034
 
2494 3035
 	public static function update_tle() {
2495 3036
 		global $tmp_dir, $globalDebug;
2496
-		if ($globalDebug) echo "Download TLE : Download...";
3037
+		if ($globalDebug) {
3038
+			echo "Download TLE : Download...";
3039
+		}
2497 3040
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2498 3041
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2499 3042
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2500 3043
 		foreach ($alltle as $filename) {
2501
-			if ($globalDebug) echo "downloading ".$filename.'...';
3044
+			if ($globalDebug) {
3045
+				echo "downloading ".$filename.'...';
3046
+			}
2502 3047
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2503 3048
 			if (file_exists($tmp_dir.$filename)) {
2504
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3049
+				if ($globalDebug) {
3050
+					echo "Add to DB ".$filename."...";
3051
+				}
2505 3052
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2506
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3053
+			} else {
3054
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3055
+			}
2507 3056
 			if ($error != '') {
2508 3057
 				echo $error."\n";
2509
-			} elseif ($globalDebug) echo "Done\n";
3058
+			} elseif ($globalDebug) {
3059
+				echo "Done\n";
3060
+			}
2510 3061
 		}
2511 3062
 		return '';
2512 3063
 	}
2513 3064
 
2514 3065
 	public static function update_ucsdb() {
2515 3066
 		global $tmp_dir, $globalDebug;
2516
-		if ($globalDebug) echo "Download UCS DB : Download...";
3067
+		if ($globalDebug) {
3068
+			echo "Download UCS DB : Download...";
3069
+		}
2517 3070
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2518 3071
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2519
-			if ($globalDebug) echo "Add to DB...";
3072
+			if ($globalDebug) {
3073
+				echo "Add to DB...";
3074
+			}
2520 3075
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2521
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3076
+		} else {
3077
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3078
+		}
2522 3079
 		if ($error != '') {
2523 3080
 			echo $error."\n";
2524
-		} elseif ($globalDebug) echo "Done\n";
3081
+		} elseif ($globalDebug) {
3082
+			echo "Done\n";
3083
+		}
2525 3084
 		return '';
2526 3085
 	}
2527 3086
 
2528 3087
 	public static function update_celestrak() {
2529 3088
 		global $tmp_dir, $globalDebug;
2530
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3089
+		if ($globalDebug) {
3090
+			echo "Download Celestrak DB : Download...";
3091
+		}
2531 3092
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2532 3093
 		if (file_exists($tmp_dir.'satcat.txt')) {
2533
-			if ($globalDebug) echo "Add to DB...";
3094
+			if ($globalDebug) {
3095
+				echo "Add to DB...";
3096
+			}
2534 3097
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2535
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3098
+		} else {
3099
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3100
+		}
2536 3101
 		if ($error != '') {
2537 3102
 			echo $error."\n";
2538
-		} elseif ($globalDebug) echo "Done\n";
3103
+		} elseif ($globalDebug) {
3104
+			echo "Done\n";
3105
+		}
2539 3106
 		return '';
2540 3107
 	}
2541 3108
 
2542 3109
 	public static function update_models() {
2543 3110
 		global $tmp_dir, $globalDebug;
2544 3111
 		$error = '';
2545
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3112
+		if ($globalDebug) {
3113
+			echo "Models from FlightAirMap website : Download...";
3114
+		}
2546 3115
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2547 3116
 		if (file_exists($tmp_dir.'models.md5sum')) {
2548
-			if ($globalDebug) echo "Check files...\n";
3117
+			if ($globalDebug) {
3118
+				echo "Check files...\n";
3119
+			}
2549 3120
 			$newmodelsdb = array();
2550 3121
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2551 3122
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2564,25 +3135,35 @@  discard block
 block discarded – undo
2564 3135
 			}
2565 3136
 			$diff = array_diff($newmodelsdb,$modelsdb);
2566 3137
 			foreach ($diff as $key => $value) {
2567
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3138
+				if ($globalDebug) {
3139
+					echo 'Downloading model '.$key.' ...'."\n";
3140
+				}
2568 3141
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2569 3142
 				
2570 3143
 			}
2571 3144
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2572
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3145
+		} else {
3146
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3147
+		}
2573 3148
 		if ($error != '') {
2574 3149
 			return $error;
2575
-		} elseif ($globalDebug) echo "Done\n";
3150
+		} elseif ($globalDebug) {
3151
+			echo "Done\n";
3152
+		}
2576 3153
 		return '';
2577 3154
 	}
2578 3155
 
2579 3156
 	public static function update_space_models() {
2580 3157
 		global $tmp_dir, $globalDebug;
2581 3158
 		$error = '';
2582
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3159
+		if ($globalDebug) {
3160
+			echo "Space models from FlightAirMap website : Download...";
3161
+		}
2583 3162
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2584 3163
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2585
-			if ($globalDebug) echo "Check files...\n";
3164
+			if ($globalDebug) {
3165
+				echo "Check files...\n";
3166
+			}
2586 3167
 			$newmodelsdb = array();
2587 3168
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2588 3169
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2601,25 +3182,35 @@  discard block
 block discarded – undo
2601 3182
 			}
2602 3183
 			$diff = array_diff($newmodelsdb,$modelsdb);
2603 3184
 			foreach ($diff as $key => $value) {
2604
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3185
+				if ($globalDebug) {
3186
+					echo 'Downloading space model '.$key.' ...'."\n";
3187
+				}
2605 3188
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2606 3189
 				
2607 3190
 			}
2608 3191
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2609
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3192
+		} else {
3193
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3194
+		}
2610 3195
 		if ($error != '') {
2611 3196
 			return $error;
2612
-		} elseif ($globalDebug) echo "Done\n";
3197
+		} elseif ($globalDebug) {
3198
+			echo "Done\n";
3199
+		}
2613 3200
 		return '';
2614 3201
 	}
2615 3202
 
2616 3203
 	public static function update_vehicules_models() {
2617 3204
 		global $tmp_dir, $globalDebug;
2618 3205
 		$error = '';
2619
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3206
+		if ($globalDebug) {
3207
+			echo "Vehicules models from FlightAirMap website : Download...";
3208
+		}
2620 3209
 		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2621 3210
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2622
-			if ($globalDebug) echo "Check files...\n";
3211
+			if ($globalDebug) {
3212
+				echo "Check files...\n";
3213
+			}
2623 3214
 			$newmodelsdb = array();
2624 3215
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2625 3216
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2638,15 +3229,21 @@  discard block
 block discarded – undo
2638 3229
 			}
2639 3230
 			$diff = array_diff($newmodelsdb,$modelsdb);
2640 3231
 			foreach ($diff as $key => $value) {
2641
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3232
+				if ($globalDebug) {
3233
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3234
+				}
2642 3235
 				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2643 3236
 				
2644 3237
 			}
2645 3238
 			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2646
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3239
+		} else {
3240
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3241
+		}
2647 3242
 		if ($error != '') {
2648 3243
 			return $error;
2649
-		} elseif ($globalDebug) echo "Done\n";
3244
+		} elseif ($globalDebug) {
3245
+			echo "Done\n";
3246
+		}
2650 3247
 		return '';
2651 3248
 	}
2652 3249
 
@@ -2689,7 +3286,9 @@  discard block
 block discarded – undo
2689 3286
                 }
2690 3287
 
2691 3288
 		$error = '';
2692
-		if ($globalDebug) echo "Notam : Download...";
3289
+		if ($globalDebug) {
3290
+			echo "Notam : Download...";
3291
+		}
2693 3292
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2694 3293
 		if (file_exists($tmp_dir.'notam.rss')) {
2695 3294
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2704,14 +3303,30 @@  discard block
 block discarded – undo
2704 3303
 				$data['fir'] = $q[0];
2705 3304
 				$data['code'] = $q[1];
2706 3305
 				$ifrvfr = $q[2];
2707
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2708
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2709
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2710
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2711
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2712
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2713
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2714
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3306
+				if ($ifrvfr == 'IV') {
3307
+					$data['rules'] = 'IFR/VFR';
3308
+				}
3309
+				if ($ifrvfr == 'I') {
3310
+					$data['rules'] = 'IFR';
3311
+				}
3312
+				if ($ifrvfr == 'V') {
3313
+					$data['rules'] = 'VFR';
3314
+				}
3315
+				if ($q[4] == 'A') {
3316
+					$data['scope'] = 'Airport warning';
3317
+				}
3318
+				if ($q[4] == 'E') {
3319
+					$data['scope'] = 'Enroute warning';
3320
+				}
3321
+				if ($q[4] == 'W') {
3322
+					$data['scope'] = 'Navigation warning';
3323
+				}
3324
+				if ($q[4] == 'AE') {
3325
+					$data['scope'] = 'Airport/Enroute warning';
3326
+				}
3327
+				if ($q[4] == 'AW') {
3328
+					$data['scope'] = 'Airport/Navigation warning';
3329
+				}
2715 3330
 				//$data['scope'] = $q[4];
2716 3331
 				$data['lower_limit'] = $q[5];
2717 3332
 				$data['upper_limit'] = $q[6];
@@ -2719,8 +3334,12 @@  discard block
 block discarded – undo
2719 3334
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2720 3335
 				$latitude = $Common->convertDec($las,'latitude');
2721 3336
 				$longitude = $Common->convertDec($lns,'longitude');
2722
-				if ($lac == 'S') $latitude = '-'.$latitude;
2723
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3337
+				if ($lac == 'S') {
3338
+					$latitude = '-'.$latitude;
3339
+				}
3340
+				if ($lnc == 'W') {
3341
+					$longitude = '-'.$longitude;
3342
+				}
2724 3343
 				$data['center_latitude'] = $latitude;
2725 3344
 				$data['center_longitude'] = $longitude;
2726 3345
 				$data['radius'] = intval($radius);
@@ -2750,10 +3369,14 @@  discard block
 block discarded – undo
2750 3369
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2751 3370
 				unset($data);
2752 3371
 			} 
2753
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3372
+		} else {
3373
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3374
+		}
2754 3375
 		if ($error != '') {
2755 3376
 			return $error;
2756
-		} elseif ($globalDebug) echo "Done\n";
3377
+		} elseif ($globalDebug) {
3378
+			echo "Done\n";
3379
+		}
2757 3380
 		return '';
2758 3381
 	}
2759 3382
 	
@@ -2778,7 +3401,9 @@  discard block
 block discarded – undo
2778 3401
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2779 3402
 		$airspace_json = json_decode($airspace_lst,true);
2780 3403
 		foreach ($airspace_json['records'] as $airspace) {
2781
-			if ($globalDebug) echo $airspace['name']."...\n";
3404
+			if ($globalDebug) {
3405
+				echo $airspace['name']."...\n";
3406
+			}
2782 3407
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2783 3408
 			if (file_exists($tmp_dir.$airspace['name'])) {
2784 3409
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2822,8 +3447,11 @@  discard block
 block discarded – undo
2822 3447
                         return "error : ".$e->getMessage();
2823 3448
                 }
2824 3449
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2825
-                if ($row['nb'] > 0) return false;
2826
-                else return true;
3450
+                if ($row['nb'] > 0) {
3451
+                	return false;
3452
+                } else {
3453
+                	return true;
3454
+                }
2827 3455
 	}
2828 3456
 
2829 3457
 	public static function insert_last_update() {
@@ -2848,8 +3476,11 @@  discard block
 block discarded – undo
2848 3476
                         return "error : ".$e->getMessage();
2849 3477
                 }
2850 3478
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2851
-                if ($row['nb'] > 0) return true;
2852
-                else return false;
3479
+                if ($row['nb'] > 0) {
3480
+                	return true;
3481
+                } else {
3482
+                	return false;
3483
+                }
2853 3484
 	}
2854 3485
 
2855 3486
 	public static function check_geoid_version($version) {
@@ -2862,8 +3493,11 @@  discard block
 block discarded – undo
2862 3493
                         return "error : ".$e->getMessage();
2863 3494
                 }
2864 3495
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2865
-                if ($row['nb'] > 0) return true;
2866
-                else return false;
3496
+                if ($row['nb'] > 0) {
3497
+                	return true;
3498
+                } else {
3499
+                	return false;
3500
+                }
2867 3501
 	}
2868 3502
 
2869 3503
 	public static function check_marine_identity_version($version) {
@@ -2876,8 +3510,11 @@  discard block
 block discarded – undo
2876 3510
 			return "error : ".$e->getMessage();
2877 3511
 		}
2878 3512
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2879
-		if ($row['nb'] > 0) return true;
2880
-		else return false;
3513
+		if ($row['nb'] > 0) {
3514
+			return true;
3515
+		} else {
3516
+			return false;
3517
+		}
2881 3518
 	}
2882 3519
 
2883 3520
 	public static function check_satellite_version($version) {
@@ -2890,8 +3527,11 @@  discard block
 block discarded – undo
2890 3527
 			return "error : ".$e->getMessage();
2891 3528
 		}
2892 3529
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2893
-		if ($row['nb'] > 0) return true;
2894
-		else return false;
3530
+		if ($row['nb'] > 0) {
3531
+			return true;
3532
+		} else {
3533
+			return false;
3534
+		}
2895 3535
 	}
2896 3536
 
2897 3537
 
@@ -2958,8 +3598,11 @@  discard block
 block discarded – undo
2958 3598
                         return "error : ".$e->getMessage();
2959 3599
                 }
2960 3600
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2961
-                if ($row['nb'] > 0) return false;
2962
-                else return true;
3601
+                if ($row['nb'] > 0) {
3602
+                	return false;
3603
+                } else {
3604
+                	return true;
3605
+                }
2963 3606
 	}
2964 3607
 
2965 3608
 	public static function insert_last_notam_update() {
@@ -2989,8 +3632,11 @@  discard block
 block discarded – undo
2989 3632
                         return "error : ".$e->getMessage();
2990 3633
                 }
2991 3634
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2992
-                if ($row['nb'] > 0) return false;
2993
-                else return true;
3635
+                if ($row['nb'] > 0) {
3636
+                	return false;
3637
+                } else {
3638
+                	return true;
3639
+                }
2994 3640
 	}
2995 3641
 
2996 3642
 	public static function insert_last_airspace_update() {
@@ -3020,8 +3666,11 @@  discard block
 block discarded – undo
3020 3666
                         return "error : ".$e->getMessage();
3021 3667
                 }
3022 3668
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3023
-                if ($row['nb'] > 0) return false;
3024
-                else return true;
3669
+                if ($row['nb'] > 0) {
3670
+                	return false;
3671
+                } else {
3672
+                	return true;
3673
+                }
3025 3674
 	}
3026 3675
 
3027 3676
 	public static function insert_last_geoid_update() {
@@ -3051,8 +3700,11 @@  discard block
 block discarded – undo
3051 3700
                         return "error : ".$e->getMessage();
3052 3701
                 }
3053 3702
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3054
-                if ($row['nb'] > 0) return false;
3055
-                else return true;
3703
+                if ($row['nb'] > 0) {
3704
+                	return false;
3705
+                } else {
3706
+                	return true;
3707
+                }
3056 3708
 	}
3057 3709
 
3058 3710
 	public static function insert_last_owner_update() {
@@ -3081,8 +3733,11 @@  discard block
 block discarded – undo
3081 3733
                         return "error : ".$e->getMessage();
3082 3734
                 }
3083 3735
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3084
-                if ($row['nb'] > 0) return false;
3085
-                else return true;
3736
+                if ($row['nb'] > 0) {
3737
+                	return false;
3738
+                } else {
3739
+                	return true;
3740
+                }
3086 3741
 	}
3087 3742
 
3088 3743
 	public static function insert_last_schedules_update() {
@@ -3112,8 +3767,11 @@  discard block
 block discarded – undo
3112 3767
 			return "error : ".$e->getMessage();
3113 3768
 		}
3114 3769
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3115
-		if ($row['nb'] > 0) return false;
3116
-		else return true;
3770
+		if ($row['nb'] > 0) {
3771
+			return false;
3772
+		} else {
3773
+			return true;
3774
+		}
3117 3775
 	}
3118 3776
 
3119 3777
 	public static function insert_last_tle_update() {
@@ -3143,8 +3801,11 @@  discard block
 block discarded – undo
3143 3801
 			return "error : ".$e->getMessage();
3144 3802
 		}
3145 3803
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3146
-		if ($row['nb'] > 0) return false;
3147
-		else return true;
3804
+		if ($row['nb'] > 0) {
3805
+			return false;
3806
+		} else {
3807
+			return true;
3808
+		}
3148 3809
 	}
3149 3810
 
3150 3811
 	public static function insert_last_ucsdb_update() {
@@ -3174,8 +3835,11 @@  discard block
 block discarded – undo
3174 3835
 			return "error : ".$e->getMessage();
3175 3836
 		}
3176 3837
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3177
-		if ($row['nb'] > 0) return false;
3178
-		else return true;
3838
+		if ($row['nb'] > 0) {
3839
+			return false;
3840
+		} else {
3841
+			return true;
3842
+		}
3179 3843
 	}
3180 3844
 
3181 3845
 	public static function insert_last_celestrak_update() {
@@ -3205,8 +3869,11 @@  discard block
 block discarded – undo
3205 3869
 			return "error : ".$e->getMessage();
3206 3870
 		}
3207 3871
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3208
-		if ($row['nb'] > 0) return false;
3209
-		else return true;
3872
+		if ($row['nb'] > 0) {
3873
+			return false;
3874
+		} else {
3875
+			return true;
3876
+		}
3210 3877
 	}
3211 3878
 
3212 3879
 	public static function check_last_satellite_update() {
@@ -3224,8 +3891,11 @@  discard block
 block discarded – undo
3224 3891
 			return "error : ".$e->getMessage();
3225 3892
 		}
3226 3893
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3227
-		if ($row['nb'] > 0) return false;
3228
-		else return true;
3894
+		if ($row['nb'] > 0) {
3895
+			return false;
3896
+		} else {
3897
+			return true;
3898
+		}
3229 3899
 	}
3230 3900
 
3231 3901
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
statistics.php 1 patch
Braces   +169 added lines, -80 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@  discard block
 block discarded – undo
22 22
 	require_once('require/class.Spotter.php');
23 23
 }
24 24
 
25
-if (!isset($filter_name)) $filter_name = '';
25
+if (!isset($filter_name)) {
26
+	$filter_name = '';
27
+}
26 28
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 29
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
-}
30
+	if (isset($globalFilter['airline'])) {
31
+		$airline_icao = $globalFilter['airline'][0];
32
+	}
33
+	}
30 34
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 35
 	$Spotter = new Spotter();
32 36
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -69,7 +78,9 @@  discard block
 block discarded – undo
69 78
 	if (isset($last_update[0]['value'])) {
70 79
 		date_default_timezone_set('UTC');
71 80
 		$lastupdate = strtotime($last_update[0]['value']);
72
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
81
+		if (isset($globalTimezone) && $globalTimezone != '') {
82
+			date_default_timezone_set($globalTimezone);
83
+		}
73 84
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
74 85
 	}
75 86
 }
@@ -154,8 +165,11 @@  discard block
 block discarded – undo
154 165
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
155 166
 		$aircraft_data = '';
156 167
 		foreach($aircraft_array as $aircraft_item) {
157
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
158
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
168
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
169
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
170
+			} else {
171
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			}
159 173
 		}
160 174
 		$aircraft_data = substr($aircraft_data, 0, -1);
161 175
 		print 'var series = ['.$aircraft_data.'];';
@@ -172,11 +186,17 @@  discard block
 block discarded – undo
172 186
 <?php
173 187
 	if ($year != '' && $month != '') {
174 188
 ?>
175
-            	    <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>
189
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
190
+	echo '/'.$airline_icao;
191
+}
192
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
176 193
 <?php
177 194
 	} else {
178 195
 ?>
179
-            	    <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>
196
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
197
+	echo '/'.$airline_icao;
198
+}
199
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 200
 <?php
181 201
 	}
182 202
 ?>
@@ -205,11 +225,15 @@  discard block
 block discarded – undo
205 225
 			print '</script>';
206 226
 			if ($year != '' && $month != '') {
207 227
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
208
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
228
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
229
+					echo '/'.$airline_icao;
230
+				}
209 231
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
210 232
 			} else {
211 233
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
234
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
235
+					echo '/'.$airline_icao;
236
+				}
213 237
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 238
 			}
215 239
 			print '</div>';
@@ -229,8 +253,9 @@  discard block
 block discarded – undo
229 253
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
230 254
 <?php
231 255
 	$marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
232
-	if (count($marine_array) == 0) print _("No data available");
233
-	else {
256
+	if (count($marine_array) == 0) {
257
+		print _("No data available");
258
+	} else {
234 259
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
235 260
 		$marine_data = '';
236 261
 		foreach($marine_array as $marine_item) {
@@ -274,8 +299,9 @@  discard block
 block discarded – undo
274 299
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
275 300
 <?php
276 301
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
277
-	if (count($tracker_array) == 0) print _("No data available");
278
-	else {
302
+	if (count($tracker_array) == 0) {
303
+		print _("No data available");
304
+	} else {
279 305
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
280 306
 		$tracker_data = '';
281 307
 		foreach($tracker_array as $tracker_item) {
@@ -319,8 +345,9 @@  discard block
 block discarded – undo
319 345
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
320 346
 <?php
321 347
 		$owner_array = $Satellite->countAllOwners(true);
322
-		if (count($owner_array) == 0) print _("No data available");
323
-		else {
348
+		if (count($owner_array) == 0) {
349
+			print _("No data available");
350
+		} else {
324 351
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
325 352
 			$owner_data = '';
326 353
 			foreach($owner_array as $owner_item) {
@@ -339,7 +366,10 @@  discard block
 block discarded – undo
339 366
 ?>
340 367
                <!--
341 368
                 <div class="more">
342
-                    <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>
369
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
370
+	echo '/'.$airline_icao;
371
+}
372
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
343 373
                 </div>
344 374
                 -->
345 375
             </div>
@@ -348,8 +378,9 @@  discard block
 block discarded – undo
348 378
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
349 379
 <?php
350 380
 		$countries_array = $Satellite->countAllCountriesOwners(true);
351
-		if (count($countries_array) == 0) print _("No data available");
352
-		else {
381
+		if (count($countries_array) == 0) {
382
+			print _("No data available");
383
+		} else {
353 384
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
354 385
 			$owner_data = '';
355 386
 			foreach($countries_array as $owner_item) {
@@ -368,7 +399,10 @@  discard block
 block discarded – undo
368 399
 ?>
369 400
 	    <!--
370 401
                 <div class="more">
371
-                    <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>
402
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
403
+	echo '/'.$airline_icao;
404
+}
405
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
372 406
                 </div>
373 407
                 -->
374 408
             </div>
@@ -380,8 +414,9 @@  discard block
 block discarded – undo
380 414
                 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
381 415
 <?php
382 416
 		$launch_site_array = $Satellite->countAllLaunchSite(true);
383
-		if (count($launch_site_array) == 0) print _("No data available");
384
-		else {
417
+		if (count($launch_site_array) == 0) {
418
+			print _("No data available");
419
+		} else {
385 420
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
386 421
 			$launch_site_data = '';
387 422
 			foreach($launch_site_array as $launch_site_item) {
@@ -400,7 +435,10 @@  discard block
 block discarded – undo
400 435
 ?>
401 436
                <!--
402 437
                 <div class="more">
403
-                    <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>
438
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
439
+	echo '/'.$airline_icao;
440
+}
441
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
404 442
                 </div>
405 443
                 -->
406 444
             </div>
@@ -423,8 +461,9 @@  discard block
 block discarded – undo
423 461
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
424 462
 <?php
425 463
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
426
-		if (count($pilot_array) == 0) print _("No data available");
427
-		else {
464
+		if (count($pilot_array) == 0) {
465
+			print _("No data available");
466
+		} else {
428 467
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
429 468
 			$pilot_data = '';
430 469
 			foreach($pilot_array as $pilot_item) {
@@ -442,7 +481,9 @@  discard block
 block discarded – undo
442 481
 		}
443 482
 		print '<div class="more">';
444 483
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
445
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
484
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
485
+			echo '/'.$airline_icao;
486
+		}
446 487
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
447 488
 		print '</div>';
448 489
 ?>
@@ -458,8 +499,9 @@  discard block
 block discarded – undo
458 499
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
459 500
 <?php
460 501
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
461
-		if (count($owner_array) == 0) print _("No data available");
462
-		else {
502
+		if (count($owner_array) == 0) {
503
+			print _("No data available");
504
+		} else {
463 505
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
464 506
 			$owner_data = '';
465 507
 			foreach($owner_array as $owner_item) {
@@ -477,7 +519,10 @@  discard block
 block discarded – undo
477 519
 		}
478 520
 ?>
479 521
                 <div class="more">
480
-                    <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>
522
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
523
+	echo '/'.$airline_icao;
524
+}
525
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
481 526
                 </div>
482 527
             </div>
483 528
         
@@ -490,8 +535,9 @@  discard block
 block discarded – undo
490 535
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
491 536
 <?php
492 537
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
493
-		if (count($flightover_array) == 0) print _("No data available");
494
-		else {
538
+		if (count($flightover_array) == 0) {
539
+			print _("No data available");
540
+		} else {
495 541
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
496 542
 			print 'var series = [';
497 543
 			$flightover_data = '';
@@ -533,7 +579,10 @@  discard block
 block discarded – undo
533 579
 		}
534 580
 ?>
535 581
                 <div class="more">
536
-                    <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>
582
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
583
+	echo '/'.$airline_icao;
584
+}
585
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
537 586
                 </div>
538 587
             </div>
539 588
 <?php
@@ -551,8 +600,9 @@  discard block
 block discarded – undo
551 600
 	<div class="col-md-6">
552 601
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
553 602
 <?php
554
-	if (count($flightover_array) == 0) print _("No data available");
555
-	else {
603
+	if (count($flightover_array) == 0) {
604
+		print _("No data available");
605
+	} else {
556 606
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
557 607
 		print 'var series = [';
558 608
 		$flightover_data = '';
@@ -608,8 +658,9 @@  discard block
 block discarded – undo
608 658
 	<div class="col-md-6">
609 659
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
610 660
 <?php
611
-	if (count($flightover_array) == 0) print _("No data available");
612
-	else {
661
+	if (count($flightover_array) == 0) {
662
+		print _("No data available");
663
+	} else {
613 664
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
614 665
 		print 'var series = [';
615 666
 		$flightover_data = '';
@@ -715,7 +766,9 @@  discard block
 block discarded – undo
715 766
 		});";
716 767
 		print '</script>';
717 768
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
718
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
769
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
770
+			echo '/'.$airline_icao;
771
+		}
719 772
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
720 773
 	}
721 774
 ?>
@@ -777,7 +830,9 @@  discard block
 block discarded – undo
777 830
 		});";
778 831
 		print '</script>';
779 832
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
780
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
833
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
834
+			echo '/'.$airline_icao;
835
+		}
781 836
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
782 837
 	}
783 838
 ?>
@@ -796,8 +851,9 @@  discard block
 block discarded – undo
796 851
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
797 852
 <?php
798 853
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
799
-		if (count($year_array) == 0) print _("No data available");
800
-		else {
854
+		if (count($year_array) == 0) {
855
+			print _("No data available");
856
+		} else {
801 857
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
802 858
 			$year_data = '';
803 859
 			$year_cnt = '';
@@ -816,7 +872,10 @@  discard block
 block discarded – undo
816 872
 		}
817 873
 ?>
818 874
                 <div class="more">
819
-                    <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>
875
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
876
+	echo '/'.$airline_icao;
877
+}
878
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
820 879
                 </div>
821 880
             </div>
822 881
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -824,8 +883,9 @@  discard block
 block discarded – undo
824 883
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
825 884
 <?php
826 885
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
827
-		if (count($month_array) == 0) print _("No data available");
828
-		else {
886
+		if (count($month_array) == 0) {
887
+			print _("No data available");
888
+		} else {
829 889
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
830 890
 			$month_data = '';
831 891
 			$month_cnt = '';
@@ -844,7 +904,10 @@  discard block
 block discarded – undo
844 904
 		}
845 905
 ?>
846 906
                 <div class="more">
847
-                    <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>
907
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
908
+	echo '/'.$airline_icao;
909
+}
910
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
848 911
                 </div>
849 912
             </div>
850 913
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -853,8 +916,9 @@  discard block
 block discarded – undo
853 916
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
854 917
 <?php
855 918
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
856
-		if (empty($date_array)) print _("No data available");
857
-		else {
919
+		if (empty($date_array)) {
920
+			print _("No data available");
921
+		} else {
858 922
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
859 923
 			$date_data = '';
860 924
 			$date_cnt = '';
@@ -873,7 +937,10 @@  discard block
 block discarded – undo
873 937
 		}
874 938
 ?>
875 939
                 <div class="more">
876
-                    <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>
940
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
941
+	echo '/'.$airline_icao;
942
+}
943
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
877 944
                 </div>
878 945
             </div>
879 946
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -881,8 +948,9 @@  discard block
 block discarded – undo
881 948
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
882 949
 <?php
883 950
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
884
-		if (empty($hour_array)) print _("No data available");
885
-		else {
951
+		if (empty($hour_array)) {
952
+			print _("No data available");
953
+		} else {
886 954
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
887 955
 			$hour_data = '';
888 956
 			$hour_cnt = '';
@@ -901,7 +969,10 @@  discard block
 block discarded – undo
901 969
 		}
902 970
 ?>
903 971
                 <div class="more">
904
-                    <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>
972
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
973
+	echo '/'.$airline_icao;
974
+}
975
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
905 976
                 </div>
906 977
             </div>
907 978
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -921,8 +992,9 @@  discard block
 block discarded – undo
921 992
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
922 993
 <?php
923 994
 		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
924
-		if (count($year_array) == 0) print _("No data available");
925
-		else {
995
+		if (count($year_array) == 0) {
996
+			print _("No data available");
997
+		} else {
926 998
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
927 999
 			$year_data = '';
928 1000
 			$year_cnt = '';
@@ -950,8 +1022,9 @@  discard block
 block discarded – undo
950 1022
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
951 1023
 <?php
952 1024
 		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
953
-		if (count($month_array) == 0) print _("No data available");
954
-		else {
1025
+		if (count($month_array) == 0) {
1026
+			print _("No data available");
1027
+		} else {
955 1028
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
956 1029
 			$month_data = '';
957 1030
 			$month_cnt = '';
@@ -979,8 +1052,9 @@  discard block
 block discarded – undo
979 1052
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
980 1053
 <?php
981 1054
 		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
982
-		if (empty($date_array)) print _("No data available");
983
-		else {
1055
+		if (empty($date_array)) {
1056
+			print _("No data available");
1057
+		} else {
984 1058
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
985 1059
 			$date_data = '';
986 1060
 			$date_cnt = '';
@@ -1007,8 +1081,9 @@  discard block
 block discarded – undo
1007 1081
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1008 1082
 <?php
1009 1083
 		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1010
-		if (empty($hour_array)) print _("No data available");
1011
-		else {
1084
+		if (empty($hour_array)) {
1085
+			print _("No data available");
1086
+		} else {
1012 1087
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1013 1088
 			$hour_data = '';
1014 1089
 			$hour_cnt = '';
@@ -1047,8 +1122,9 @@  discard block
 block discarded – undo
1047 1122
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1048 1123
 <?php
1049 1124
 		$year_array = $Tracker->countAllMonthsLastYear(true);
1050
-		if (count($year_array) == 0) print _("No data available");
1051
-		else {
1125
+		if (count($year_array) == 0) {
1126
+			print _("No data available");
1127
+		} else {
1052 1128
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1053 1129
 			$year_data = '';
1054 1130
 			$year_cnt = '';
@@ -1076,8 +1152,9 @@  discard block
 block discarded – undo
1076 1152
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1077 1153
 <?php
1078 1154
 		$month_array = $Tracker->countAllDatesLastMonth();
1079
-		if (count($month_array) == 0) print _("No data available");
1080
-		else {
1155
+		if (count($month_array) == 0) {
1156
+			print _("No data available");
1157
+		} else {
1081 1158
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1082 1159
 			$month_data = '';
1083 1160
 			$month_cnt = '';
@@ -1105,8 +1182,9 @@  discard block
 block discarded – undo
1105 1182
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1106 1183
 <?php
1107 1184
 		$date_array = $Tracker->countAllDatesLast7Days();
1108
-		if (empty($date_array)) print _("No data available");
1109
-		else {
1185
+		if (empty($date_array)) {
1186
+			print _("No data available");
1187
+		} else {
1110 1188
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1111 1189
 			$date_data = '';
1112 1190
 			$date_cnt = '';
@@ -1133,8 +1211,9 @@  discard block
 block discarded – undo
1133 1211
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1134 1212
 <?php
1135 1213
 		$hour_array = $Tracker->countAllHours('hour',true);
1136
-		if (empty($hour_array)) print _("No data available");
1137
-		else {
1214
+		if (empty($hour_array)) {
1215
+			print _("No data available");
1216
+		} else {
1138 1217
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1139 1218
 			$hour_data = '';
1140 1219
 			$hour_cnt = '';
@@ -1173,8 +1252,9 @@  discard block
 block discarded – undo
1173 1252
                 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1174 1253
 <?php
1175 1254
 		$year_array = $Satellite->countAllMonthsLastYear();
1176
-		if (count($year_array) == 0) print _("No data available");
1177
-		else {
1255
+		if (count($year_array) == 0) {
1256
+			print _("No data available");
1257
+		} else {
1178 1258
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1179 1259
 			$year_data = '';
1180 1260
 			$year_cnt = '';
@@ -1204,8 +1284,9 @@  discard block
 block discarded – undo
1204 1284
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1205 1285
 <?php
1206 1286
 		$year_array = $Satellite->countAllYears();
1207
-		if (count($year_array) == 0) print _("No data available");
1208
-		else {
1287
+		if (count($year_array) == 0) {
1288
+			print _("No data available");
1289
+		} else {
1209 1290
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1210 1291
 			$year_data = '';
1211 1292
 			$year_cnt = '';
@@ -1247,8 +1328,9 @@  discard block
 block discarded – undo
1247 1328
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1248 1329
 <?php
1249 1330
 		$year_array = $Stats->countFatalitiesByYear();
1250
-		if (count($year_array) == 0) print _("No data available");
1251
-		else {
1331
+		if (count($year_array) == 0) {
1332
+			print _("No data available");
1333
+		} else {
1252 1334
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1253 1335
 			$year_data = '';
1254 1336
 			$year_cnt = '';
@@ -1277,8 +1359,9 @@  discard block
 block discarded – undo
1277 1359
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1278 1360
 <?php
1279 1361
 		$year_array = $Stats->countFatalitiesLast12Months();
1280
-		if (count($year_array) == 0) print _("No data available");
1281
-		else {
1362
+		if (count($year_array) == 0) {
1363
+			print _("No data available");
1364
+		} else {
1282 1365
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1283 1366
 			$year_data = '';
1284 1367
 			$year_cnt = '';
@@ -1349,8 +1432,11 @@  discard block
 block discarded – undo
1349 1432
 					$distance = $distance;
1350 1433
 					$unit = 'km';
1351 1434
 				}
1352
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1353
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1435
+				if (!isset($polar_data)) {
1436
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1437
+				} else {
1438
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1439
+				}
1354 1440
 			}
1355 1441
 ?>
1356 1442
             <div class="col-md-6">
@@ -1414,9 +1500,12 @@  discard block
 block discarded – undo
1414 1500
 		foreach ($msg as $eachmsg) {
1415 1501
 			//$eachmsg = $msg[0];
1416 1502
 			$data = $eachmsg['source_data'];
1417
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1418
-			else $max = 500;
1419
-?>
1503
+			if ($data > 500) {
1504
+				$max = (round(($data+100)/100))*100;
1505
+			} else {
1506
+				$max = 500;
1507
+			}
1508
+			?>
1420 1509
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1421 1510
         	<script>
1422 1511
 		      var g = new JustGage({
Please login to merge, or discard this patch.
require/class.ACARS.php 1 patch
Braces   +412 added lines, -262 removed lines patch added patch discarded remove patch
@@ -26,14 +26,19 @@  discard block
 block discarded – undo
26 26
 	*/
27 27
 	public function ident2icao($ident) {
28 28
 		if (substr($ident,0,2) == 'AF') {
29
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
30
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
29
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
30
+				$icao = $ident;
31
+			} else {
32
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
33
+			}
31 34
 		} else {
32 35
 			$Spotter = new Spotter($this->db);
33 36
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
34 37
 			if (isset($identicao[0])) {
35 38
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
36
-			} else $icao = $ident;
39
+			} else {
40
+				$icao = $ident;
41
+			}
37 42
 		}
38 43
 		return $icao;
39 44
 	}
@@ -106,14 +111,24 @@  discard block
 block discarded – undo
106 111
 		$message = '';
107 112
 		$result = array();
108 113
 		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
109
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
110
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
111
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
114
+		if ($n == 0) {
115
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
116
+		}
117
+		if ($n == 0) {
118
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
119
+		}
120
+		if ($n == 0) {
121
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
122
+		}
112 123
 		if ($n != 0) {
113 124
 			$registration = str_replace('.','',$registration);
114 125
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
115
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
116
-		} else $message = $data;
126
+			if ($globalDebug) {
127
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
128
+			}
129
+		} else {
130
+			$message = $data;
131
+		}
117 132
 		$decode = array();
118 133
 		$found = false;
119 134
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -133,12 +148,21 @@  discard block
 block discarded – undo
133 148
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
134 149
 					$latitude = $la / 10000.0;
135 150
 					$longitude = $ln / 10000.0;
136
-					if ($lac == 'S') $latitude = '-'.$latitude;
137
-					if ($lnc == 'W') $longitude = '-'.$longitude;
151
+					if ($lac == 'S') {
152
+						$latitude = '-'.$latitude;
153
+					}
154
+					if ($lnc == 'W') {
155
+						$longitude = '-'.$longitude;
156
+					}
138 157
 					// Temp not always available
139
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
140
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
141
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
158
+					if ($globalDebug) {
159
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
160
+					}
161
+					if ($temp == '') {
162
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
163
+					} else {
164
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
165
+					}
142 166
 
143 167
 					//$icao = $Translation->checkTranslation($ident);
144 168
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -152,25 +176,35 @@  discard block
 block discarded – undo
152 176
 				$ahour = '';
153 177
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
154 178
 				if ($n == 4 && strlen($darr) == 4) {
155
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
156
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
157
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
179
+					if ($dhour != '') {
180
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
181
+					}
182
+					if ($ahour != '') {
183
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
184
+					}
185
+					if ($globalDebug) {
186
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
187
+					}
158 188
 					//$icao = ACARS->ident2icao($ident);
159 189
 					//$icao = $Translation->checkTranslation($ident);
160 190
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
161 191
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
162 192
 					$found = true;
163
-				}
164
-				elseif ($n == 2 || $n  == 4) {
165
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
166
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
193
+				} elseif ($n == 2 || $n  == 4) {
194
+					if ($dhour != '') {
195
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
196
+					}
197
+					if ($globalDebug) {
198
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
199
+					}
167 200
 					//$icao = ACARS->ident2icao($ident);
168 201
 					//$icao = $Translation->checkTranslation($ident);
169 202
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
170 203
 					$found = true;
171
-				}
172
-				elseif ($n == 1) {
173
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
204
+				} elseif ($n == 1) {
205
+					if ($globalDebug) {
206
+						echo 'airport arrival : '.$darr."\n";
207
+					}
174 208
 					//$icao = ACARS->ident2icao($ident);
175 209
 					//$icao = $Translation->checkTranslation($ident);
176 210
 					$decode = array('Arrival airport' => $darr);
@@ -188,7 +222,9 @@  discard block
 block discarded – undo
188 222
 				$darr = '';
189 223
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
190 224
 				if ($n == 4) {
191
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
225
+					if ($globalDebug) {
226
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
227
+					}
192 228
 					//$icao = ACARS->ident2icao($ident);
193 229
 					//$icao = $Translation->checkTranslation($ident);
194 230
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -222,14 +258,23 @@  discard block
 block discarded – undo
222 258
 				$apiste = '';
223 259
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
224 260
 				if ($n > 8) {
225
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
226
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
227
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
261
+					if ($globalDebug) {
262
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
263
+					}
264
+					if ($dhour != '') {
265
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
266
+					}
267
+					if ($ahour != '') {
268
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
269
+					}
228 270
 					$icao = trim($aident);
229 271
 
230 272
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
231
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
232
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
273
+					if ($ahour == '') {
274
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
275
+					} else {
276
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
277
+					}
233 278
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
234 279
 					$decode['icao'] = $icao;
235 280
 					$found = true;
@@ -251,9 +296,15 @@  discard block
 block discarded – undo
251 296
 					$lns = $lns.'.'.$lns;
252 297
 					$latitude = $las / 1000.0;
253 298
 					$longitude = $lns / 1000.0;
254
-					if ($lac == 'S') $latitude = '-'.$latitude;
255
-					if ($lnc == 'W') $longitude = '-'.$longitude;
256
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
299
+					if ($lac == 'S') {
300
+						$latitude = '-'.$latitude;
301
+					}
302
+					if ($lnc == 'W') {
303
+						$longitude = '-'.$longitude;
304
+					}
305
+					if ($globalDebug) {
306
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
307
+					}
257 308
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
258 309
 					$found = true;
259 310
 				}
@@ -271,7 +322,9 @@  discard block
 block discarded – undo
271 322
 				$darr = '';
272 323
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
273 324
 				if ($n == 4) {
274
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
325
+					if ($globalDebug) {
326
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
327
+					}
275 328
 					//$icao = $Translation->checkTranslation($ident);
276 329
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
277 330
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -284,7 +337,9 @@  discard block
 block discarded – undo
284 337
 				$darr = '';
285 338
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
286 339
 				if ($n == 4) {
287
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
340
+					if ($globalDebug) {
341
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
342
+					}
288 343
 					//$icao = $Translation->checkTranslation($ident);
289 344
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
290 345
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -297,7 +352,9 @@  discard block
 block discarded – undo
297 352
 				$darr = '';
298 353
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
299 354
 				if ($n == 2) {
300
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
355
+					if ($globalDebug) {
356
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
357
+					}
301 358
 					//$icao = $Translation->checkTranslation($ident);
302 359
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
303 360
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -311,7 +368,9 @@  discard block
 block discarded – undo
311 368
 				$darr = '';
312 369
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
313 370
 				if ($n == 6) {
314
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
371
+					if ($globalDebug) {
372
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
373
+					}
315 374
 					//$icao = $Translation->checkTranslation($ident);
316 375
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
317 376
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -324,7 +383,9 @@  discard block
 block discarded – undo
324 383
 				$darr = '';
325 384
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
326 385
 				if ($n == 7) {
327
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
386
+					if ($globalDebug) {
387
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
388
+					}
328 389
 					//$icao = $Translation->checkTranslation($ident);
329 390
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
330 391
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -352,8 +413,12 @@  discard block
 block discarded – undo
352 413
 					$decode['icao'] = $icao;
353 414
 					$latitude = $las / 100.0;
354 415
 					$longitude = $lns / 100.0;
355
-					if ($lac == 'S') $latitude = '-'.$latitude;
356
-					if ($lnc == 'W') $longitude = '-'.$longitude;
416
+					if ($lac == 'S') {
417
+						$latitude = '-'.$latitude;
418
+					}
419
+					if ($lnc == 'W') {
420
+						$longitude = '-'.$longitude;
421
+					}
357 422
 
358 423
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
359 424
 					$found = true;
@@ -371,8 +436,12 @@  discard block
 block discarded – undo
371 436
 				if ($n == 4) {
372 437
 					$latitude = $las;
373 438
 					$longitude = $lns;
374
-					if ($lac == 'S') $latitude = '-'.$latitude;
375
-					if ($lnc == 'W') $longitude = '-'.$longitude;
439
+					if ($lac == 'S') {
440
+						$latitude = '-'.$latitude;
441
+					}
442
+					if ($lnc == 'W') {
443
+						$longitude = '-'.$longitude;
444
+					}
376 445
 
377 446
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
378 447
 					$found = true;
@@ -388,7 +457,9 @@  discard block
 block discarded – undo
388 457
 				$darr = '';
389 458
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
390 459
 				if ($n == 5) {
391
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
460
+					if ($globalDebug) {
461
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
462
+					}
392 463
 					//$icao = $Translation->checkTranslation($ident);
393 464
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
394 465
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -409,7 +480,9 @@  discard block
 block discarded – undo
409 480
 				$aident = '';
410 481
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
411 482
 				if ($n == 8) {
412
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
483
+					if ($globalDebug) {
484
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
485
+					}
413 486
 					$icao = trim($aident);
414 487
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
415 488
 					$decode['icao'] = $icao;
@@ -426,7 +499,9 @@  discard block
 block discarded – undo
426 499
 				$darr = '';
427 500
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
428 501
 				if ($n == 5) {
429
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
502
+					if ($globalDebug) {
503
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
504
+					}
430 505
 					//$icao = $Translation->checkTranslation($ident);
431 506
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
432 507
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -441,7 +516,9 @@  discard block
 block discarded – undo
441 516
 				$darr = '';
442 517
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
443 518
 				if ($n == 3) {
444
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
519
+					if ($globalDebug) {
520
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
521
+					}
445 522
 					//$icao = $Translation->checkTranslation($ident);
446 523
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
447 524
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -456,7 +533,9 @@  discard block
 block discarded – undo
456 533
 				$darr = '';
457 534
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
458 535
 				if ($n == 3) {
459
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
536
+					if ($globalDebug) {
537
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
538
+					}
460 539
 					//$icao = $Translation->checkTranslation($ident);
461 540
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
462 541
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -466,7 +545,9 @@  discard block
 block discarded – undo
466 545
 			if (!$found) {
467 546
 				$n = sscanf($message,'MET01%4c',$airport);
468 547
 				if ($n == 1) {
469
-					if ($globalDebug) echo 'airport name : '.$airport;
548
+					if ($globalDebug) {
549
+						echo 'airport name : '.$airport;
550
+					}
470 551
 					$decode = array('Airport/Waypoint name' => $airport);
471 552
 					$found = true;
472 553
 				}
@@ -474,184 +555,126 @@  discard block
 block discarded – undo
474 555
 			if ($label == 'H1') {
475 556
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
476 557
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
477
-				}
478
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
558
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
479 559
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
480
-				}
481
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
560
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
482 561
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
483
-				}
484
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
562
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
485 563
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
486
-				}
487
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
564
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
488 565
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
489
-				}
490
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
566
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
491 567
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
492
-				}
493
-				elseif (preg_match(':^#M1AAEP:',$message)) {
568
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
494 569
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
495
-				}
496
-				elseif (preg_match(':^#M2APWD:',$message)) {
570
+				} elseif (preg_match(':^#M2APWD:',$message)) {
497 571
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
498
-				}
499
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
572
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
500 573
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
501
-				}
502
-				elseif (preg_match(':^#CF:',$message)) {
574
+				} elseif (preg_match(':^#CF:',$message)) {
503 575
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
504
-				}
505
-				elseif (preg_match(':^#DF:',$message)) {
576
+				} elseif (preg_match(':^#DF:',$message)) {
506 577
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
507
-				}
508
-				elseif (preg_match(':^#EC:',$message)) {
578
+				} elseif (preg_match(':^#EC:',$message)) {
509 579
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
510
-				}
511
-				elseif (preg_match(':^#EI:',$message)) {
580
+				} elseif (preg_match(':^#EI:',$message)) {
512 581
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
513
-				}
514
-				elseif (preg_match(':^#H1:',$message)) {
582
+				} elseif (preg_match(':^#H1:',$message)) {
515 583
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
516
-				}
517
-				elseif (preg_match(':^#H2:',$message)) {
584
+				} elseif (preg_match(':^#H2:',$message)) {
518 585
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
519
-				}
520
-				elseif (preg_match(':^#HD:',$message)) {
586
+				} elseif (preg_match(':^#HD:',$message)) {
521 587
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
522
-				}
523
-				elseif (preg_match(':^#M1:',$message)) {
588
+				} elseif (preg_match(':^#M1:',$message)) {
524 589
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
525
-				}
526
-				elseif (preg_match(':^#M2:',$message)) {
590
+				} elseif (preg_match(':^#M2:',$message)) {
527 591
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
528
-				}
529
-				elseif (preg_match(':^#M3:',$message)) {
592
+				} elseif (preg_match(':^#M3:',$message)) {
530 593
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
531
-				}
532
-				elseif (preg_match(':^#MD:',$message)) {
594
+				} elseif (preg_match(':^#MD:',$message)) {
533 595
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
534
-				}
535
-				elseif (preg_match(':^#PS:',$message)) {
596
+				} elseif (preg_match(':^#PS:',$message)) {
536 597
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
537
-				}
538
-				elseif (preg_match(':^#S1:',$message)) {
598
+				} elseif (preg_match(':^#S1:',$message)) {
539 599
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
540
-				}
541
-				elseif (preg_match(':^#S2:',$message)) {
600
+				} elseif (preg_match(':^#S2:',$message)) {
542 601
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
543
-				}
544
-				elseif (preg_match(':^#SD:',$message)) {
602
+				} elseif (preg_match(':^#SD:',$message)) {
545 603
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
546
-				}
547
-				elseif (preg_match(':^#T[0-8]:',$message)) {
604
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
548 605
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
549
-				}
550
-				elseif (preg_match(':^#WO:',$message)) {
606
+				} elseif (preg_match(':^#WO:',$message)) {
551 607
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
552
-				}
553
-				elseif (preg_match(':^#A1:',$message)) {
608
+				} elseif (preg_match(':^#A1:',$message)) {
554 609
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
555
-				}
556
-				elseif (preg_match(':^#A3:',$message)) {
610
+				} elseif (preg_match(':^#A3:',$message)) {
557 611
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
558
-				}
559
-				elseif (preg_match(':^#A4:',$message)) {
612
+				} elseif (preg_match(':^#A4:',$message)) {
560 613
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
561
-				}
562
-				elseif (preg_match(':^#A6:',$message)) {
614
+				} elseif (preg_match(':^#A6:',$message)) {
563 615
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
564
-				}
565
-				elseif (preg_match(':^#A8:',$message)) {
616
+				} elseif (preg_match(':^#A8:',$message)) {
566 617
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
567
-				}
568
-				elseif (preg_match(':^#A9:',$message)) {
618
+				} elseif (preg_match(':^#A9:',$message)) {
569 619
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
570
-				}
571
-				elseif (preg_match(':^#A0:',$message)) {
620
+				} elseif (preg_match(':^#A0:',$message)) {
572 621
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
573
-				}
574
-				elseif (preg_match(':^#AA:',$message)) {
622
+				} elseif (preg_match(':^#AA:',$message)) {
575 623
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
576
-				}
577
-				elseif (preg_match(':^#AB:',$message)) {
624
+				} elseif (preg_match(':^#AB:',$message)) {
578 625
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
579
-				}
580
-				elseif (preg_match(':^#AC:',$message)) {
626
+				} elseif (preg_match(':^#AC:',$message)) {
581 627
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
582
-				}
583
-				elseif (preg_match(':^#AD:',$message)) {
628
+				} elseif (preg_match(':^#AD:',$message)) {
584 629
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
585
-				}
586
-				elseif (preg_match(':^#AF:',$message)) {
630
+				} elseif (preg_match(':^#AF:',$message)) {
587 631
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
588
-				}
589
-				elseif (preg_match(':^#B1:',$message)) {
632
+				} elseif (preg_match(':^#B1:',$message)) {
590 633
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
591
-				}
592
-				elseif (preg_match(':^#B2:',$message)) {
634
+				} elseif (preg_match(':^#B2:',$message)) {
593 635
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
594
-				}
595
-				elseif (preg_match(':^#B3:',$message)) {
636
+				} elseif (preg_match(':^#B3:',$message)) {
596 637
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
597
-				}
598
-				elseif (preg_match(':^#B4:',$message)) {
638
+				} elseif (preg_match(':^#B4:',$message)) {
599 639
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
600
-				}
601
-				elseif (preg_match(':^#B6:',$message)) {
640
+				} elseif (preg_match(':^#B6:',$message)) {
602 641
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
603
-				}
604
-				elseif (preg_match(':^#B8:',$message)) {
642
+				} elseif (preg_match(':^#B8:',$message)) {
605 643
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
606
-				}
607
-				elseif (preg_match(':^#B9:',$message)) {
644
+				} elseif (preg_match(':^#B9:',$message)) {
608 645
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
609
-				}
610
-				elseif (preg_match(':^#B0:',$message)) {
646
+				} elseif (preg_match(':^#B0:',$message)) {
611 647
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
612
-				}
613
-				elseif (preg_match(':^#BA:',$message)) {
648
+				} elseif (preg_match(':^#BA:',$message)) {
614 649
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
615
-				}
616
-				elseif (preg_match(':^#BB:',$message)) {
650
+				} elseif (preg_match(':^#BB:',$message)) {
617 651
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
618
-				}
619
-				elseif (preg_match(':^#BC:',$message)) {
652
+				} elseif (preg_match(':^#BC:',$message)) {
620 653
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
621
-				}
622
-				elseif (preg_match(':^#BD:',$message)) {
654
+				} elseif (preg_match(':^#BD:',$message)) {
623 655
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
624
-				}
625
-				elseif (preg_match(':^#BE:',$message)) {
656
+				} elseif (preg_match(':^#BE:',$message)) {
626 657
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
627
-				}
628
-				elseif (preg_match(':^#BF:',$message)) {
658
+				} elseif (preg_match(':^#BF:',$message)) {
629 659
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
630
-				}
631
-				elseif (preg_match(':^#H3:',$message)) {
660
+				} elseif (preg_match(':^#H3:',$message)) {
632 661
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
633 662
 				}
634 663
 			}
635 664
 			if ($label == '10') {
636 665
 				if (preg_match(':^DTO01:',$message)) {
637 666
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
638
-				}
639
-				elseif (preg_match(':^AIS01:',$message)) {
667
+				} elseif (preg_match(':^AIS01:',$message)) {
640 668
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
641
-				}
642
-				elseif (preg_match(':^FTX01:',$message)) {
669
+				} elseif (preg_match(':^FTX01:',$message)) {
643 670
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
644
-				}
645
-				elseif (preg_match(':^FPL01:',$message)) {
671
+				} elseif (preg_match(':^FPL01:',$message)) {
646 672
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
647
-				}
648
-				elseif (preg_match(':^WAB01:',$message)) {
673
+				} elseif (preg_match(':^WAB01:',$message)) {
649 674
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
650
-				}
651
-				elseif (preg_match(':^MET01:',$message)) {
675
+				} elseif (preg_match(':^MET01:',$message)) {
652 676
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
653
-				}
654
-				elseif (preg_match(':^WAB02:',$message)) {
677
+				} elseif (preg_match(':^WAB02:',$message)) {
655 678
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
656 679
 				}
657 680
 			}
@@ -666,38 +689,28 @@  discard block
 block discarded – undo
666 689
 					$vsta = array('Version' => $version);
667 690
 					if ($state == 'E') {
668 691
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
669
-					}
670
-					elseif ($state == 'L') {
692
+					} elseif ($state == 'L') {
671 693
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
672
-					}
673
-					else {
694
+					} else {
674 695
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
675 696
 					}
676 697
 					if ($type == 'V') {
677 698
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
678
-					}
679
-					elseif ($type == 'S') {
699
+					} elseif ($type == 'S') {
680 700
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
681
-					}
682
-					elseif ($type == 'H') {
701
+					} elseif ($type == 'H') {
683 702
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
684
-					}
685
-					elseif ($type == 'G') {
703
+					} elseif ($type == 'G') {
686 704
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
687
-					}
688
-					elseif ($type == 'C') {
705
+					} elseif ($type == 'C') {
689 706
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
690
-					}
691
-					elseif ($type == '2') {
707
+					} elseif ($type == '2') {
692 708
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
693
-					}
694
-					elseif ($type == 'X') {
709
+					} elseif ($type == 'X') {
695 710
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
696
-					}
697
-					elseif ($type == 'I') {
711
+					} elseif ($type == 'I') {
698 712
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
699
-					}
700
-					else {
713
+					} else {
701 714
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
702 715
 					}
703 716
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -706,7 +719,9 @@  discard block
 block discarded – undo
706 719
 			}
707 720
 
708 721
 			$title = $this->getTitlefromLabel($label);
709
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
722
+			if ($title != '') {
723
+				$decode = array_merge(array('Message title' => $title),$decode);
724
+			}
710 725
 			/*
711 726
 			// Business jets always use GS0001
712 727
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -741,31 +756,54 @@  discard block
 block discarded – undo
741 756
 			$msg = $message['message'];
742 757
 			$decode = $message['decode'];
743 758
 			$registration = (string)$message['registration'];
744
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
745
-			else $latitude = '';
746
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
747
-			else $longitude = '';
748
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
749
-			else $airicao = '';
750
-			if (isset($decode['icao'])) $icao = $decode['icao'];
751
-			else $icao = $Translation->checkTranslation($ident);
759
+			if (isset($decode['latitude'])) {
760
+				$latitude = $decode['latitude'];
761
+			} else {
762
+				$latitude = '';
763
+			}
764
+			if (isset($decode['longitude'])) {
765
+				$longitude = $decode['longitude'];
766
+			} else {
767
+				$longitude = '';
768
+			}
769
+			if (isset($decode['airicao'])) {
770
+				$airicao = $decode['airicao'];
771
+			} else {
772
+				$airicao = '';
773
+			}
774
+			if (isset($decode['icao'])) {
775
+				$icao = $decode['icao'];
776
+			} else {
777
+				$icao = $Translation->checkTranslation($ident);
778
+			}
752 779
 			$image_array = $Image->getSpotterImage($registration);
753 780
 			if (!isset($image_array[0]['registration'])) {
754 781
 				$Image->addSpotterImage($registration);
755 782
 			}
756 783
 			// Business jets always use GS0001
757
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
758
-			if ($globalDebug && isset($info) && $info != '') echo $info;
759
-			if (count($decode) > 0) $decode_json = json_encode($decode);
760
-			else $decode_json = '';
784
+			if ($ident != 'GS0001') {
785
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
786
+			}
787
+			if ($globalDebug && isset($info) && $info != '') {
788
+				echo $info;
789
+			}
790
+			if (count($decode) > 0) {
791
+				$decode_json = json_encode($decode);
792
+			} else {
793
+				$decode_json = '';
794
+			}
761 795
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
762 796
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
763 797
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
764 798
 				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
765 799
 			}
766 800
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
767
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
768
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
801
+			if (!isset($globalACARSArchive)) {
802
+				$globalACARSArchive = array('10','80','81','82','3F');
803
+			}
804
+			if ($result && in_array($label,$globalACARSArchive)) {
805
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
806
+			}
769 807
 			if ($globalDebug && count($decode) > 0) {
770 808
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
771 809
 			}
@@ -788,7 +826,9 @@  discard block
 block discarded – undo
788 826
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
789 827
 			$Connection = new Connection($this->db);
790 828
 			$this->db = $Connection->db;
791
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
829
+			if ($globalDebug) {
830
+				echo "Test if not already in Live ACARS table...";
831
+			}
792 832
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
793 833
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
794 834
 			try {
@@ -798,7 +838,9 @@  discard block
 block discarded – undo
798 838
 				return "error : ".$e->getMessage();
799 839
 			}
800 840
 			if ($stht->fetchColumn() == 0) {
801
-				if ($globalDebug) echo "Add Live ACARS data...";
841
+				if ($globalDebug) {
842
+					echo "Add Live ACARS data...";
843
+				}
802 844
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
803 845
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
804 846
 				try {
@@ -808,10 +850,14 @@  discard block
 block discarded – undo
808 850
 					return "error : ".$e->getMessage();
809 851
 				}
810 852
 			} else {
811
-				if ($globalDebug) echo "Data already in DB...\n";
853
+				if ($globalDebug) {
854
+					echo "Data already in DB...\n";
855
+				}
812 856
 				return false;
813 857
 			}
814
-			if ($globalDebug) echo "Done\n";
858
+			if ($globalDebug) {
859
+				echo "Done\n";
860
+			}
815 861
 			return true;
816 862
 		}
817 863
 	}
@@ -842,7 +888,9 @@  discard block
 block discarded – undo
842 888
 			    	    }
843 889
 				    if ($stht->fetchColumn() == 0) {
844 890
 			*/
845
-			if ($globalDebug) echo "Add Live ACARS data...";
891
+			if ($globalDebug) {
892
+				echo "Add Live ACARS data...";
893
+			}
846 894
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
847 895
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
848 896
 			try {
@@ -851,7 +899,9 @@  discard block
 block discarded – undo
851 899
 			} catch(PDOException $e) {
852 900
 				return "error : ".$e->getMessage();
853 901
 			}
854
-			if ($globalDebug) echo "Done\n";
902
+			if ($globalDebug) {
903
+				echo "Done\n";
904
+			}
855 905
 		}
856 906
 	}
857 907
 
@@ -874,8 +924,11 @@  discard block
 block discarded – undo
874 924
 			return '';
875 925
 		}
876 926
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
877
-		if (count($row) > 0) return $row[0]['title'];
878
-		else return '';
927
+		if (count($row) > 0) {
928
+			return $row[0]['title'];
929
+		} else {
930
+			return '';
931
+		}
879 932
 	}
880 933
 
881 934
 	/**
@@ -894,8 +947,11 @@  discard block
 block discarded – undo
894 947
 			return array();
895 948
 		}
896 949
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
897
-		if (count($row) > 0) return $row;
898
-		else return array();
950
+		if (count($row) > 0) {
951
+			return $row;
952
+		} else {
953
+			return array();
954
+		}
899 955
 	}
900 956
 
901 957
 	/**
@@ -915,8 +971,11 @@  discard block
 block discarded – undo
915 971
 			return array();
916 972
 		}
917 973
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
918
-		if (count($row) > 0) return $row[0];
919
-		else return array();
974
+		if (count($row) > 0) {
975
+			return $row[0];
976
+		} else {
977
+			return array();
978
+		}
920 979
 	}
921 980
 
922 981
 	/**
@@ -961,19 +1020,35 @@  discard block
 block discarded – undo
961 1020
 			if ($row['registration'] != '') {
962 1021
 				$row['registration'] = str_replace('.','',$row['registration']);
963 1022
 				$image_array = $Image->getSpotterImage($row['registration']);
964
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
965
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
966
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
967
-			if ($row['registration'] == '') $row['registration'] = 'NA';
968
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1023
+				if (count($image_array) > 0) {
1024
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1025
+				} else {
1026
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1027
+				}
1028
+			} else {
1029
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1030
+			}
1031
+			if ($row['registration'] == '') {
1032
+				$row['registration'] = 'NA';
1033
+			}
1034
+			if ($row['ident'] == '') {
1035
+				$row['ident'] = 'NA';
1036
+			}
969 1037
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
970 1038
 			if (isset($identicao[0])) {
971 1039
 				if (substr($row['ident'],0,2) == 'AF') {
972
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
973
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
974
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1040
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1041
+						$icao = $row['ident'];
1042
+					} else {
1043
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1044
+					}
1045
+				} else {
1046
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1047
+				}
975 1048
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
976
-			} else $icao = $row['ident'];
1049
+			} else {
1050
+				$icao = $row['ident'];
1051
+			}
977 1052
 			$icao = $Translation->checkTranslation($icao,false);
978 1053
 			$decode = json_decode($row['decode'],true);
979 1054
 			$found = false;
@@ -998,7 +1073,9 @@  discard block
 block discarded – undo
998 1073
 					$found = true;
999 1074
 				}
1000 1075
 			}
1001
-			if ($found) $row['decode'] = json_encode($decode);
1076
+			if ($found) {
1077
+				$row['decode'] = json_encode($decode);
1078
+			}
1002 1079
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1003 1080
 			$result[] = $data;
1004 1081
 			$i++;
@@ -1006,8 +1083,9 @@  discard block
 block discarded – undo
1006 1083
 		if (isset($result)) {
1007 1084
 			$result[0]['query_number_rows'] = $i;
1008 1085
 			return $result;
1086
+		} else {
1087
+			return array();
1009 1088
 		}
1010
-		else return array();
1011 1089
 	}
1012 1090
 
1013 1091
 	/**
@@ -1056,31 +1134,51 @@  discard block
 block discarded – undo
1056 1134
 			if ($row['registration'] != '') {
1057 1135
 				$row['registration'] = str_replace('.','',$row['registration']);
1058 1136
 				$image_array = $Image->getSpotterImage($row['registration']);
1059
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1060
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1061
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1137
+				if (count($image_array) > 0) {
1138
+					$data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1139
+				} else {
1140
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1141
+				}
1142
+			} else {
1143
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1144
+			}
1062 1145
 			$icao = '';
1063
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1064
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1146
+			if ($row['registration'] == '') {
1147
+				$row['registration'] = 'NA';
1148
+			}
1149
+			if ($row['ident'] == '') {
1150
+				$row['ident'] = 'NA';
1151
+			}
1065 1152
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1066 1153
 			if (isset($identicao[0])) {
1067 1154
 				if (substr($row['ident'],0,2) == 'AF') {
1068
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1069
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1070
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1155
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1156
+						$icao = $row['ident'];
1157
+					} else {
1158
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1159
+					}
1160
+				} else {
1161
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1162
+				}
1071 1163
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1072
-			} else $icao = $row['ident'];
1164
+			} else {
1165
+				$icao = $row['ident'];
1166
+			}
1073 1167
 			$icao = $Translation->checkTranslation($icao);
1074 1168
 			$decode = json_decode($row['decode'],true);
1075 1169
 			$found = false;
1076 1170
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1077 1171
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1078
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1172
+				if (isset($airport_info[0]['icao'])) {
1173
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1174
+				}
1079 1175
 				$found = true;
1080 1176
 			}
1081 1177
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1082 1178
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1083
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1179
+				if (isset($airport_info[0]['icao'])) {
1180
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1181
+				}
1084 1182
 				$found = true;
1085 1183
 			}
1086 1184
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1090,7 +1188,9 @@  discard block
 block discarded – undo
1090 1188
 					$found = true;
1091 1189
 				}
1092 1190
 			}
1093
-			if ($found) $row['decode'] = json_encode($decode);
1191
+			if ($found) {
1192
+				$row['decode'] = json_encode($decode);
1193
+			}
1094 1194
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1095 1195
 			$result[] = $data;
1096 1196
 			$i++;
@@ -1098,7 +1198,9 @@  discard block
 block discarded – undo
1098 1198
 		if (isset($result)) {
1099 1199
 			$result[0]['query_number_rows'] = $i;
1100 1200
 			return $result;
1101
-		} else return array();
1201
+		} else {
1202
+			return array();
1203
+		}
1102 1204
 	}
1103 1205
 
1104 1206
 	/**
@@ -1114,25 +1216,37 @@  discard block
 block discarded – undo
1114 1216
 		$ident = trim($ident);
1115 1217
 		$Translation = new Translation($this->db);
1116 1218
 		$Spotter = new Spotter($this->db);
1117
-		if ($globalDebug) echo "Test if we add ModeS data...";
1219
+		if ($globalDebug) {
1220
+			echo "Test if we add ModeS data...";
1221
+		}
1118 1222
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1119
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1120
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1223
+		if ($icao == '') {
1224
+			$icao = $Translation->checkTranslation($ident);
1225
+		}
1226
+		if ($globalDebug) {
1227
+			echo '- Ident : '.$icao.' - ';
1228
+		}
1121 1229
 		if ($ident == '' || $registration == '') {
1122
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1230
+			if ($globalDebug) {
1231
+				echo "Ident or registration null, exit\n";
1232
+			}
1123 1233
 			return '';
1124 1234
 		}
1125 1235
 		$registration = str_replace('.','',$registration);
1126 1236
 		$ident = $Translation->ident2icao($ident);
1127 1237
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1128
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1238
+		if ($globalDebug) {
1239
+			echo "Check if needed to add translation ".$ident.'... ';
1240
+		}
1129 1241
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1130 1242
 		$querysi_values = array(':registration' => $registration);
1131 1243
 		try {
1132 1244
 			$sthsi = $this->db->prepare($querysi);
1133 1245
 			$sthsi->execute($querysi_values);
1134 1246
 		} catch(PDOException $e) {
1135
-			if ($globalDebug) echo $e->getMessage();
1247
+			if ($globalDebug) {
1248
+				echo $e->getMessage();
1249
+			}
1136 1250
 			return "error : ".$e->getMessage();
1137 1251
 		}
1138 1252
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1140,9 +1254,14 @@  discard block
 block discarded – undo
1140 1254
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1141 1255
 			$Translation = new Translation($this->db);
1142 1256
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1143
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1144
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1145
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1257
+			if ($globalDebug) {
1258
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1259
+			}
1260
+			if ($ident != $trans_ident) {
1261
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1262
+			} elseif ($trans_ident == $ident) {
1263
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1264
+			}
1146 1265
 		} else {
1147 1266
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1148 1267
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1151,32 +1270,46 @@  discard block
 block discarded – undo
1151 1270
 					$sth = $this->db->prepare($query);
1152 1271
 					$sth->execute($query_values);
1153 1272
 				} catch(PDOException $e) {
1154
-					if ($globalDebug) echo $e->getMessage();
1273
+					if ($globalDebug) {
1274
+						echo $e->getMessage();
1275
+					}
1155 1276
 					return "error : ".$e->getMessage();
1156 1277
 				}
1157 1278
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1158 1279
 				$sth->closeCursor();
1159
-				if (isset($result['modes'])) $hex = $result['modes'];
1160
-				else $hex = '';
1280
+				if (isset($result['modes'])) {
1281
+					$hex = $result['modes'];
1282
+				} else {
1283
+					$hex = '';
1284
+				}
1161 1285
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1162
-				if ($this->fromACARSscript) $this->SI->add($SI_data);
1286
+				if ($this->fromACARSscript) {
1287
+					$this->SI->add($SI_data);
1288
+				}
1163 1289
 			}
1164 1290
 		}
1165
-		if ($globalDebug) echo 'Done'."\n";
1291
+		if ($globalDebug) {
1292
+			echo 'Done'."\n";
1293
+		}
1166 1294
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1167 1295
 		$query_values = array(':ident' => $icao);
1168 1296
 		try {
1169 1297
 			$sth = $this->db->prepare($query);
1170 1298
 			$sth->execute($query_values);
1171 1299
 		} catch(PDOException $e) {
1172
-			if ($globalDebug) echo $e->getMessage();
1300
+			if ($globalDebug) {
1301
+				echo $e->getMessage();
1302
+			}
1173 1303
 			return "error : ".$e->getMessage();
1174 1304
 		}
1175 1305
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1176 1306
 		$sth->closeCursor();
1177 1307
 		if (isset($result['flightaware_id'])) {
1178
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1179
-			else $ModeS = '';
1308
+			if (isset($result['ModeS'])) {
1309
+				$ModeS = $result['ModeS'];
1310
+			} else {
1311
+				$ModeS = '';
1312
+			}
1180 1313
 			if ($ModeS == '') {
1181 1314
 				$id = explode('-',$result['flightaware_id']);
1182 1315
 				$ModeS = $id[0];
@@ -1189,24 +1322,32 @@  discard block
 block discarded – undo
1189 1322
 					$sthc = $this->db->prepare($queryc);
1190 1323
 					$sthc->execute($queryc_values);
1191 1324
 				} catch(PDOException $e) {
1192
-					if ($globalDebug) echo $e->getMessage();
1325
+					if ($globalDebug) {
1326
+						echo $e->getMessage();
1327
+					}
1193 1328
 					return "error : ".$e->getMessage();
1194 1329
 				}
1195 1330
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1196 1331
 				$sthc->closeCursor();
1197 1332
 				if (count($row) ==  0) {
1198
-					if ($globalDebug) echo " Add to ModeS table - ";
1333
+					if ($globalDebug) {
1334
+						echo " Add to ModeS table - ";
1335
+					}
1199 1336
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1200 1337
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1201 1338
 					try {
1202 1339
 						$sthi = $this->db->prepare($queryi);
1203 1340
 						$sthi->execute($queryi_values);
1204 1341
 					} catch(PDOException $e) {
1205
-						if ($globalDebug) echo $e->getMessage();
1342
+						if ($globalDebug) {
1343
+							echo $e->getMessage();
1344
+						}
1206 1345
 						return "error : ".$e->getMessage();
1207 1346
 					}
1208 1347
 				} else {
1209
-					if ($globalDebug) echo " Update ModeS table - ";
1348
+					if ($globalDebug) {
1349
+						echo " Update ModeS table - ";
1350
+					}
1210 1351
 					if ($ICAOTypeCode != '') {
1211 1352
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1212 1353
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1218,7 +1359,9 @@  discard block
 block discarded – undo
1218 1359
 						$sthi = $this->db->prepare($queryi);
1219 1360
 						$sthi->execute($queryi_values);
1220 1361
 					} catch(PDOException $e) {
1221
-						if ($globalDebug) echo $e->getMessage();
1362
+						if ($globalDebug) {
1363
+							echo $e->getMessage();
1364
+						}
1222 1365
 						return "error : ".$e->getMessage();
1223 1366
 					}
1224 1367
 				}
@@ -1239,7 +1382,9 @@  discard block
 block discarded – undo
1239 1382
 					    return "error : ".$e->getMessage();
1240 1383
 				}
1241 1384
 				*/
1242
-				if ($globalDebug) echo " Update Spotter_output table - ";
1385
+				if ($globalDebug) {
1386
+					echo " Update Spotter_output table - ";
1387
+				}
1243 1388
 				if ($ICAOTypeCode != '') {
1244 1389
 					if ($globalDBdriver == 'mysql') {
1245 1390
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1250,8 +1395,7 @@  discard block
 block discarded – undo
1250 1395
 				} else {
1251 1396
 					if ($globalDBdriver == 'mysql') {
1252 1397
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1253
-					}
1254
-					elseif ($globalDBdriver == 'pgsql') {
1398
+					} elseif ($globalDBdriver == 'pgsql') {
1255 1399
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1256 1400
 					}
1257 1401
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1260,14 +1404,20 @@  discard block
 block discarded – undo
1260 1404
 					$sthi = $this->db->prepare($queryi);
1261 1405
 					$sthi->execute($queryi_values);
1262 1406
 				} catch(PDOException $e) {
1263
-					if ($globalDebug) echo $e->getMessage();
1407
+					if ($globalDebug) {
1408
+						echo $e->getMessage();
1409
+					}
1264 1410
 					return "error : ".$e->getMessage();
1265 1411
 				}
1266 1412
 			}
1267 1413
 		} else {
1268
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1414
+			if ($globalDebug) {
1415
+				echo " Can't find ModeS in spotter_output - ";
1416
+			}
1417
+		}
1418
+		if ($globalDebug) {
1419
+			echo "Done\n";
1269 1420
 		}
1270
-		if ($globalDebug) echo "Done\n";
1271 1421
 	}
1272 1422
 }
1273 1423
 ?>
Please login to merge, or discard this patch.