Completed
Push — master ( 1a2d60...d53e0e )
by Yannick
06:20
created
statistics-sub-menu.php 1 patch
Braces   +110 added lines, -27 removed lines patch added patch discarded remove patch
@@ -4,7 +4,13 @@  discard block
 block discarded – undo
4 4
 	<div class="stats_airline">
5 5
 	
6 6
 		<form id="changedate" method="post">
7
-			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') echo $year.'-'; ?><?php if (isset($month) && $month != '') echo $month; ?>" />
7
+			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') {
8
+	echo $year.'-';
9
+}
10
+?><?php if (isset($month) && $month != '') {
11
+	echo $month;
12
+}
13
+?>" />
8 14
 		</form>
9 15
 	
10 16
 		<form id="changeairline" method="post">
@@ -13,7 +19,9 @@  discard block
 block discarded – undo
13 19
 				<?php
14 20
 					require_once('require/class.Stats.php');
15 21
 					$Stats = new Stats();
16
-					if (!isset($filter_name)) $filter_name = '';
22
+					if (!isset($filter_name)) {
23
+						$filter_name = '';
24
+					}
17 25
 					$airlines = $Stats->getAllAirlineNames($filter_name);
18 26
 					if (isset($airline_icao) && ($airline_icao == '' || $airline_icao == 'all')) {
19 27
 						print '<option value="all" selected>All</option>';
@@ -41,10 +49,22 @@  discard block
 block discarded – undo
41 49
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
42 50
 		    </a>
43 51
 		    <ul class="dropdown-menu">
44
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Aircraft"); ?></a></li>
45
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Registration"); ?></a></li>
46
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Manufacturer"); ?></a></li>
47
-			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Country"); ?></a></li>
52
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
53
+	echo '/'.$airline_icao;
54
+}
55
+?>"><?php echo _("Aircraft"); ?></a></li>
56
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
57
+	echo '/'.$airline_icao;
58
+}
59
+?>"><?php echo _("Registration"); ?></a></li>
60
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
61
+	echo '/'.$airline_icao;
62
+}
63
+?>"><?php echo _("Manufacturer"); ?></a></li>
64
+			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
65
+	echo '/'.$airline_icao;
66
+}
67
+?>"><?php echo _("Country"); ?></a></li>
48 68
 		    </ul>
49 69
 		</li>
50 70
 		<li class="dropdown">
@@ -52,9 +72,18 @@  discard block
 block discarded – undo
52 72
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
53 73
 		    </a>
54 74
 		    <ul class="dropdown-menu" role="menu">
55
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline"); ?></a></li>
56
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline by Country"); ?></a></li>
57
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Callsign"); ?></a></li>
75
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
76
+	echo '/'.$airline_icao;
77
+}
78
+?>"><?php echo _("Airline"); ?></a></li>
79
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
80
+	echo '/'.$airline_icao;
81
+}
82
+?>"><?php echo _("Airline by Country"); ?></a></li>
83
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
84
+	echo '/'.$airline_icao;
85
+}
86
+?>"><?php echo _("Callsign"); ?></a></li>
58 87
 		    </ul>
59 88
 		</li>
60 89
 		<li class="dropdown">
@@ -62,10 +91,22 @@  discard block
 block discarded – undo
62 91
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
63 92
 		    </a>
64 93
 		    <ul class="dropdown-menu" role="menu">
65
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport"); ?></a></li>
66
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
67
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport"); ?></a></li>
68
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
94
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
95
+	echo '/'.$airline_icao;
96
+}
97
+?>"><?php echo _("Departure Airport"); ?></a></li>
98
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
99
+	echo '/'.$airline_icao;
100
+}
101
+?>"><?php echo _("Departure Airport by Country"); ?></a></li>
102
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
103
+	echo '/'.$airline_icao;
104
+}
105
+?>"><?php echo _("Arrival Airport"); ?></a></li>
106
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
107
+	echo '/'.$airline_icao;
108
+}
109
+?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
69 110
 		    </ul>
70 111
 		</li>
71 112
 		<li class="dropdown">
@@ -73,8 +114,14 @@  discard block
 block discarded – undo
73 114
 		      <?php echo _("Route"); ?> <span class="caret"></span>
74 115
 		    </a>
75 116
 		    <ul class="dropdown-menu" role="menu">
76
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Airport"); ?></a></li>
77
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Waypoint"); ?></a></li>
117
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
118
+	echo '/'.$airline_icao;
119
+}
120
+?>"><?php echo _("Route by Airport"); ?></a></li>
121
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
122
+	echo '/'.$airline_icao;
123
+}
124
+?>"><?php echo _("Route by Waypoint"); ?></a></li>
78 125
 		    </ul>
79 126
 		</li>
80 127
 		<li class="dropdown">
@@ -82,8 +129,14 @@  discard block
 block discarded – undo
82 129
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
83 130
 		    </a>
84 131
 		    <ul class="dropdown-menu" role="menu">
85
-		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Date"); ?></a></li>
86
-			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Time"); ?></a></li>
132
+		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
133
+	echo '/'.$airline_icao;
134
+}
135
+?>"><?php echo _("Date"); ?></a></li>
136
+			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
137
+	echo '/'.$airline_icao;
138
+}
139
+?>"><?php echo _("Time"); ?></a></li>
87 140
 		    </ul>
88 141
 		</li>
89 142
 		<?php
@@ -113,9 +166,18 @@  discard block
 block discarded – undo
113 166
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
114 167
 		    </a>
115 168
 		    <ul class="dropdown-menu">
116
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
117
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
118
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
169
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
170
+	echo '/'.$airline_icao;
171
+}
172
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
173
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
174
+	echo '/'.$airline_icao;
175
+}
176
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
177
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
178
+	echo '/'.$airline_icao;
179
+}
180
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
119 181
 			<!-- <li><a href="<?php print $globalURL; ?>/statistics/country"><?php echo _("Country"); ?></a></li> -->
120 182
 		    </ul>
121 183
 		</li>
@@ -124,9 +186,18 @@  discard block
 block discarded – undo
124 186
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
125 187
 		    </a>
126 188
 		    <ul class="dropdown-menu" role="menu">
127
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
128
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
129
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
189
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
190
+	echo '/'.$airline_icao;
191
+}
192
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
193
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
194
+	echo '/'.$airline_icao;
195
+}
196
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
197
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
198
+	echo '/'.$airline_icao;
199
+}
200
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
130 201
 		    </ul>
131 202
 		</li>
132 203
 		<li class="dropdown">
@@ -134,10 +205,22 @@  discard block
 block discarded – undo
134 205
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
135 206
 		    </a>
136 207
 		    <ul class="dropdown-menu" role="menu">
137
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
138
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
139
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
140
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
208
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
209
+	echo '/'.$airline_icao;
210
+}
211
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
212
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
213
+	echo '/'.$airline_icao;
214
+}
215
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
216
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
217
+	echo '/'.$airline_icao;
218
+}
219
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
220
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
221
+	echo '/'.$airline_icao;
222
+}
223
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
141 224
 		    </ul>
142 225
 		</li>
143 226
 		<!--
Please login to merge, or discard this patch.
statistics-pilot.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,11 +5,15 @@
 block discarded – undo
5 5
 $Stats = new Stats();
6 6
 $title = _("Statistics").' - '._("Most common Pilots");
7 7
 
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 12
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12
-}
13
+    if (isset($globalFilter['airline'])) {
14
+    	$airline_icao = $globalFilter['airline'][0];
15
+    }
16
+    }
13 17
 setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/');
14 18
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 19
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
require/class.METAR.php 1 patch
Braces   +100 added lines, -38 removed lines patch added patch discarded remove patch
@@ -59,8 +59,11 @@  discard block
 block discarded – undo
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
61 61
                 $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
62
+                if ($row['nb'] > 0) {
63
+                	return false;
64
+                } else {
65
+                	return true;
66
+                }
64 67
         }
65 68
 
66 69
         public static function insert_last_update() {
@@ -84,9 +87,14 @@  discard block
 block discarded – undo
84 87
     		//$pieces = explode(' ',$data);
85 88
     		$pieces = preg_split('/\s/',$data);
86 89
     		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
+    		if ($pieces[0] == 'METAR') {
91
+    			$pos++;
92
+    		} elseif ($pieces[0] == 'SPECI') {
93
+    			$pos++;
94
+    		}
95
+    		if (strlen($pieces[$pos]) != 4) {
96
+    			$pos++;
97
+    		}
90 98
     		$result = array();
91 99
     		$result['location'] = $pieces[$pos];
92 100
     		$pos++;
@@ -95,16 +103,26 @@  discard block
 block discarded – undo
95 103
     		$c = count($pieces);
96 104
     		for($pos++; $pos < $c; $pos++) {
97 105
     			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
106
+    			if ($piece == 'RMK') {
107
+    				break;
108
+    			}
109
+    			if ($piece == 'AUTO') {
110
+    				$result['auto'] = true;
111
+    			}
112
+    			if ($piece == 'COR') {
113
+    				$result['correction'] = true;
114
+    			}
101 115
     			// Wind Speed
102 116
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103 117
     				$result['wind']['direction'] = (float)$matches[1];
104 118
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
119
+    				if ($result['wind']['unit'] == 'KT') {
120
+    					$result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
121
+    				} elseif ($result['wind']['unit'] == 'KPH') {
122
+    					$result['wind']['speed'] = round(((float)$matches[2])*1000,2);
123
+    				} elseif ($result['wind']['unit'] == 'MPS') {
124
+    					$result['wind']['speed'] = round(((float)$matches[2]),2);
125
+    				}
108 126
 				$result['wind']['gust'] = (float)$matches[3];
109 127
 				$result['wind']['unit'] = $matches[4];
110 128
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
@@ -186,14 +204,23 @@  discard block
 block discarded – undo
186 204
     				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187 205
     				$type = $matches[1];
188 206
     				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
207
+    				if ($type == 'SKC') {
208
+    					$cloud['type'] = 'No cloud/Sky clear';
209
+    				} elseif ($type == 'CLR') {
210
+    					$cloud['type'] = 'No cloud below 12,000ft (3700m)';
211
+    				} elseif ($type == 'NSC') {
212
+    					$cloud['type'] = 'No significant cloud';
213
+    				} elseif ($type == 'FEW') {
214
+    					$cloud['type'] = 'Few';
215
+    				} elseif ($type == 'SCT') {
216
+    					$cloud['type'] = 'Scattered';
217
+    				} elseif ($type == 'BKN') {
218
+    					$cloud['type'] = 'Broken';
219
+    				} elseif ($type == 'OVC') {
220
+    					$cloud['type'] = 'Overcast/Full cloud coverage';
221
+    				} elseif ($type == 'VV') {
222
+    					$cloud['type'] = 'Vertical visibility';
223
+    				}
197 224
     				$cloud['type_code'] = $type;
198 225
     				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199 226
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
@@ -223,8 +250,11 @@  discard block
 block discarded – undo
223 250
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 251
     				//echo $piece;
225 252
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
253
+    				if (isset($matches[5])) {
254
+    					$range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
255
+    				} else {
256
+    					$range = array('exact' => (float)$matches[2], 'unit' => 'M');
257
+    				}
228 258
 				if (isset($matches[3])) {
229 259
 					$range = Array(
230 260
 					    'from' => (float)$matches[2],
@@ -257,8 +287,11 @@  discard block
 block discarded – undo
257 287
 				if (isset($matches[3])) {
258 288
 					$text[] = $this->texts[$matches[3]];
259 289
 				}
260
-				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261
-				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
290
+				if (!isset($result['weather'])) {
291
+					$result['weather'] = implode(' ', $text);
292
+				} else {
293
+					$result['weather'] = $result['weather'].' / '.implode(' ', $text);
294
+				}
262 295
     			}
263 296
     		}
264 297
     		return $result;
@@ -270,8 +303,11 @@  discard block
 block discarded – undo
270 303
     		if (isset($globalMETARcycle) && $globalMETARcycle) {
271 304
             		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272 305
                 } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
306
+            		if ($globalDBdriver == 'mysql') {
307
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
308
+            		} else {
309
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
310
+            		}
275 311
                 }
276 312
                 $query_values = array(':icao' => $icao);
277 313
                  try {
@@ -326,7 +362,9 @@  discard block
 block discarded – undo
326 362
         
327 363
         public function addMETARCycle() {
328 364
     		global $globalDebug, $globalIVAO, $globalTransaction;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
365
+    		if (isset($globalDebug) && $globalDebug) {
366
+    			echo "Downloading METAR cycle...";
367
+    		}
330 368
     		date_default_timezone_set("UTC");
331 369
     		$Common = new Common();
332 370
     		if (isset($globalIVAO) && $globalIVAO) {
@@ -339,33 +377,49 @@  discard block
 block discarded – undo
339 377
     			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340 378
     		}
341 379
     		if ($handle) {
342
-			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
380
+			if (isset($globalDebug) && $globalDebug) {
381
+				echo "Done - Updating DB...";
382
+			}
343 383
 			$date = '';
344 384
     			//foreach(explode("\n",$cycle) as $line) {
345
-    			if ($globalTransaction) $this->db->beginTransaction();
385
+    			if ($globalTransaction) {
386
+    				$this->db->beginTransaction();
387
+    			}
346 388
 	    		while(($line = fgets($handle,4096)) !== false) {
347 389
 				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
348 390
 					$date = $line;
349 391
     				} elseif ($line != '') {
350 392
     				    //$this->parse($line);
351
-    				    if ($date == '') $date = date('Y/m/d H:m');
393
+    				    if ($date == '') {
394
+    				    	$date = date('Y/m/d H:m');
395
+    				    }
352 396
         			    $pos = 0;
353 397
         			    $pieces = preg_split('/\s/',$line);
354
-        			    if ($pieces[0] == 'METAR') $pos++;
355
-        			    if (strlen($pieces[$pos]) != 4) $pos++;
398
+        			    if ($pieces[0] == 'METAR') {
399
+        			    	$pos++;
400
+        			    }
401
+        			    if (strlen($pieces[$pos]) != 4) {
402
+        			    	$pos++;
403
+        			    }
356 404
 		        	    $location = $pieces[$pos];
357 405
         	        	    echo $this->addMETAR($location,$line,$date);
358 406
     				}
359 407
     			}
360 408
     			fclose($handle);
361
-    			if ($globalTransaction) $this->db->commit();
409
+    			if ($globalTransaction) {
410
+    				$this->db->commit();
411
+    			}
412
+    		}
413
+    		if (isset($globalDebug) && $globalDebug) {
414
+    			echo "Done\n";
362 415
     		}
363
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
364 416
         
365 417
         }
366 418
         public function downloadMETAR($icao) {
367 419
     		global $globalMETARurl;
368
-    		if ($globalMETARurl == '') return array();
420
+    		if ($globalMETARurl == '') {
421
+    			return array();
422
+    		}
369 423
     		date_default_timezone_set("UTC");
370 424
     		$Common = new Common();
371 425
     		$url = str_replace('{icao}',$icao,$globalMETARurl);
@@ -379,16 +433,24 @@  discard block
 block discarded – undo
379 433
     			if ($line != '') {
380 434
     			    //$this->parse($line);
381 435
     			    //echo $line;
382
-    			    if ($date == '') $date = date('Y/m/d H:m');
436
+    			    if ($date == '') {
437
+    			    	$date = date('Y/m/d H:m');
438
+    			    }
383 439
     			    $pos = 0;
384 440
     			    $pieces = preg_split('/\s/',$line);
385
-    			    if ($pieces[0] == 'METAR') $pos++;
386
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
441
+    			    if ($pieces[0] == 'METAR') {
442
+    			    	$pos++;
443
+    			    }
444
+    			    if (strlen($pieces[$pos]) != 4) {
445
+    			    	$pos++;
446
+    			    }
387 447
 	        	    $location = $pieces[$pos];
388 448
 	        	    if (strlen($location == 4)) {
389 449
 	        		$this->addMETAR($location,$line,$date);
390 450
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
-	        	    } else return array();
451
+	        	    } else {
452
+	        	    	return array();
453
+	        	    }
392 454
     			}
393 455
     			//echo $line."\n";
394 456
     		}
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 1 patch
Braces   +37 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 			$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
24 24
 		}
25 25
 	}
26
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
26
+	if (is_array($globalFilter)) {
27
+		$filter = array_merge($filter,$globalFilter);
28
+	}
27 29
 	$filter_query_join = '';
28 30
 	$filter_query_where = '';
29 31
 	foreach($filters as $flt) {
@@ -74,8 +76,11 @@  discard block
 block discarded – undo
74 76
 		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
75 77
 	    }
76 78
 	}
77
-	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
78
-	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
79
+	if ($filter_query_where == '' && $where) {
80
+		$filter_query_where = ' WHERE';
81
+	} elseif ($filter_query_where != '' && $and) {
82
+		$filter_query_where .= ' AND';
83
+	}
79 84
 	$filter_query = $filter_query_join.$filter_query_where;
80 85
 	return $filter_query;
81 86
     }
@@ -86,10 +91,17 @@  discard block
 block discarded – undo
86 91
 		if ($over_country == '') {
87 92
 			$Spotter = new Spotter($this->db);
88 93
 			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
89
-			if (!empty($data_country)) $country = $data_country['iso2'];
90
-			else $country = '';
91
-		} else $country = $over_country;
92
-		if ($airline_type === NULL) $airline_type ='';
94
+			if (!empty($data_country)) {
95
+				$country = $data_country['iso2'];
96
+			} else {
97
+				$country = '';
98
+			}
99
+		} else {
100
+			$country = $over_country;
101
+		}
102
+		if ($airline_type === NULL) {
103
+			$airline_type ='';
104
+		}
93 105
 	
94 106
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
95 107
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
@@ -592,7 +604,9 @@  discard block
 block discarded – undo
592 604
 		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
593 605
 		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
594 606
 		    $translate = $Translation->ident2icao($q_item);
595
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
607
+		    if ($translate != $q_item) {
608
+		    	$additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
609
+		    }
596 610
 		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
597 611
 		    $additional_query .= ")";
598 612
 		}
@@ -810,7 +824,9 @@  discard block
 block discarded – undo
810 824
 		date_default_timezone_set($globalTimezone);
811 825
 		$datetime = new DateTime();
812 826
 		$offset = $datetime->format('P');
813
-	    } else $offset = '+00:00';
827
+	    } else {
828
+	    	$offset = '+00:00';
829
+	    }
814 830
 
815 831
 
816 832
 	    if ($date_array[1] != "")
@@ -1084,9 +1100,13 @@  discard block
 block discarded – undo
1084 1100
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1085 1101
 			}
1086 1102
 		}
1087
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1103
+                if ($sincedate != '') {
1104
+                	$query .= "AND date > '".$sincedate."' ";
1105
+                }
1088 1106
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1089
-	if ($limit) $query .= " LIMIT 0,10";
1107
+	if ($limit) {
1108
+		$query .= " LIMIT 0,10";
1109
+	}
1090 1110
       
1091 1111
 	
1092 1112
 	$sth = $this->db->prepare($query);
@@ -1130,9 +1150,13 @@  discard block
 block discarded – undo
1130 1150
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1131 1151
 			}
1132 1152
 		}
1133
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1153
+                if ($sincedate != '') {
1154
+                	$query .= "AND s.date > '".$sincedate."' ";
1155
+                }
1134 1156
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1135
-	if ($limit) $query .= " LIMIT 0,10";
1157
+	if ($limit) {
1158
+		$query .= " LIMIT 0,10";
1159
+	}
1136 1160
       
1137 1161
 	
1138 1162
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
statistics.php 1 patch
Braces   +103 added lines, -42 removed lines patch added patch discarded remove patch
@@ -6,11 +6,15 @@  discard block
 block discarded – undo
6 6
 $beginpage = microtime(true);
7 7
 $Stats = new Stats();
8 8
 
9
-if (!isset($filter_name)) $filter_name = '';
9
+if (!isset($filter_name)) {
10
+	$filter_name = '';
11
+}
10 12
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11 13
 if ($airline_icao == '' && isset($globalFilter)) {
12
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13
-}
14
+	if (isset($globalFilter['airline'])) {
15
+		$airline_icao = $globalFilter['airline'][0];
16
+	}
17
+	}
14 18
 if ($airline_icao != '' && $airline_icao != 'all') {
15 19
 	$Spotter = new Spotter();
16 20
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -36,14 +40,21 @@  discard block
 block discarded – undo
36 40
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/justgage.js"></script>
37 41
 <div class="column">
38 42
     <div class="info">
39
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
43
+            <h1><?php if (isset($airline_name)) {
44
+	echo _("Statistics for ").$airline_name;
45
+} else {
46
+	echo _("Statistics");
47
+}
48
+?></h1>
40 49
     <?php 
41 50
 	$last_update = $Stats->getLastStatsUpdate();
42 51
 	//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
43 52
 	if (isset($last_update[0]['value'])) {
44 53
 		date_default_timezone_set('UTC');
45 54
 		$lastupdate = strtotime($last_update[0]['value']);
46
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
55
+		if (isset($globalTimezone) && $globalTimezone != '') {
56
+			date_default_timezone_set($globalTimezone);
57
+		}
47 58
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
48 59
 	}
49 60
     ?>
@@ -95,8 +106,9 @@  discard block
 block discarded – undo
95 106
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
96 107
                  <?php
97 108
                   $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
98
-		    if (count($aircraft_array) == 0) print _("No data available");
99
-		    else {
109
+		    if (count($aircraft_array) == 0) {
110
+		    	print _("No data available");
111
+		    } else {
100 112
 
101 113
                     print '<div id="chart1" class="chart" width="100%"></div>
102 114
                     <script> 
@@ -133,11 +145,17 @@  discard block
 block discarded – undo
133 145
             	    <?php
134 146
             		if ($year != '' && $month != '') {
135 147
             	    ?>
136
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
148
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
149
+	echo '/'.$airline_icao;
150
+}
151
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
137 152
             	    <?php
138 153
             		} else {
139 154
             	    ?>
140
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
155
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
156
+	echo '/'.$airline_icao;
157
+}
158
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
141 159
             	    <?php
142 160
             		}
143 161
             	    ?>
@@ -182,11 +200,15 @@  discard block
 block discarded – undo
182 200
                   </script>';
183 201
 	    if ($year != '' && $month != '') {
184 202
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
185
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
203
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
204
+			echo '/'.$airline_icao;
205
+		}
186 206
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
187 207
 	    } else {
188 208
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
189
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
209
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
210
+			echo '/'.$airline_icao;
211
+		}
190 212
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
191 213
 	    }
192 214
     	    print '</div>';
@@ -210,8 +232,9 @@  discard block
 block discarded – undo
210 232
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
211 233
 <?php
212 234
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
213
-	if (count($pilot_array) == 0) print _("No data available");
214
-	else {
235
+	if (count($pilot_array) == 0) {
236
+		print _("No data available");
237
+	} else {
215 238
 	    print '<div id="chart7" class="chart" width="100%"></div>
216 239
                     <script> 
217 240
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -244,7 +267,9 @@  discard block
 block discarded – undo
244 267
         }
245 268
         print '<div class="more">';
246 269
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
247
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
270
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
271
+		echo '/'.$airline_icao;
272
+	}
248 273
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
249 274
 	print '</div>';
250 275
 ?>
@@ -258,8 +283,9 @@  discard block
 block discarded – undo
258 283
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
259 284
 <?php
260 285
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
261
-	if (count($owner_array) == 0) print _("No data available");
262
-	else {
286
+	if (count($owner_array) == 0) {
287
+		print _("No data available");
288
+	} else {
263 289
 	    print '<div id="chart7" class="chart" width="100%"></div>
264 290
                     <script> 
265 291
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -292,7 +318,10 @@  discard block
 block discarded – undo
292 318
 	}
293 319
 ?>
294 320
                 <div class="more">
295
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
321
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
322
+	echo '/'.$airline_icao;
323
+}
324
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
296 325
                 </div>
297 326
             </div>
298 327
         
@@ -305,8 +334,9 @@  discard block
 block discarded – undo
305 334
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
306 335
 <?php
307 336
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
308
-	if (count($flightover_array) == 0) print _("No data available");
309
-	else {
337
+	if (count($flightover_array) == 0) {
338
+		print _("No data available");
339
+	} else {
310 340
 	    print '<div id="chart10" class="chart" width="100%"></div>
311 341
                     <script> 
312 342
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -341,7 +371,10 @@  discard block
 block discarded – undo
341 371
 	}
342 372
 ?>
343 373
                 <div class="more">
344
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
374
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
375
+	echo '/'.$airline_icao;
376
+}
377
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
345 378
                 </div>
346 379
             </div>
347 380
 <?php
@@ -394,7 +427,9 @@  discard block
 block discarded – undo
394 427
               }
395 428
                 </script>';
396 429
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
397
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
430
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
431
+		echo '/'.$airline_icao;
432
+	}
398 433
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
399 434
     }
400 435
 ?>
@@ -441,7 +476,9 @@  discard block
 block discarded – undo
441 476
               }
442 477
                 </script>';
443 478
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
444
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
479
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
480
+		echo '/'.$airline_icao;
481
+	}
445 482
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
446 483
     }
447 484
 ?>
@@ -456,8 +493,9 @@  discard block
 block discarded – undo
456 493
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
457 494
                 <?php
458 495
                   $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
459
-		    if (count($year_array) == 0) print _("No data available");
460
-		    else {
496
+		    if (count($year_array) == 0) {
497
+		    	print _("No data available");
498
+		    } else {
461 499
                   print '<div id="chart8" class="chart" width="100%"></div>
462 500
                     <script> 
463 501
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -493,7 +531,10 @@  discard block
 block discarded – undo
493 531
                   }
494 532
                   ?>
495 533
                 <div class="more">
496
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
534
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
535
+	echo '/'.$airline_icao;
536
+}
537
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 538
                 </div>
498 539
             </div>
499 540
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -501,8 +542,9 @@  discard block
 block discarded – undo
501 542
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
502 543
                 <?php
503 544
                   $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
504
-		    if (count($month_array) == 0) print _("No data available");
505
-		    else {
545
+		    if (count($month_array) == 0) {
546
+		    	print _("No data available");
547
+		    } else {
506 548
                   print '<div id="chart9" class="chart" width="100%"></div>
507 549
                     <script> 
508 550
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -538,7 +580,10 @@  discard block
 block discarded – undo
538 580
                   }
539 581
                   ?>
540 582
                 <div class="more">
541
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
583
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
584
+	echo '/'.$airline_icao;
585
+}
586
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
542 587
                 </div>
543 588
             </div>
544 589
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -547,8 +592,9 @@  discard block
 block discarded – undo
547 592
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
548 593
                 <?php
549 594
                     $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
550
-		    if (empty($date_array)) print _("No data available");
551
-		    else {
595
+		    if (empty($date_array)) {
596
+		    	print _("No data available");
597
+		    } else {
552 598
                   print '<div id="chart5" class="chart" width="100%"></div>
553 599
                     <script> 
554 600
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -585,7 +631,10 @@  discard block
 block discarded – undo
585 631
                   }
586 632
                   ?>
587 633
                 <div class="more">
588
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
634
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
635
+	echo '/'.$airline_icao;
636
+}
637
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
589 638
                 </div>
590 639
             </div>
591 640
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -593,8 +642,9 @@  discard block
 block discarded – undo
593 642
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
594 643
                 <?php
595 644
                   $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
596
-		    if (empty($hour_array)) print _("No data available");
597
-		    else {
645
+		    if (empty($hour_array)) {
646
+		    	print _("No data available");
647
+		    } else {
598 648
 
599 649
                   print '<div id="chart6" class="chart" width="100%"></div>
600 650
                     <script> 
@@ -631,7 +681,10 @@  discard block
 block discarded – undo
631 681
                   }
632 682
                 ?>
633 683
                 <div class="more">
634
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
684
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
685
+	echo '/'.$airline_icao;
686
+}
687
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
635 688
                 </div>
636 689
             </div>
637 690
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -650,8 +703,9 @@  discard block
 block discarded – undo
650 703
 		    require_once('require/class.Accident.php');
651 704
             	    $Accident = new Accident();
652 705
                   $year_array = $Accident->countFatalitiesByYear($filter_name);
653
-		    if (count($year_array) == 0) print _("No data available");
654
-		    else {
706
+		    if (count($year_array) == 0) {
707
+		    	print _("No data available");
708
+		    } else {
655 709
                   print '<div id="chart32" class="chart" width="100%"></div>
656 710
                     <script> 
657 711
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -699,8 +753,9 @@  discard block
 block discarded – undo
699 753
 		    require_once('require/class.Accident.php');
700 754
             	    $Accident = new Accident();
701 755
                   $year_array = $Accident->countFatalitiesLast12Months($filter_name);
702
-		    if (count($year_array) == 0) print _("No data available");
703
-		    else {
756
+		    if (count($year_array) == 0) {
757
+		    	print _("No data available");
758
+		    } else {
704 759
                   print '<div id="chart33" class="chart" width="100%"></div>
705 760
                     <script> 
706 761
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -776,8 +831,11 @@  discard block
 block discarded – undo
776 831
 					$distance = $distance;
777 832
 					$unit = 'km';
778 833
 				}
779
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
780
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
834
+        			if (!isset($polar_data)) {
835
+        				$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
836
+        			} else {
837
+        	    			$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
838
+        	    		}
781 839
         		    }
782 840
         	?>
783 841
             <div class="col-md-6">
@@ -829,8 +887,11 @@  discard block
 block discarded – undo
829 887
         		foreach ($msg as $eachmsg) {
830 888
         		    //$eachmsg = $msg[0];
831 889
         		    $data = $eachmsg['source_data'];
832
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
833
-        		    else $max = 500;
890
+        		    if ($data > 500) {
891
+        		    	$max = (round(($data+100)/100))*100;
892
+        		    } else {
893
+        		    	$max = 500;
894
+        		    }
834 895
         	?>
835 896
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
836 897
         	<script>
Please login to merge, or discard this patch.
pilot-detailed.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,8 +53,12 @@  discard block
 block discarded – undo
53 53
 	{
54 54
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
55 55
 		$ident = $spotter_array[0]['ident'];
56
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
57
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
56
+		if (isset($spotter_array[0]['latitude'])) {
57
+			$latitude = $spotter_array[0]['latitude'];
58
+		}
59
+		if (isset($spotter_array[0]['longitude'])) {
60
+			$longitude = $spotter_array[0]['longitude'];
61
+		}
58 62
 		require_once('header.php');
59 63
 		/*
60 64
 		if (isset($globalArchive) && $globalArchive) {
@@ -107,7 +111,9 @@  discard block
 block discarded – undo
107 111
 		*/
108 112
 		print '<div class="info column">';
109 113
 		print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>';
110
-		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
114
+		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') {
115
+			print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
116
+		}
111 117
 		$Stats = new Stats();
112 118
 		$flights = $Stats->getStatsPilot($pilot);
113 119
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +324 added lines, -115 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 	$dbc = $this->db;
54 54
 	$this->all_flights[$id]['schedule_check'] = true;
55 55
 	if ($globalSchedulesFetch) {
56
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
56
+	if ($globalDebug) {
57
+		echo 'Getting schedule info...'."\n";
58
+	}
57 59
 	$Spotter = new Spotter($dbc);
58 60
 	$Schedule = new Schedule($dbc);
59 61
 	$Translation = new Translation($dbc);
@@ -64,7 +66,9 @@  discard block
 block discarded – undo
64 66
 	    if ($Schedule->checkSchedule($operator) == 0) {
65 67
 		$schedule = $Schedule->fetchSchedule($operator);
66 68
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
67
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
69
+		    if ($globalDebug) {
70
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
71
+		    }
68 72
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69 73
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
70 74
 		    // Should also check if route schedule = route from DB
@@ -73,7 +77,9 @@  discard block
 block discarded – undo
73 77
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
74 78
 			    if (trim($airport_icao) != '') {
75 79
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
76
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
80
+				if ($globalDebug) {
81
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
82
+				}
77 83
 			    }
78 84
 			}
79 85
 		    }
@@ -82,17 +88,25 @@  discard block
 block discarded – undo
82 88
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
83 89
 			    if (trim($airport_icao) != '') {
84 90
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
85
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
91
+				if ($globalDebug) {
92
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
93
+				}
86 94
 			    }
87 95
 			}
88 96
 		    }
89 97
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
90 98
 		}
91
-	    } else $scheduleexist = true;
92
-	} else $scheduleexist = true;
99
+	    } else {
100
+	    	$scheduleexist = true;
101
+	    }
102
+	} else {
103
+		$scheduleexist = true;
104
+	}
93 105
 	// close connection, at least one way will work ?
94 106
        if ($scheduleexist) {
95
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
107
+		if ($globalDebug) {
108
+			echo "-> get arrival/departure airport info for ".$ident."\n";
109
+		}
96 110
     		$sch = $Schedule->getSchedule($operator);
97 111
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
98 112
        }
@@ -114,7 +128,9 @@  discard block
 block discarded – undo
114 128
 
115 129
     public function checkAll() {
116 130
 	global $globalDebug;
117
-	if ($globalDebug) echo "Update last seen flights data...\n";
131
+	if ($globalDebug) {
132
+		echo "Update last seen flights data...\n";
133
+	}
118 134
 	foreach ($this->all_flights as $key => $flight) {
119 135
 	    if (isset($this->all_flights[$key]['id'])) {
120 136
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
@@ -127,24 +143,32 @@  discard block
 block discarded – undo
127 143
 
128 144
     public function arrival($key) {
129 145
 	global $globalClosestMinDist, $globalDebug;
130
-	if ($globalDebug) echo 'Update arrival...'."\n";
146
+	if ($globalDebug) {
147
+		echo 'Update arrival...'."\n";
148
+	}
131 149
 	$Spotter = new Spotter($this->db);
132 150
         $airport_icao = '';
133 151
         $airport_time = '';
134
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
152
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
153
+        	$globalClosestMinDist = 50;
154
+        }
135 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
136 156
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
137 157
     	    if (isset($closestAirports[0])) {
138 158
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139 159
         	    $airport_icao = $closestAirports[0]['icao'];
140 160
         	    $airport_time = $this->all_flights[$key]['datetime'];
141
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
161
+        	    if ($globalDebug) {
162
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
163
+        	    }
142 164
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
143 165
         	    foreach ($closestAirports as $airport) {
144 166
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
145 167
         		    $airport_icao = $airport['icao'];
146 168
         		    $airport_time = $this->all_flights[$key]['datetime'];
147
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
+        		    if ($globalDebug) {
170
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
171
+        		    }
148 172
         		    break;
149 173
         		}
150 174
         	    }
@@ -152,14 +176,20 @@  discard block
 block discarded – undo
152 176
         		$airport_icao = $closestAirports[0]['icao'];
153 177
         		$airport_time = $this->all_flights[$key]['datetime'];
154 178
         	} else {
155
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
179
+        		if ($globalDebug) {
180
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
181
+        		}
156 182
         	}
157 183
     	    } else {
158
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
184
+    		    if ($globalDebug) {
185
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
186
+    		    }
159 187
     	    }
160 188
 
161 189
         } else {
162
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
190
+        	if ($globalDebug) {
191
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
192
+        	}
163 193
         }
164 194
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
165 195
     }
@@ -169,12 +199,16 @@  discard block
 block discarded – undo
169 199
     public function del() {
170 200
 	global $globalDebug;
171 201
 	// Delete old infos
172
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
202
+	if ($globalDebug) {
203
+		echo 'Delete old values and update latest data...'."\n";
204
+	}
173 205
 	foreach ($this->all_flights as $key => $flight) {
174 206
     	    if (isset($flight['lastupdate'])) {
175 207
         	if ($flight['lastupdate'] < (time()-3000)) {
176 208
             	    if (isset($this->all_flights[$key]['id'])) {
177
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
209
+            		if ($globalDebug) {
210
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
211
+            		}
178 212
 			/*
179 213
 			$SpotterLive = new SpotterLive();
180 214
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -184,7 +218,9 @@  discard block
 block discarded – undo
184 218
             		$Spotter = new Spotter($this->db);
185 219
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
186 220
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
187
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
221
+				if ($globalDebug && $result != 'success') {
222
+					echo '!!! ERROR : '.$result."\n";
223
+				}
188 224
 			}
189 225
 			// Put in archive
190 226
 //			$Spotter->db = null;
@@ -198,8 +234,10 @@  discard block
 block discarded – undo
198 234
     public function add($line) {
199 235
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights;
200 236
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
201
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
202
-/*
237
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
238
+		$globalCoordMinChange = '0.02';
239
+	}
240
+	/*
203 241
 	$Spotter = new Spotter();
204 242
 	$dbc = $Spotter->db;
205 243
 	$SpotterLive = new SpotterLive($dbc);
@@ -227,11 +265,15 @@  discard block
 block discarded – undo
227 265
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
228 266
 		    $current_date = date('Y-m-d');
229 267
 		    $source = $line['source_name'];
230
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
268
+		    if ($source == '' || $line['format_source'] == 'aprs') {
269
+		    	$source = $line['format_source'];
270
+		    }
231 271
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
232 272
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
233 273
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
234
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
274
+		    } else {
275
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
276
+		    }
235 277
 		}
236 278
 		
237 279
 		/*
@@ -247,8 +289,11 @@  discard block
 block discarded – undo
247 289
 		//$this->db = $dbc;
248 290
 
249 291
 		$hex = trim($line['hex']);
250
-	        if (!isset($line['id'])) $id = trim($line['hex']);
251
-	        else $id = trim($line['id']);
292
+	        if (!isset($line['id'])) {
293
+	        	$id = trim($line['hex']);
294
+	        } else {
295
+	        	$id = trim($line['id']);
296
+	        }
252 297
 		
253 298
 		//print_r($this->all_flights);
254 299
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
@@ -263,13 +308,20 @@  discard block
 block discarded – undo
263 308
 			$Spotter = new Spotter($this->db);
264 309
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
265 310
 			$Spotter->db = null;
266
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
311
+			if ($globalDebugTimeElapsed) {
312
+				echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
+			}
267 314
 
268 315
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
269
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
270
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
271
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
272
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
316
+			    if ($line['aircraft_type'] == 'PARA_GLIDER') {
317
+			    	$aircraft_icao = 'GLID';
318
+			    } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
319
+			    	$aircraft_icao = 'UHEL';
320
+			    } elseif ($line['aircraft_type'] == 'TOW_PLANE') {
321
+			    	$aircraft_icao = 'TOWPLANE';
322
+			    } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
323
+			    	$aircraft_icao = 'POWAIRC';
324
+			    }
273 325
 			}
274 326
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
275 327
 		    } else if (isset($line['aircraft_name'])) {
@@ -277,21 +329,36 @@  discard block
 block discarded – undo
277 329
 			$Spotter = new Spotter($this->db);
278 330
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
279 331
 			$Spotter->db = null;
280
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
281
-			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
282
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
332
+			if ($aircraft_icao != '') {
333
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
334
+			} else {
335
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
336
+			}
337
+		    } else {
338
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
339
+		    }
283 340
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
284 341
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
285 342
 		    if (!isset($line['id'])) {
286
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
287
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
343
+			if (!isset($globalDaemon)) {
344
+				$globalDaemon = TRUE;
345
+			}
346
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
288 347
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
289
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
348
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
349
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
350
+			}
290 351
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
291
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
352
+		     } else {
353
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
354
+		     }
292 355
 
293
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
294
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
356
+		    if ($globalDebug) {
357
+		    	echo "*********** New aircraft hex : ".$hex." ***********\n";
358
+		    }
359
+		    if ($globalAllFlights !== FALSE) {
360
+		    	$dataFound = true;
361
+		    }
295 362
 		}
296 363
 		
297 364
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
@@ -299,8 +366,11 @@  discard block
 block discarded – undo
299 366
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
300 367
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301 368
 		    } else {
302
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
303
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
369
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
370
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
371
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
372
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
373
+				}
304 374
 				/*
305 375
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
306 376
 				print_r($this->all_flights[$id]);
@@ -332,15 +402,25 @@  discard block
 block discarded – undo
332 402
 			$timeelapsed = microtime(true);
333 403
             		$Spotter = new Spotter($this->db);
334 404
             		$fromsource = NULL;
335
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
336
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
337
-			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
338
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
339
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
405
+            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
406
+            			$fromsource = $globalAirlinesSource;
407
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
408
+            			$fromsource = 'vatsim';
409
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
410
+				$fromsource = 'ivao';
411
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
412
+				$fromsource = 'vatsim';
413
+			} elseif (isset($globalIVAO) && $globalIVAO) {
414
+				$fromsource = 'ivao';
415
+			}
340 416
             		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
341
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
417
+			if ($globalDebug && $result != 'success') {
418
+				echo '!!! ERROR : '.$result."\n";
419
+			}
342 420
 			$Spotter->db = null;
343
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
421
+			if ($globalDebugTimeElapsed) {
422
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
423
+			}
344 424
 		    }
345 425
 
346 426
 /*
@@ -351,7 +431,9 @@  discard block
 block discarded – undo
351 431
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
352 432
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
353 433
   */
354
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
434
+		    if (!isset($this->all_flights[$id]['id'])) {
435
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
436
+		    }
355 437
 
356 438
 		    //$putinarchive = true;
357 439
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -368,7 +450,9 @@  discard block
 block discarded – undo
368 450
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
369 451
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
370 452
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
371
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
453
+				if ($globalDebugTimeElapsed) {
454
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
455
+				}
372 456
 
373 457
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
374 458
 			$timeelapsed = microtime(true);
@@ -381,7 +465,9 @@  discard block
 block discarded – undo
381 465
 				$Translation->db = null;
382 466
 			}
383 467
 			$Spotter->db = null;
384
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
468
+			if ($globalDebugTimeElapsed) {
469
+				echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
470
+			}
385 471
 
386 472
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
387 473
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -390,9 +476,13 @@  discard block
 block discarded – undo
390 476
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
391 477
 		    	    }
392 478
 			}
393
-			if (!isset($globalFork)) $globalFork = TRUE;
479
+			if (!isset($globalFork)) {
480
+				$globalFork = TRUE;
481
+			}
394 482
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
395
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
483
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
484
+					$this->get_Schedule($id,trim($line['ident']));
485
+				}
396 486
 			}
397 487
 		    }
398 488
 		}
@@ -408,16 +498,23 @@  discard block
 block discarded – undo
408 498
 		    // use datetime
409 499
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
410 500
 			$speed = $speed*3.6;
411
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
412
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
501
+			if ($speed < 1000) {
502
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
503
+			}
504
+  			if ($globalDebug) {
505
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
506
+  			}
413 507
 		    }
414 508
 		}
415 509
 
416 510
 
417 511
 
418 512
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
419
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
420
-	    	    else unset($timediff);
513
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
514
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
515
+	    	    } else {
516
+	    	    	unset($timediff);
517
+	    	    }
421 518
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
422 519
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
423 520
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -425,21 +522,31 @@  discard block
 block discarded – undo
425 522
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
426 523
 				$this->all_flights[$id]['putinarchive'] = true;
427 524
 				
428
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
525
+				if ($globalDebug) {
526
+					echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
527
+				}
429 528
 				$timeelapsed = microtime(true);
430 529
 				$Spotter = new Spotter($this->db);
431 530
 				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
432
-				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
531
+				if (!empty($all_country)) {
532
+					$this->all_flights[$id]['over_country'] = $all_country['iso2'];
533
+				}
433 534
 				$Spotter->db = null;
434
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
535
+				if ($globalDebugTimeElapsed) {
536
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
537
+				}
435 538
 				$this->tmd = 0;
436
-				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
539
+				if ($globalDebug) {
540
+					echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
541
+				}
437 542
 			    }
438 543
 			}
439 544
 
440 545
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
441 546
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
442
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
547
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
548
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
549
+				}
443 550
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
444 551
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
445 552
 				    $dataFound = true;
@@ -461,9 +568,13 @@  discard block
 block discarded – undo
461 568
 			    */
462 569
 			}
463 570
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
464
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
571
+			    if ($line['longitude'] > 180) {
572
+			    	$line['longitude'] = $line['longitude'] - 360;
573
+			    }
465 574
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
466
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
575
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
576
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
577
+				}
467 578
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
468 579
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
469 580
 				    $dataFound = true;
@@ -494,7 +605,9 @@  discard block
 block discarded – undo
494 605
 		    }
495 606
 		}
496 607
 		if (isset($line['last_update']) && $line['last_update'] != '') {
497
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
608
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
609
+		    	$dataFound = true;
610
+		    }
498 611
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
499 612
 		}
500 613
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -516,11 +629,17 @@  discard block
 block discarded – undo
516 629
 			// Here we force archive of flight because after ground it's a new one (or should be)
517 630
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
518 631
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
519
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
520
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
521
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
632
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
633
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
634
+			} elseif (isset($line['id'])) {
635
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
636
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
637
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
638
+			}
639
+		    }
640
+		    if ($line['ground'] != 1) {
641
+		    	$line['ground'] = 0;
522 642
 		    }
523
-		    if ($line['ground'] != 1) $line['ground'] = 0;
524 643
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
525 644
 		    //$dataFound = true;
526 645
 		}
@@ -528,28 +647,40 @@  discard block
 block discarded – undo
528 647
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
529 648
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
530 649
 			    $highlight = '';
531
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
532
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
533
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
650
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
651
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
652
+			    }
653
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
654
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
655
+			    }
656
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
657
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
658
+			    }
534 659
 			    if ($highlight != '') {
535 660
 				$timeelapsed = microtime(true);
536 661
 				$Spotter = new Spotter($this->db);
537 662
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
538 663
 				$Spotter->db = null;
539
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
664
+				if ($globalDebugTimeElapsed) {
665
+					echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
666
+				}
540 667
 
541 668
 				$this->all_flights[$id]['putinarchive'] = true;
542 669
 				//$putinarchive = true;
543 670
 				//$highlight = '';
544 671
 			    }
545 672
 			    
546
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
673
+		    } else {
674
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
675
+		    }
547 676
 		    //$dataFound = true;
548 677
 		}
549 678
 
550 679
 		if (isset($line['altitude']) && $line['altitude'] != '') {
551 680
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
552
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
681
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) {
682
+				$this->all_flights[$id]['putinarchive'] = true;
683
+			}
553 684
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
554 685
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
555 686
 			//$dataFound = true;
@@ -561,21 +692,30 @@  discard block
 block discarded – undo
561 692
 		}
562 693
 		
563 694
 		if (isset($line['heading']) && $line['heading'] != '') {
564
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
695
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) {
696
+		    	$this->all_flights[$id]['putinarchive'] = true;
697
+		    }
565 698
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
566 699
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
567 700
 		    //$dataFound = true;
568 701
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
569 702
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
570 703
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
571
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
572
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
704
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) {
705
+		    	$this->all_flights[$id]['putinarchive'] = true;
706
+		    }
707
+  		    if ($globalDebug) {
708
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
709
+  		    }
573 710
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
574 711
   		    // If not enough messages and ACARS set heading to 0
575 712
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
576 713
   		}
577
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
578
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
714
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
715
+			$dataFound = false;
716
+		} elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
717
+			$dataFound = false;
718
+		}
579 719
 
580 720
 //		print_r($this->all_flights[$id]);
581 721
 		//gets the callsign from the last hour
@@ -590,23 +730,36 @@  discard block
 block discarded – undo
590 730
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
591 731
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
592 732
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
593
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
733
+				if ($globalDebug) {
734
+					echo "Check if aircraft is already in DB...";
735
+				}
594 736
 				$timeelapsed = microtime(true);
595 737
 				$SpotterLive = new SpotterLive($this->db);
596 738
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
597 739
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
598
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
740
+				    if ($globalDebugTimeElapsed) {
741
+				    	echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
742
+				    }
599 743
 				} elseif (isset($line['id'])) {
600 744
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
601
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
745
+				    if ($globalDebugTimeElapsed) {
746
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
747
+				    }
602 748
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
603 749
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
604
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
605
-				} else $recent_ident = '';
750
+				    if ($globalDebugTimeElapsed) {
751
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
752
+				    }
753
+				} else {
754
+					$recent_ident = '';
755
+				}
606 756
 				$SpotterLive->db=null;
607 757
 
608
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
609
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
758
+				if ($globalDebug && $recent_ident == '') {
759
+					echo " Not in DB.\n";
760
+				} elseif ($globalDebug && $recent_ident != '') {
761
+					echo " Already in DB.\n";
762
+				}
610 763
 			    } else {
611 764
 				$recent_ident = '';
612 765
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -614,7 +767,9 @@  discard block
 block discarded – undo
614 767
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
615 768
 			    if($recent_ident == "")
616 769
 			    {
617
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
770
+				if ($globalDebug) {
771
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
772
+				}
618 773
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
619 774
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
620 775
 				//adds the spotter data for the archive
@@ -658,26 +813,44 @@  discard block
 block discarded – undo
658 813
 				
659 814
 				if (!$ignoreImport) {
660 815
 				    $highlight = '';
661
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
662
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
663
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
664
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
816
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
817
+				    	$highlight = 'Squawk 7500 : Hijack';
818
+				    }
819
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
820
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
821
+				    }
822
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
823
+				    	$highlight = 'Squawk 7700 : Emergency';
824
+				    }
825
+				    if (!isset($this->all_flights[$id]['id'])) {
826
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
827
+				    }
665 828
 				    $timeelapsed = microtime(true);
666 829
 				    $Spotter = new Spotter($this->db);
667 830
 				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
668 831
 				    $Spotter->db = null;
669
-				    if ($globalDebug && isset($result)) echo $result."\n";
670
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
832
+				    if ($globalDebug && isset($result)) {
833
+				    	echo $result."\n";
834
+				    }
835
+				    if ($globalDebugTimeElapsed) {
836
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
837
+				    }
671 838
 				    
672 839
 				    // Add source stat in DB
673 840
 				    $Stats = new Stats($this->db);
674 841
 				    if (!empty($this->stats)) {
675
-					if ($globalDebug) echo 'Add source stats : ';
842
+					if ($globalDebug) {
843
+						echo 'Add source stats : ';
844
+					}
676 845
 				        foreach($this->stats as $date => $data) {
677 846
 					    foreach($data as $source => $sourced) {
678 847
 					        //print_r($sourced);
679
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
680
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
848
+				    	        if (isset($sourced['polar'])) {
849
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
850
+				    	        }
851
+				    	        if (isset($sourced['hist'])) {
852
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
853
+				    	        }
681 854
 				    		if (isset($sourced['msg'])) {
682 855
 				    		    if (time() - $sourced['msg']['date'] > 10) {
683 856
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -690,13 +863,17 @@  discard block
 block discarded – undo
690 863
 			    			unset($this->stats[$date]);
691 864
 			    		    }
692 865
 				    	}
693
-				    	if ($globalDebug) echo 'Done'."\n";
866
+				    	if ($globalDebug) {
867
+				    		echo 'Done'."\n";
868
+				    	}
694 869
 
695 870
 				    }
696 871
 				    $Stats->db = null;
697 872
 				    
698 873
 				    $this->del();
699
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
874
+				} elseif ($globalDebug) {
875
+					echo 'Ignore data'."\n";
876
+				}
700 877
 				//$ignoreImport = false;
701 878
 				$this->all_flights[$id]['addedSpotter'] = 1;
702 879
 				//print_r($this->all_flights[$id]);
@@ -713,12 +890,16 @@  discard block
 block discarded – undo
713 890
 			*/
714 891
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
715 892
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
716
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
893
+				    if ($globalDebug) {
894
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
895
+				    }
717 896
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
718 897
 				    $SpotterLive = new SpotterLive($this->db);
719 898
 				    $SpotterLive->deleteLiveSpotterData();
720 899
 				    $SpotterLive->db=null;
721
-				    if ($globalDebug) echo " Done\n";
900
+				    if ($globalDebug) {
901
+				    	echo " Done\n";
902
+				    }
722 903
 				    $this->last_delete = time();
723 904
 				}
724 905
 			    } else {
@@ -741,11 +922,17 @@  discard block
 block discarded – undo
741 922
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
742 923
 		    if ($globalDebug) {
743 924
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
744
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
745
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
925
+				if (isset($this->all_flights[$id]['source_name'])) {
926
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
927
+				} else {
928
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
929
+				}
746 930
 			} else {
747
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
748
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
931
+				if (isset($this->all_flights[$id]['source_name'])) {
932
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
933
+				} else {
934
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
935
+				}
749 936
 			}
750 937
 		    }
751 938
 		    $ignoreImport = false;
@@ -791,19 +978,25 @@  discard block
 block discarded – undo
791 978
 
792 979
 		    if (!$ignoreImport) {
793 980
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
794
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
981
+				if ($globalDebug) {
982
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
983
+				}
795 984
 				$timeelapsed = microtime(true);
796 985
 				$SpotterLive = new SpotterLive($this->db);
797 986
 				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
798 987
 				$SpotterLive->db = null;
799
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
988
+				if ($globalDebugTimeElapsed) {
989
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
990
+				}
800 991
 
801 992
 				// Put statistics in $this->stats variable
802 993
 				//if ($line['format_source'] != 'aprs') {
803 994
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
804 995
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
805 996
 					$source = $this->all_flights[$id]['source_name'];
806
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
997
+					if ($source == '') {
998
+						$source = $this->all_flights[$id]['format_source'];
999
+					}
807 1000
 					if (!isset($this->source_location[$source])) {
808 1001
 						$Location = new Source();
809 1002
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -824,7 +1017,9 @@  discard block
 block discarded – undo
824 1017
 					$stats_heading = round($stats_heading/22.5);
825 1018
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
826 1019
 					$current_date = date('Y-m-d');
827
-					if ($stats_heading == 16) $stats_heading = 0;
1020
+					if ($stats_heading == 16) {
1021
+						$stats_heading = 0;
1022
+					}
828 1023
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
829 1024
 						for ($i=0;$i<=15;$i++) {
830 1025
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -842,7 +1037,9 @@  discard block
 block discarded – undo
842 1037
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
843 1038
 						    end($this->stats[$current_date][$source]['hist']);
844 1039
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
845
-						} else $mini = 0;
1040
+						} else {
1041
+							$mini = 0;
1042
+						}
846 1043
 						for ($i=$mini;$i<=$distance;$i+=10) {
847 1044
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
848 1045
 						}
@@ -853,20 +1050,30 @@  discard block
 block discarded – undo
853 1050
 				}
854 1051
 
855 1052
 				$this->all_flights[$id]['lastupdate'] = time();
856
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1053
+				if ($this->all_flights[$id]['putinarchive']) {
1054
+					$send = true;
1055
+				}
857 1056
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
858
-				if ($globalDebug) echo $result."\n";
859
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1057
+				if ($globalDebug) {
1058
+					echo $result."\n";
1059
+				}
1060
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1061
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1062
+			}
860 1063
 			//$this->del();
861 1064
 			
862 1065
 			
863 1066
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
864
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1067
+			    if ($globalDebug) {
1068
+			    	echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1069
+			    }
865 1070
 			    $SpotterLive = new SpotterLive($this->db);
866 1071
 			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
867 1072
 			    $SpotterLive->db = null;
868 1073
 			    //SpotterLive->deleteLiveSpotterData();
869
-			    if ($globalDebug) echo " Done\n";
1074
+			    if ($globalDebug) {
1075
+			    	echo " Done\n";
1076
+			    }
870 1077
 			    $this->last_delete_hourly = time();
871 1078
 			}
872 1079
 			
@@ -874,7 +1081,9 @@  discard block
 block discarded – undo
874 1081
 		    //$ignoreImport = false;
875 1082
 		}
876 1083
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
877
-		if ($send) return $this->all_flights[$id];
1084
+		if ($send) {
1085
+			return $this->all_flights[$id];
1086
+		}
878 1087
 	    }
879 1088
 	}
880 1089
     }
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +277 added lines, -104 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
 
@@ -1543,8 +1609,11 @@  discard block
 block discarded – undo
1543 1609
     	    if ($Connection->tableExists('aircraft')) {
1544 1610
     		if (!$Connection->tableExists('config')) {
1545 1611
     		    $version = '1';
1546
-    		    if ($update) return self::update_from_1();
1547
-    		    else return $version;
1612
+    		    if ($update) {
1613
+    		    	return self::update_from_1();
1614
+    		    } else {
1615
+    		    	return $version;
1616
+    		    }
1548 1617
 		} else {
1549 1618
     		    $Connection = new Connection();
1550 1619
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1558,142 +1627,246 @@  discard block
 block discarded – undo
1558 1627
     		    if ($update) {
1559 1628
     			if ($result['value'] == '2') {
1560 1629
     			    $error = self::update_from_2();
1561
-    			    if ($error != '') return $error;
1562
-    			    else return self::check_version(true);
1630
+    			    if ($error != '') {
1631
+    			    	return $error;
1632
+    			    } else {
1633
+    			    	return self::check_version(true);
1634
+    			    }
1563 1635
     			} elseif ($result['value'] == '3') {
1564 1636
     			    $error = self::update_from_3();
1565
-    			    if ($error != '') return $error;
1566
-    			    else return self::check_version(true);
1637
+    			    if ($error != '') {
1638
+    			    	return $error;
1639
+    			    } else {
1640
+    			    	return self::check_version(true);
1641
+    			    }
1567 1642
     			} elseif ($result['value'] == '4') {
1568 1643
     			    $error = self::update_from_4();
1569
-    			    if ($error != '') return $error;
1570
-    			    else return self::check_version(true);
1644
+    			    if ($error != '') {
1645
+    			    	return $error;
1646
+    			    } else {
1647
+    			    	return self::check_version(true);
1648
+    			    }
1571 1649
     			} elseif ($result['value'] == '5') {
1572 1650
     			    $error = self::update_from_5();
1573
-    			    if ($error != '') return $error;
1574
-    			    else return self::check_version(true);
1651
+    			    if ($error != '') {
1652
+    			    	return $error;
1653
+    			    } else {
1654
+    			    	return self::check_version(true);
1655
+    			    }
1575 1656
     			} elseif ($result['value'] == '6') {
1576 1657
     			    $error = self::update_from_6();
1577
-    			    if ($error != '') return $error;
1578
-    			    else return self::check_version(true);
1658
+    			    if ($error != '') {
1659
+    			    	return $error;
1660
+    			    } else {
1661
+    			    	return self::check_version(true);
1662
+    			    }
1579 1663
     			} elseif ($result['value'] == '7') {
1580 1664
     			    $error = self::update_from_7();
1581
-    			    if ($error != '') return $error;
1582
-    			    else return self::check_version(true);
1665
+    			    if ($error != '') {
1666
+    			    	return $error;
1667
+    			    } else {
1668
+    			    	return self::check_version(true);
1669
+    			    }
1583 1670
     			} elseif ($result['value'] == '8') {
1584 1671
     			    $error = self::update_from_8();
1585
-    			    if ($error != '') return $error;
1586
-    			    else return self::check_version(true);
1672
+    			    if ($error != '') {
1673
+    			    	return $error;
1674
+    			    } else {
1675
+    			    	return self::check_version(true);
1676
+    			    }
1587 1677
     			} elseif ($result['value'] == '9') {
1588 1678
     			    $error = self::update_from_9();
1589
-    			    if ($error != '') return $error;
1590
-    			    else return self::check_version(true);
1679
+    			    if ($error != '') {
1680
+    			    	return $error;
1681
+    			    } else {
1682
+    			    	return self::check_version(true);
1683
+    			    }
1591 1684
     			} elseif ($result['value'] == '10') {
1592 1685
     			    $error = self::update_from_10();
1593
-    			    if ($error != '') return $error;
1594
-    			    else return self::check_version(true);
1686
+    			    if ($error != '') {
1687
+    			    	return $error;
1688
+    			    } else {
1689
+    			    	return self::check_version(true);
1690
+    			    }
1595 1691
     			} elseif ($result['value'] == '11') {
1596 1692
     			    $error = self::update_from_11();
1597
-    			    if ($error != '') return $error;
1598
-    			    else return self::check_version(true);
1693
+    			    if ($error != '') {
1694
+    			    	return $error;
1695
+    			    } else {
1696
+    			    	return self::check_version(true);
1697
+    			    }
1599 1698
     			} elseif ($result['value'] == '12') {
1600 1699
     			    $error = self::update_from_12();
1601
-    			    if ($error != '') return $error;
1602
-    			    else return self::check_version(true);
1700
+    			    if ($error != '') {
1701
+    			    	return $error;
1702
+    			    } else {
1703
+    			    	return self::check_version(true);
1704
+    			    }
1603 1705
     			} elseif ($result['value'] == '13') {
1604 1706
     			    $error = self::update_from_13();
1605
-    			    if ($error != '') return $error;
1606
-    			    else return self::check_version(true);
1707
+    			    if ($error != '') {
1708
+    			    	return $error;
1709
+    			    } else {
1710
+    			    	return self::check_version(true);
1711
+    			    }
1607 1712
     			} elseif ($result['value'] == '14') {
1608 1713
     			    $error = self::update_from_14();
1609
-    			    if ($error != '') return $error;
1610
-    			    else return self::check_version(true);
1714
+    			    if ($error != '') {
1715
+    			    	return $error;
1716
+    			    } else {
1717
+    			    	return self::check_version(true);
1718
+    			    }
1611 1719
     			} elseif ($result['value'] == '15') {
1612 1720
     			    $error = self::update_from_15();
1613
-    			    if ($error != '') return $error;
1614
-    			    else return self::check_version(true);
1721
+    			    if ($error != '') {
1722
+    			    	return $error;
1723
+    			    } else {
1724
+    			    	return self::check_version(true);
1725
+    			    }
1615 1726
     			} elseif ($result['value'] == '16') {
1616 1727
     			    $error = self::update_from_16();
1617
-    			    if ($error != '') return $error;
1618
-    			    else return self::check_version(true);
1728
+    			    if ($error != '') {
1729
+    			    	return $error;
1730
+    			    } else {
1731
+    			    	return self::check_version(true);
1732
+    			    }
1619 1733
     			} elseif ($result['value'] == '17') {
1620 1734
     			    $error = self::update_from_17();
1621
-    			    if ($error != '') return $error;
1622
-    			    else return self::check_version(true);
1735
+    			    if ($error != '') {
1736
+    			    	return $error;
1737
+    			    } else {
1738
+    			    	return self::check_version(true);
1739
+    			    }
1623 1740
     			} elseif ($result['value'] == '18') {
1624 1741
     			    $error = self::update_from_18();
1625
-    			    if ($error != '') return $error;
1626
-    			    else return self::check_version(true);
1742
+    			    if ($error != '') {
1743
+    			    	return $error;
1744
+    			    } else {
1745
+    			    	return self::check_version(true);
1746
+    			    }
1627 1747
     			} elseif ($result['value'] == '19') {
1628 1748
     			    $error = self::update_from_19();
1629
-    			    if ($error != '') return $error;
1630
-    			    else return self::check_version(true);
1749
+    			    if ($error != '') {
1750
+    			    	return $error;
1751
+    			    } else {
1752
+    			    	return self::check_version(true);
1753
+    			    }
1631 1754
     			} elseif ($result['value'] == '20') {
1632 1755
     			    $error = self::update_from_20();
1633
-    			    if ($error != '') return $error;
1634
-    			    else return self::check_version(true);
1756
+    			    if ($error != '') {
1757
+    			    	return $error;
1758
+    			    } else {
1759
+    			    	return self::check_version(true);
1760
+    			    }
1635 1761
     			} elseif ($result['value'] == '21') {
1636 1762
     			    $error = self::update_from_21();
1637
-    			    if ($error != '') return $error;
1638
-    			    else return self::check_version(true);
1763
+    			    if ($error != '') {
1764
+    			    	return $error;
1765
+    			    } else {
1766
+    			    	return self::check_version(true);
1767
+    			    }
1639 1768
     			} elseif ($result['value'] == '22') {
1640 1769
     			    $error = self::update_from_22();
1641
-    			    if ($error != '') return $error;
1642
-    			    else return self::check_version(true);
1770
+    			    if ($error != '') {
1771
+    			    	return $error;
1772
+    			    } else {
1773
+    			    	return self::check_version(true);
1774
+    			    }
1643 1775
     			} elseif ($result['value'] == '23') {
1644 1776
     			    $error = self::update_from_23();
1645
-    			    if ($error != '') return $error;
1646
-    			    else return self::check_version(true);
1777
+    			    if ($error != '') {
1778
+    			    	return $error;
1779
+    			    } else {
1780
+    			    	return self::check_version(true);
1781
+    			    }
1647 1782
     			} elseif ($result['value'] == '24') {
1648 1783
     			    $error = self::update_from_24();
1649
-    			    if ($error != '') return $error;
1650
-    			    else return self::check_version(true);
1784
+    			    if ($error != '') {
1785
+    			    	return $error;
1786
+    			    } else {
1787
+    			    	return self::check_version(true);
1788
+    			    }
1651 1789
     			} elseif ($result['value'] == '25') {
1652 1790
     			    $error = self::update_from_25();
1653
-    			    if ($error != '') return $error;
1654
-    			    else return self::check_version(true);
1791
+    			    if ($error != '') {
1792
+    			    	return $error;
1793
+    			    } else {
1794
+    			    	return self::check_version(true);
1795
+    			    }
1655 1796
     			} elseif ($result['value'] == '26') {
1656 1797
     			    $error = self::update_from_26();
1657
-    			    if ($error != '') return $error;
1658
-    			    else return self::check_version(true);
1798
+    			    if ($error != '') {
1799
+    			    	return $error;
1800
+    			    } else {
1801
+    			    	return self::check_version(true);
1802
+    			    }
1659 1803
     			} elseif ($result['value'] == '27') {
1660 1804
     			    $error = self::update_from_27();
1661
-    			    if ($error != '') return $error;
1662
-    			    else return self::check_version(true);
1805
+    			    if ($error != '') {
1806
+    			    	return $error;
1807
+    			    } else {
1808
+    			    	return self::check_version(true);
1809
+    			    }
1663 1810
     			} elseif ($result['value'] == '28') {
1664 1811
     			    $error = self::update_from_28();
1665
-    			    if ($error != '') return $error;
1666
-    			    else return self::check_version(true);
1812
+    			    if ($error != '') {
1813
+    			    	return $error;
1814
+    			    } else {
1815
+    			    	return self::check_version(true);
1816
+    			    }
1667 1817
     			} elseif ($result['value'] == '29') {
1668 1818
     			    $error = self::update_from_29();
1669
-    			    if ($error != '') return $error;
1670
-    			    else return self::check_version(true);
1819
+    			    if ($error != '') {
1820
+    			    	return $error;
1821
+    			    } else {
1822
+    			    	return self::check_version(true);
1823
+    			    }
1671 1824
     			} elseif ($result['value'] == '30') {
1672 1825
     			    $error = self::update_from_30();
1673
-    			    if ($error != '') return $error;
1674
-    			    else return self::check_version(true);
1826
+    			    if ($error != '') {
1827
+    			    	return $error;
1828
+    			    } else {
1829
+    			    	return self::check_version(true);
1830
+    			    }
1675 1831
     			} elseif ($result['value'] == '31') {
1676 1832
     			    $error = self::update_from_31();
1677
-    			    if ($error != '') return $error;
1678
-    			    else return self::check_version(true);
1833
+    			    if ($error != '') {
1834
+    			    	return $error;
1835
+    			    } else {
1836
+    			    	return self::check_version(true);
1837
+    			    }
1679 1838
     			} elseif ($result['value'] == '32') {
1680 1839
     			    $error = self::update_from_32();
1681
-    			    if ($error != '') return $error;
1682
-    			    else return self::check_version(true);
1840
+    			    if ($error != '') {
1841
+    			    	return $error;
1842
+    			    } else {
1843
+    			    	return self::check_version(true);
1844
+    			    }
1683 1845
     			} elseif ($result['value'] == '33') {
1684 1846
     			    $error = self::update_from_33();
1685
-    			    if ($error != '') return $error;
1686
-    			    else return self::check_version(true);
1847
+    			    if ($error != '') {
1848
+    			    	return $error;
1849
+    			    } else {
1850
+    			    	return self::check_version(true);
1851
+    			    }
1687 1852
     			} elseif ($result['value'] == '34') {
1688 1853
     			    $error = self::update_from_34();
1689
-    			    if ($error != '') return $error;
1690
-    			    else return self::check_version(true);
1691
-    			} else return '';
1854
+    			    if ($error != '') {
1855
+    			    	return $error;
1856
+    			    } else {
1857
+    			    	return self::check_version(true);
1858
+    			    }
1859
+    			} else {
1860
+    				return '';
1861
+    			}
1862
+    		    } else {
1863
+    		    	return $result['value'];
1692 1864
     		    }
1693
-    		    else return $result['value'];
1694 1865
 		}
1695 1866
 		
1696
-	    } else return $version;
1867
+	    } else {
1868
+	    	return $version;
1869
+	    }
1697 1870
     	}
1698 1871
     	
1699 1872
 }
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Braces   +476 added lines, -165 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -77,7 +79,9 @@  discard block
 block discarded – undo
77 79
                 }
78 80
         }
79 81
 	public function getAllAirlineNames($filter_name = '') {
80
-		if ($filter_name == '') $filter_name = $this->filter_name;
82
+		if ($filter_name == '') {
83
+			$filter_name = $this->filter_name;
84
+		}
81 85
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82 86
                  try {
83 87
                         $sth = $this->db->prepare($query);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
                 return $all;
90 94
         }
91 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92
-		if ($filter_name == '') $filter_name = $this->filter_name;
96
+		if ($filter_name == '') {
97
+			$filter_name = $this->filter_name;
98
+		}
93 99
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 100
                  try {
95 101
                         $sth = $this->db->prepare($query);
@@ -101,7 +107,9 @@  discard block
 block discarded – undo
101 107
                 return $all;
102 108
         }
103 109
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104
-		if ($filter_name == '') $filter_name = $this->filter_name;
110
+		if ($filter_name == '') {
111
+			$filter_name = $this->filter_name;
112
+		}
105 113
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 114
                  try {
107 115
                         $sth = $this->db->prepare($query);
@@ -113,7 +121,9 @@  discard block
 block discarded – undo
113 121
                 return $all;
114 122
         }
115 123
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
124
+		if ($filter_name == '') {
125
+			$filter_name = $this->filter_name;
126
+		}
117 127
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 128
                  try {
119 129
                         $sth = $this->db->prepare($query);
@@ -126,7 +136,9 @@  discard block
 block discarded – undo
126 136
         }
127 137
 
128 138
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129
-		if ($filter_name == '') $filter_name = $this->filter_name;
139
+		if ($filter_name == '') {
140
+			$filter_name = $this->filter_name;
141
+		}
130 142
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 143
                  try {
132 144
                         $sth = $this->db->prepare($query);
@@ -139,7 +151,9 @@  discard block
 block discarded – undo
139 151
         }
140 152
 
141 153
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142
-		if ($filter_name == '') $filter_name = $this->filter_name;
154
+		if ($filter_name == '') {
155
+			$filter_name = $this->filter_name;
156
+		}
143 157
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144 158
                  try {
145 159
                         $sth = $this->db->prepare($query);
@@ -154,10 +168,15 @@  discard block
 block discarded – undo
154 168
 
155 169
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
156 170
 		global $globalStatsFilters;
157
-		if ($filter_name == '') $filter_name = $this->filter_name;
171
+		if ($filter_name == '') {
172
+			$filter_name = $this->filter_name;
173
+		}
158 174
 		if ($year == '' && $month == '') {
159
-			if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
160
-			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
175
+			if ($limit) {
176
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
177
+			} else {
178
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
179
+			}
161 180
 			try {
162 181
 				$sth = $this->db->prepare($query);
163 182
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -165,7 +184,9 @@  discard block
 block discarded – undo
165 184
 				echo "error : ".$e->getMessage();
166 185
 			}
167 186
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168
-		} else $all = array();
187
+		} else {
188
+			$all = array();
189
+		}
169 190
                 if (empty($all)) {
170 191
             	    $filters = array('airlines' => array($stats_airline));
171 192
             	    if ($filter_name != '') {
@@ -178,10 +199,15 @@  discard block
 block discarded – undo
178 199
 	}
179 200
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 201
 		global $globalStatsFilters;
181
-		if ($filter_name == '') $filter_name = $this->filter_name;
202
+		if ($filter_name == '') {
203
+			$filter_name = $this->filter_name;
204
+		}
182 205
 		if ($year == '' && $month == '') {
183
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
184
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
206
+			if ($limit) {
207
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
208
+			} else {
209
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
210
+			}
185 211
 			try {
186 212
 				$sth = $this->db->prepare($query);
187 213
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -189,7 +215,9 @@  discard block
 block discarded – undo
189 215
 				echo "error : ".$e->getMessage();
190 216
 			}
191 217
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-		} else $all = array();
218
+		} else {
219
+			$all = array();
220
+		}
193 221
                 if (empty($all)) {
194 222
             		$Spotter = new Spotter($this->db);
195 223
             		$filters = array();
@@ -202,10 +230,15 @@  discard block
 block discarded – undo
202 230
 	}
203 231
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 232
 		global $globalStatsFilters;
205
-		if ($filter_name == '') $filter_name = $this->filter_name;
233
+		if ($filter_name == '') {
234
+			$filter_name = $this->filter_name;
235
+		}
206 236
 		if ($year == '' && $month == '') {
207
-			if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
208
-			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
237
+			if ($limit) {
238
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
239
+			} else {
240
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
241
+			}
209 242
 			try {
210 243
 				$sth = $this->db->prepare($query);
211 244
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -213,7 +246,9 @@  discard block
 block discarded – undo
213 246
 				echo "error : ".$e->getMessage();
214 247
 			}
215 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
216
-		} else $all = array();
249
+		} else {
250
+			$all = array();
251
+		}
217 252
 		if (empty($all)) {
218 253
 			$filters = array('airlines' => array($stats_airline));
219 254
 			if ($filter_name != '') {
@@ -227,10 +262,15 @@  discard block
 block discarded – undo
227 262
 
228 263
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
229 264
 		global $globalStatsFilters;
230
-		if ($filter_name == '') $filter_name = $this->filter_name;
265
+		if ($filter_name == '') {
266
+			$filter_name = $this->filter_name;
267
+		}
231 268
 		if ($year == '' && $month == '') {
232
-			if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
233
-			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
269
+			if ($limit) {
270
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
271
+			} else {
272
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
273
+			}
234 274
 			try {
235 275
 				$sth = $this->db->prepare($query);
236 276
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -238,7 +278,9 @@  discard block
 block discarded – undo
238 278
 				echo "error : ".$e->getMessage();
239 279
 			}
240 280
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241
-		} else $all = array();
281
+		} else {
282
+			$all = array();
283
+		}
242 284
                 if (empty($all)) {
243 285
 			$filters = array('airlines' => array($stats_airline));
244 286
 			if ($filter_name != '') {
@@ -251,9 +293,14 @@  discard block
 block discarded – undo
251 293
 	}
252 294
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 295
 		global $globalStatsFilters;
254
-		if ($filter_name == '') $filter_name = $this->filter_name;
255
-		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
256
-		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
296
+		if ($filter_name == '') {
297
+			$filter_name = $this->filter_name;
298
+		}
299
+		if ($limit) {
300
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
301
+		} else {
302
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
303
+		}
257 304
                  try {
258 305
                         $sth = $this->db->prepare($query);
259 306
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -274,17 +321,29 @@  discard block
 block discarded – undo
274 321
 
275 322
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
276 323
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
277
-		if ($filter_name == '') $filter_name = $this->filter_name;
324
+		if ($filter_name == '') {
325
+			$filter_name = $this->filter_name;
326
+		}
278 327
 		if ($year == '' && $month == '') {
279
-			if ($globalVATSIM) $forsource = 'vatsim';
280
-			if ($globalIVAO) $forsource = 'ivao';
328
+			if ($globalVATSIM) {
329
+				$forsource = 'vatsim';
330
+			}
331
+			if ($globalIVAO) {
332
+				$forsource = 'ivao';
333
+			}
281 334
 			if (isset($forsource)) {
282
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
283
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
335
+				if ($limit) {
336
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
337
+				} else {
338
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
339
+				}
284 340
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
285 341
 			} else {
286
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
287
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
342
+				if ($limit) {
343
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
344
+				} else {
345
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
346
+				}
288 347
 				$query_values = array(':filter_name' => $filter_name);
289 348
 			}
290 349
 			try {
@@ -294,7 +353,9 @@  discard block
 block discarded – undo
294 353
 				echo "error : ".$e->getMessage();
295 354
 			}
296 355
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
297
-		} else $all = array();
356
+		} else {
357
+			$all = array();
358
+		}
298 359
                 if (empty($all)) {
299 360
 	                $Spotter = new Spotter($this->db);
300 361
             		$filters = array();
@@ -307,10 +368,15 @@  discard block
 block discarded – undo
307 368
 	}
308 369
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
309 370
 		global $globalStatsFilters;
310
-		if ($filter_name == '') $filter_name = $this->filter_name;
371
+		if ($filter_name == '') {
372
+			$filter_name = $this->filter_name;
373
+		}
311 374
 		if ($year == '' && $month == '') {
312
-			if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
313
-			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
375
+			if ($limit) {
376
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
377
+			} else {
378
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
379
+			}
314 380
 			try {
315 381
 				$sth = $this->db->prepare($query);
316 382
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -318,7 +384,9 @@  discard block
 block discarded – undo
318 384
 				echo "error : ".$e->getMessage();
319 385
 			}
320 386
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
321
-		} else $all = array();
387
+		} else {
388
+			$all = array();
389
+		}
322 390
                 if (empty($all)) {
323 391
 			$filters = array('airlines' => array($stats_airline));
324 392
 			if ($filter_name != '') {
@@ -331,10 +399,15 @@  discard block
 block discarded – undo
331 399
 	}
332 400
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
333 401
 		global $globalStatsFilters;
334
-		if ($filter_name == '') $filter_name = $this->filter_name;
402
+		if ($filter_name == '') {
403
+			$filter_name = $this->filter_name;
404
+		}
335 405
 		if ($year == '' && $month == '') {
336
-			if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
337
-			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
406
+			if ($limit) {
407
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
408
+			} else {
409
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
410
+			}
338 411
 			 try {
339 412
 				$sth = $this->db->prepare($query);
340 413
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -342,7 +415,9 @@  discard block
 block discarded – undo
342 415
 				echo "error : ".$e->getMessage();
343 416
 			}
344 417
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
345
-		} else $all = array();
418
+		} else {
419
+			$all = array();
420
+		}
346 421
 		if (empty($all)) {
347 422
 			$filters = array('airlines' => array($stats_airline));
348 423
 			if ($filter_name != '') {
@@ -355,11 +430,16 @@  discard block
 block discarded – undo
355 430
 	}
356 431
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
357 432
 		$Connection = new Connection();
358
-		if ($filter_name == '') $filter_name = $this->filter_name;
433
+		if ($filter_name == '') {
434
+			$filter_name = $this->filter_name;
435
+		}
359 436
 		if ($Connection->tableExists('countries')) {
360 437
 			if ($year == '' && $month == '') {
361
-				if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
362
-				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
438
+				if ($limit) {
439
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
440
+				} else {
441
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
442
+				}
363 443
 				 try {
364 444
 					$sth = $this->db->prepare($query);
365 445
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -374,17 +454,24 @@  discard block
 block discarded – undo
374 454
                 }
375 455
                 */
376 456
 				return $all;
377
-			} else return array();
457
+			} else {
458
+				return array();
459
+			}
378 460
 		} else {
379 461
 			return array();
380 462
 		}
381 463
 	}
382 464
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
383 465
 		global $globalStatsFilters;
384
-		if ($filter_name == '') $filter_name = $this->filter_name;
466
+		if ($filter_name == '') {
467
+			$filter_name = $this->filter_name;
468
+		}
385 469
 		if ($year == '' && $month == '') {
386
-			if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
387
-			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
470
+			if ($limit) {
471
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
472
+			} else {
473
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
474
+			}
388 475
 			try {
389 476
 				$sth = $this->db->prepare($query);
390 477
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -392,7 +479,9 @@  discard block
 block discarded – undo
392 479
 				echo "error : ".$e->getMessage();
393 480
 			}
394 481
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
395
-		} else $all = array();
482
+		} else {
483
+			$all = array();
484
+		}
396 485
 		if (empty($all)) {
397 486
 			$filters = array('airlines' => array($stats_airline));
398 487
 			if ($filter_name != '') {
@@ -406,10 +495,15 @@  discard block
 block discarded – undo
406 495
 
407 496
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
408 497
 		global $globalStatsFilters;
409
-		if ($filter_name == '') $filter_name = $this->filter_name;
498
+		if ($filter_name == '') {
499
+			$filter_name = $this->filter_name;
500
+		}
410 501
 		if ($year == '' && $month == '') {
411
-			if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
412
-			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
502
+			if ($limit) {
503
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
504
+			} else {
505
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
506
+			}
413 507
 			try {
414 508
 				$sth = $this->db->prepare($query);
415 509
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -417,7 +511,9 @@  discard block
 block discarded – undo
417 511
 				echo "error : ".$e->getMessage();
418 512
 			}
419 513
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
420
-		} else $all = array();
514
+		} else {
515
+			$all = array();
516
+		}
421 517
                 if (empty($all)) {
422 518
 			$filters = array('airlines' => array($stats_airline));
423 519
 			if ($filter_name != '') {
@@ -430,10 +526,15 @@  discard block
 block discarded – undo
430 526
 	}
431 527
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
432 528
 		global $globalStatsFilters;
433
-		if ($filter_name == '') $filter_name = $this->filter_name;
529
+		if ($filter_name == '') {
530
+			$filter_name = $this->filter_name;
531
+		}
434 532
 		if ($year == '' && $month == '') {
435
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
436
-			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
533
+			if ($limit) {
534
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
535
+			} else {
536
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
537
+			}
437 538
 			try {
438 539
 				$sth = $this->db->prepare($query);
439 540
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -441,7 +542,9 @@  discard block
 block discarded – undo
441 542
 				echo "error : ".$e->getMessage();
442 543
 			}
443 544
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
444
-		} else $all = array();
545
+		} else {
546
+			$all = array();
547
+		}
445 548
                 if (empty($all)) {
446 549
 			$filters = array('airlines' => array($stats_airline));
447 550
             		if ($filter_name != '') {
@@ -460,7 +563,9 @@  discard block
 block discarded – undo
460 563
         			$icao = $value['airport_departure_icao'];
461 564
         			if (isset($all[$icao])) {
462 565
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
463
-        			} else $all[$icao] = $value;
566
+        			} else {
567
+        				$all[$icao] = $value;
568
+        			}
464 569
         		}
465 570
         		$count = array();
466 571
         		foreach ($all as $key => $row) {
@@ -472,10 +577,15 @@  discard block
 block discarded – undo
472 577
 	}
473 578
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
474 579
 		global $globalStatsFilters;
475
-		if ($filter_name == '') $filter_name = $this->filter_name;
580
+		if ($filter_name == '') {
581
+			$filter_name = $this->filter_name;
582
+		}
476 583
 		if ($year == '' && $month == '') {
477
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
478
-			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
584
+			if ($limit) {
585
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
586
+			} else {
587
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
588
+			}
479 589
 			try {
480 590
 				$sth = $this->db->prepare($query);
481 591
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -483,7 +593,9 @@  discard block
 block discarded – undo
483 593
 				echo "error : ".$e->getMessage();
484 594
 			}
485 595
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
486
-		} else $all = array();
596
+		} else {
597
+			$all = array();
598
+		}
487 599
 		if (empty($all)) {
488 600
 			$filters = array('airlines' => array($stats_airline));
489 601
 			if ($filter_name != '') {
@@ -502,7 +614,9 @@  discard block
 block discarded – undo
502 614
         			$icao = $value['airport_arrival_icao'];
503 615
         			if (isset($all[$icao])) {
504 616
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
505
-        			} else $all[$icao] = $value;
617
+        			} else {
618
+        				$all[$icao] = $value;
619
+        			}
506 620
         		}
507 621
         		$count = array();
508 622
         		foreach ($all as $key => $row) {
@@ -515,13 +629,21 @@  discard block
 block discarded – undo
515 629
 	}
516 630
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
517 631
 		global $globalDBdriver, $globalStatsFilters;
518
-		if ($filter_name == '') $filter_name = $this->filter_name;
632
+		if ($filter_name == '') {
633
+			$filter_name = $this->filter_name;
634
+		}
519 635
 		if ($globalDBdriver == 'mysql') {
520
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
521
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
636
+			if ($limit) {
637
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
638
+			} else {
639
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
640
+			}
522 641
 		} else {
523
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
524
-			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
642
+			if ($limit) {
643
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
644
+			} else {
645
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
646
+			}
525 647
 		}
526 648
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
527 649
                  try {
@@ -545,7 +667,9 @@  discard block
 block discarded – undo
545 667
 	
546 668
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
547 669
 		global $globalStatsFilters;
548
-		if ($filter_name == '') $filter_name = $this->filter_name;
670
+		if ($filter_name == '') {
671
+			$filter_name = $this->filter_name;
672
+		}
549 673
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
550 674
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
551 675
                  try {
@@ -567,7 +691,9 @@  discard block
 block discarded – undo
567 691
 	}
568 692
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
569 693
 		global $globalDBdriver, $globalStatsFilters;
570
-		if ($filter_name == '') $filter_name = $this->filter_name;
694
+		if ($filter_name == '') {
695
+			$filter_name = $this->filter_name;
696
+		}
571 697
 		if ($globalDBdriver == 'mysql') {
572 698
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
573 699
 		} else {
@@ -593,7 +719,9 @@  discard block
 block discarded – undo
593 719
 	}
594 720
 	public function countAllDates($stats_airline = '',$filter_name = '') {
595 721
 		global $globalStatsFilters;
596
-		if ($filter_name == '') $filter_name = $this->filter_name;
722
+		if ($filter_name == '') {
723
+			$filter_name = $this->filter_name;
724
+		}
597 725
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
598 726
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
599 727
                  try {
@@ -615,7 +743,9 @@  discard block
 block discarded – undo
615 743
 	}
616 744
 	public function countAllDatesByAirlines($filter_name = '') {
617 745
 		global $globalStatsFilters;
618
-		if ($filter_name == '') $filter_name = $this->filter_name;
746
+		if ($filter_name == '') {
747
+			$filter_name = $this->filter_name;
748
+		}
619 749
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
620 750
 		$query_data = array('filter_name' => $filter_name);
621 751
                  try {
@@ -637,7 +767,9 @@  discard block
 block discarded – undo
637 767
 	}
638 768
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
639 769
 		global $globalStatsFilters;
640
-		if ($filter_name == '') $filter_name = $this->filter_name;
770
+		if ($filter_name == '') {
771
+			$filter_name = $this->filter_name;
772
+		}
641 773
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
642 774
                  try {
643 775
                         $sth = $this->db->prepare($query);
@@ -660,7 +792,9 @@  discard block
 block discarded – undo
660 792
 	}
661 793
 	public function countAllMilitaryMonths($filter_name = '') {
662 794
 		global $globalStatsFilters;
663
-		if ($filter_name == '') $filter_name = $this->filter_name;
795
+		if ($filter_name == '') {
796
+			$filter_name = $this->filter_name;
797
+		}
664 798
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
665 799
                  try {
666 800
                         $sth = $this->db->prepare($query);
@@ -681,9 +815,14 @@  discard block
 block discarded – undo
681 815
 	}
682 816
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
683 817
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
684
-		if ($filter_name == '') $filter_name = $this->filter_name;
685
-		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
686
-		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
818
+		if ($filter_name == '') {
819
+			$filter_name = $this->filter_name;
820
+		}
821
+		if ($limit) {
822
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
823
+		} else {
824
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
825
+		}
687 826
 		if ($orderby == 'hour') {
688 827
 			/*
689 828
 			if ($globalDBdriver == 'mysql') {
@@ -692,7 +831,9 @@  discard block
 block discarded – undo
692 831
 			*/
693 832
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
694 833
 		}
695
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
834
+		if ($orderby == 'count') {
835
+			$query .= " ORDER BY hour_count DESC";
836
+		}
696 837
                  try {
697 838
                         $sth = $this->db->prepare($query);
698 839
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -713,8 +854,12 @@  discard block
 block discarded – undo
713 854
 	
714 855
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
715 856
 		global $globalStatsFilters;
716
-		if ($filter_name == '') $filter_name = $this->filter_name;
717
-		if ($year == '') $year = date('Y');
857
+		if ($filter_name == '') {
858
+			$filter_name = $this->filter_name;
859
+		}
860
+		if ($year == '') {
861
+			$year = date('Y');
862
+		}
718 863
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
719 864
 		if (empty($all)) {
720 865
 			$filters = array('airlines' => array($stats_airline));
@@ -728,8 +873,12 @@  discard block
 block discarded – undo
728 873
 	}
729 874
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
730 875
 		global $globalStatsFilters;
731
-		if ($filter_name == '') $filter_name = $this->filter_name;
732
-		if ($year == '') $year = date('Y');
876
+		if ($filter_name == '') {
877
+			$filter_name = $this->filter_name;
878
+		}
879
+		if ($year == '') {
880
+			$year = date('Y');
881
+		}
733 882
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
734 883
 		if (empty($all)) {
735 884
 		        $filters = array();
@@ -743,8 +892,12 @@  discard block
 block discarded – undo
743 892
 	}
744 893
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
745 894
 		global $globalStatsFilters;
746
-		if ($filter_name == '') $filter_name = $this->filter_name;
747
-		if ($year == '') $year = date('Y');
895
+		if ($filter_name == '') {
896
+			$filter_name = $this->filter_name;
897
+		}
898
+		if ($year == '') {
899
+			$year = date('Y');
900
+		}
748 901
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
749 902
 		if (empty($all)) {
750 903
 			$filters = array('airlines' => array($stats_airline));
@@ -758,7 +911,9 @@  discard block
 block discarded – undo
758 911
 	}
759 912
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
760 913
 		global $globalStatsFilters;
761
-		if ($filter_name == '') $filter_name = $this->filter_name;
914
+		if ($filter_name == '') {
915
+			$filter_name = $this->filter_name;
916
+		}
762 917
 		if ($year == '' && $month == '') {
763 918
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
764 919
 			try {
@@ -769,7 +924,9 @@  discard block
 block discarded – undo
769 924
 			}
770 925
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
771 926
 			$all = $result[0]['nb'];
772
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
927
+		} else {
928
+			$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
929
+		}
773 930
 		if (empty($all)) {
774 931
 			$filters = array('airlines' => array($stats_airline));
775 932
 			if ($filter_name != '') {
@@ -782,7 +939,9 @@  discard block
 block discarded – undo
782 939
 	}
783 940
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
784 941
 		global $globalStatsFilters;
785
-		if ($filter_name == '') $filter_name = $this->filter_name;
942
+		if ($filter_name == '') {
943
+			$filter_name = $this->filter_name;
944
+		}
786 945
 		if ($year == '' && $month == '') {
787 946
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
788 947
 			try {
@@ -793,7 +952,9 @@  discard block
 block discarded – undo
793 952
 			}
794 953
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
795 954
 			$all = $result[0]['nb_airline'];
796
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
955
+		} else {
956
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
957
+		}
797 958
 		if (empty($all)) {
798 959
             		$filters = array();
799 960
             		if ($filter_name != '') {
@@ -806,7 +967,9 @@  discard block
 block discarded – undo
806 967
 	}
807 968
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
808 969
 		global $globalStatsFilters;
809
-		if ($filter_name == '') $filter_name = $this->filter_name;
970
+		if ($filter_name == '') {
971
+			$filter_name = $this->filter_name;
972
+		}
810 973
 		if ($year == '' && $month == '') {
811 974
 			$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
812 975
 			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
@@ -833,7 +996,9 @@  discard block
 block discarded – undo
833 996
 	}
834 997
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
835 998
 		global $globalStatsFilters;
836
-		if ($filter_name == '') $filter_name = $this->filter_name;
999
+		if ($filter_name == '') {
1000
+			$filter_name = $this->filter_name;
1001
+		}
837 1002
 		//if ($year == '') $year = date('Y');
838 1003
 		if ($year == '' && $month == '') {
839 1004
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -861,7 +1026,9 @@  discard block
 block discarded – undo
861 1026
 	}
862 1027
 
863 1028
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
864
-		if ($filter_name == '') $filter_name = $this->filter_name;
1029
+		if ($filter_name == '') {
1030
+			$filter_name = $this->filter_name;
1031
+		}
865 1032
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
866 1033
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
867 1034
                  try {
@@ -874,7 +1041,9 @@  discard block
 block discarded – undo
874 1041
                 return $all;
875 1042
 	}
876 1043
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
877
-		if ($filter_name == '') $filter_name = $this->filter_name;
1044
+		if ($filter_name == '') {
1045
+			$filter_name = $this->filter_name;
1046
+		}
878 1047
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
879 1048
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
880 1049
                  try {
@@ -887,7 +1056,9 @@  discard block
 block discarded – undo
887 1056
                 return $all;
888 1057
         }
889 1058
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
890
-		if ($filter_name == '') $filter_name = $this->filter_name;
1059
+		if ($filter_name == '') {
1060
+			$filter_name = $this->filter_name;
1061
+		}
891 1062
     		global $globalArchiveMonths, $globalDBdriver;
892 1063
     		if ($globalDBdriver == 'mysql') {
893 1064
     			if ($month == '') {
@@ -917,7 +1088,9 @@  discard block
 block discarded – undo
917 1088
         }
918 1089
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
919 1090
     		global $globalArchiveMonths, $globalDBdriver;
920
-		if ($filter_name == '') $filter_name = $this->filter_name;
1091
+		if ($filter_name == '') {
1092
+			$filter_name = $this->filter_name;
1093
+		}
921 1094
     		if ($globalDBdriver == 'mysql') {
922 1095
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
923 1096
 		} else {
@@ -935,7 +1108,9 @@  discard block
 block discarded – undo
935 1108
         }
936 1109
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
937 1110
     		global $globalArchiveMonths, $globalDBdriver;
938
-		if ($filter_name == '') $filter_name = $this->filter_name;
1111
+		if ($filter_name == '') {
1112
+			$filter_name = $this->filter_name;
1113
+		}
939 1114
     		if ($globalDBdriver == 'mysql') {
940 1115
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
941 1116
                 } else {
@@ -952,7 +1127,9 @@  discard block
 block discarded – undo
952 1127
         }
953 1128
 	public function getStatsAirlineTotal($filter_name = '') {
954 1129
     		global $globalArchiveMonths, $globalDBdriver;
955
-		if ($filter_name == '') $filter_name = $this->filter_name;
1130
+		if ($filter_name == '') {
1131
+			$filter_name = $this->filter_name;
1132
+		}
956 1133
     		if ($globalDBdriver == 'mysql') {
957 1134
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
958 1135
                 } else {
@@ -969,7 +1146,9 @@  discard block
 block discarded – undo
969 1146
         }
970 1147
 	public function getStatsOwnerTotal($filter_name = '') {
971 1148
     		global $globalArchiveMonths, $globalDBdriver;
972
-		if ($filter_name == '') $filter_name = $this->filter_name;
1149
+		if ($filter_name == '') {
1150
+			$filter_name = $this->filter_name;
1151
+		}
973 1152
     		if ($globalDBdriver == 'mysql') {
974 1153
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
975 1154
 		} else {
@@ -986,7 +1165,9 @@  discard block
 block discarded – undo
986 1165
         }
987 1166
 	public function getStatsOwner($owner_name,$filter_name = '') {
988 1167
     		global $globalArchiveMonths, $globalDBdriver;
989
-		if ($filter_name == '') $filter_name = $this->filter_name;
1168
+		if ($filter_name == '') {
1169
+			$filter_name = $this->filter_name;
1170
+		}
990 1171
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
991 1172
                  try {
992 1173
                         $sth = $this->db->prepare($query);
@@ -995,12 +1176,17 @@  discard block
 block discarded – undo
995 1176
                         echo "error : ".$e->getMessage();
996 1177
                 }
997 1178
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
998
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
999
-                else return 0;
1179
+                if (isset($all[0]['cnt'])) {
1180
+                	return $all[0]['cnt'];
1181
+                } else {
1182
+                	return 0;
1183
+                }
1000 1184
         }
1001 1185
 	public function getStatsPilotTotal($filter_name = '') {
1002 1186
     		global $globalArchiveMonths, $globalDBdriver;
1003
-		if ($filter_name == '') $filter_name = $this->filter_name;
1187
+		if ($filter_name == '') {
1188
+			$filter_name = $this->filter_name;
1189
+		}
1004 1190
     		if ($globalDBdriver == 'mysql') {
1005 1191
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1006 1192
             	} else {
@@ -1017,7 +1203,9 @@  discard block
 block discarded – undo
1017 1203
         }
1018 1204
 	public function getStatsPilot($pilot,$filter_name = '') {
1019 1205
     		global $globalArchiveMonths, $globalDBdriver;
1020
-		if ($filter_name == '') $filter_name = $this->filter_name;
1206
+		if ($filter_name == '') {
1207
+			$filter_name = $this->filter_name;
1208
+		}
1021 1209
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1022 1210
                  try {
1023 1211
                         $sth = $this->db->prepare($query);
@@ -1026,13 +1214,18 @@  discard block
 block discarded – undo
1026 1214
                         echo "error : ".$e->getMessage();
1027 1215
                 }
1028 1216
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1029
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1030
-                else return 0;
1217
+                if (isset($all[0]['cnt'])) {
1218
+                	return $all[0]['cnt'];
1219
+                } else {
1220
+                	return 0;
1221
+                }
1031 1222
         }
1032 1223
 
1033 1224
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1034 1225
 		global $globalDBdriver;
1035
-		if ($filter_name == '') $filter_name = $this->filter_name;
1226
+		if ($filter_name == '') {
1227
+			$filter_name = $this->filter_name;
1228
+		}
1036 1229
 		if ($globalDBdriver == 'mysql') {
1037 1230
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
1038 1231
                 } else {
@@ -1048,7 +1241,9 @@  discard block
 block discarded – undo
1048 1241
         }
1049 1242
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1050 1243
 		global $globalDBdriver;
1051
-		if ($filter_name == '') $filter_name = $this->filter_name;
1244
+		if ($filter_name == '') {
1245
+			$filter_name = $this->filter_name;
1246
+		}
1052 1247
 		if ($globalDBdriver == 'mysql') {
1053 1248
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1054 1249
 		} else {
@@ -1434,10 +1629,14 @@  discard block
 block discarded – undo
1434 1629
     		$Connection = new Connection();
1435 1630
     		date_default_timezone_set('UTC');
1436 1631
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1437
-			if ($globalDebug) echo 'Update stats !'."\n";
1632
+			if ($globalDebug) {
1633
+				echo 'Update stats !'."\n";
1634
+			}
1438 1635
 			if (isset($last_update[0]['value'])) {
1439 1636
 				$last_update_day = $last_update[0]['value'];
1440
-			} else $last_update_day = '2012-12-12 12:12:12';
1637
+			} else {
1638
+				$last_update_day = '2012-12-12 12:12:12';
1639
+			}
1441 1640
 			$reset = false;
1442 1641
 			if ($globalStatsResetYear) {
1443 1642
 				$reset = true;
@@ -1445,42 +1644,60 @@  discard block
 block discarded – undo
1445 1644
 			}
1446 1645
 			$Spotter = new Spotter($this->db);
1447 1646
 
1448
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1647
+			if ($globalDebug) {
1648
+				echo 'Count all aircraft types...'."\n";
1649
+			}
1449 1650
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1450 1651
 			foreach ($alldata as $number) {
1451 1652
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1452 1653
 			}
1453
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1654
+			if ($globalDebug) {
1655
+				echo 'Count all airlines...'."\n";
1656
+			}
1454 1657
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1455 1658
 			foreach ($alldata as $number) {
1456 1659
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1457 1660
 			}
1458
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1661
+			if ($globalDebug) {
1662
+				echo 'Count all registrations...'."\n";
1663
+			}
1459 1664
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1460 1665
 			foreach ($alldata as $number) {
1461 1666
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1462 1667
 			}
1463
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1668
+			if ($globalDebug) {
1669
+				echo 'Count all callsigns...'."\n";
1670
+			}
1464 1671
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1465 1672
 			foreach ($alldata as $number) {
1466 1673
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1467 1674
 			}
1468
-			if ($globalDebug) echo 'Count all owners...'."\n";
1675
+			if ($globalDebug) {
1676
+				echo 'Count all owners...'."\n";
1677
+			}
1469 1678
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1470 1679
 			foreach ($alldata as $number) {
1471 1680
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1472 1681
 			}
1473
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1682
+			if ($globalDebug) {
1683
+				echo 'Count all pilots...'."\n";
1684
+			}
1474 1685
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1475 1686
 			foreach ($alldata as $number) {
1476 1687
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1477 1688
 			}
1478 1689
 			
1479
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1690
+			if ($globalDebug) {
1691
+				echo 'Count all departure airports...'."\n";
1692
+			}
1480 1693
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1481
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1694
+			if ($globalDebug) {
1695
+				echo 'Count all detected departure airports...'."\n";
1696
+			}
1482 1697
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1483
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1698
+			if ($globalDebug) {
1699
+				echo 'Order departure airports...'."\n";
1700
+			}
1484 1701
 	        	$alldata = array();
1485 1702
 	        	
1486 1703
     			foreach ($pall as $value) {
@@ -1491,7 +1708,9 @@  discard block
 block discarded – undo
1491 1708
     				$icao = $value['airport_departure_icao'];
1492 1709
         			if (isset($alldata[$icao])) {
1493 1710
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1494
-        			} else $alldata[$icao] = $value;
1711
+        			} else {
1712
+        				$alldata[$icao] = $value;
1713
+        			}
1495 1714
 			}
1496 1715
     			$count = array();
1497 1716
     			foreach ($alldata as $key => $row) {
@@ -1501,11 +1720,17 @@  discard block
 block discarded – undo
1501 1720
 			foreach ($alldata as $number) {
1502 1721
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1503 1722
 			}
1504
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1723
+			if ($globalDebug) {
1724
+				echo 'Count all arrival airports...'."\n";
1725
+			}
1505 1726
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1506
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1727
+			if ($globalDebug) {
1728
+				echo 'Count all detected arrival airports...'."\n";
1729
+			}
1507 1730
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1508
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1731
+			if ($globalDebug) {
1732
+				echo 'Order arrival airports...'."\n";
1733
+			}
1509 1734
 	        	$alldata = array();
1510 1735
     			foreach ($pall as $value) {
1511 1736
 	        		$icao = $value['airport_arrival_icao'];
@@ -1515,7 +1740,9 @@  discard block
 block discarded – undo
1515 1740
     				$icao = $value['airport_arrival_icao'];
1516 1741
         			if (isset($alldata[$icao])) {
1517 1742
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1518
-	        		} else $alldata[$icao] = $value;
1743
+	        		} else {
1744
+	        			$alldata[$icao] = $value;
1745
+	        		}
1519 1746
     			}
1520 1747
         		$count = array();
1521 1748
         		foreach ($alldata as $key => $row) {
@@ -1526,7 +1753,9 @@  discard block
 block discarded – undo
1526 1753
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1527 1754
 			}
1528 1755
 			if ($Connection->tableExists('countries')) {
1529
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1756
+				if ($globalDebug) {
1757
+					echo 'Count all flights by countries...'."\n";
1758
+				}
1530 1759
 				$SpotterArchive = new SpotterArchive();
1531 1760
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1532 1761
 				foreach ($alldata as $number) {
@@ -1538,46 +1767,66 @@  discard block
 block discarded – undo
1538 1767
 			// Add by month using getstat if month finish...
1539 1768
 
1540 1769
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1541
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1770
+			if ($globalDebug) {
1771
+				echo 'Count all flights by months...'."\n";
1772
+			}
1542 1773
 			$Spotter = new Spotter($this->db);
1543 1774
 			$alldata = $Spotter->countAllMonths();
1544 1775
 			$lastyear = false;
1545 1776
 			foreach ($alldata as $number) {
1546
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1777
+				if ($number['year_name'] != date('Y')) {
1778
+					$lastyear = true;
1779
+				}
1547 1780
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1548 1781
 			}
1549
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1782
+			if ($globalDebug) {
1783
+				echo 'Count all military flights by months...'."\n";
1784
+			}
1550 1785
 			$alldata = $Spotter->countAllMilitaryMonths();
1551 1786
 			foreach ($alldata as $number) {
1552 1787
 				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1553 1788
 			}
1554
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1789
+			if ($globalDebug) {
1790
+				echo 'Count all owners by months...'."\n";
1791
+			}
1555 1792
 			$alldata = $Spotter->countAllMonthsOwners();
1556 1793
 			foreach ($alldata as $number) {
1557 1794
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1558 1795
 			}
1559
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1796
+			if ($globalDebug) {
1797
+				echo 'Count all pilots by months...'."\n";
1798
+			}
1560 1799
 			$alldata = $Spotter->countAllMonthsPilots();
1561 1800
 			foreach ($alldata as $number) {
1562 1801
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1563 1802
 			}
1564
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1803
+			if ($globalDebug) {
1804
+				echo 'Count all airlines by months...'."\n";
1805
+			}
1565 1806
 			$alldata = $Spotter->countAllMonthsAirlines();
1566 1807
 			foreach ($alldata as $number) {
1567 1808
 				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1568 1809
 			}
1569
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1810
+			if ($globalDebug) {
1811
+				echo 'Count all aircrafts by months...'."\n";
1812
+			}
1570 1813
 			$alldata = $Spotter->countAllMonthsAircrafts();
1571 1814
 			foreach ($alldata as $number) {
1572 1815
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1573 1816
 			}
1574
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1817
+			if ($globalDebug) {
1818
+				echo 'Count all real arrivals by months...'."\n";
1819
+			}
1575 1820
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1576 1821
 			foreach ($alldata as $number) {
1577 1822
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1578 1823
 			}
1579
-			if ($globalDebug) echo 'Airports data...'."\n";
1580
-			if ($globalDebug) echo '...Departure'."\n";
1824
+			if ($globalDebug) {
1825
+				echo 'Airports data...'."\n";
1826
+			}
1827
+			if ($globalDebug) {
1828
+				echo '...Departure'."\n";
1829
+			}
1581 1830
 			$this->deleteStatAirport('daily');
1582 1831
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1583 1832
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1698,44 +1947,62 @@  discard block
 block discarded – undo
1698 1947
 			// Count by airlines
1699 1948
 			echo '--- Stats by airlines ---'."\n";
1700 1949
 			if ($Connection->tableExists('countries')) {
1701
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1950
+				if ($globalDebug) {
1951
+					echo 'Count all flights by countries by airlines...'."\n";
1952
+				}
1702 1953
 				$SpotterArchive = new SpotterArchive();
1703 1954
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1704 1955
 				foreach ($alldata as $number) {
1705 1956
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1706 1957
 				}
1707 1958
 			}
1708
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1959
+			if ($globalDebug) {
1960
+				echo 'Count all aircraft types by airlines...'."\n";
1961
+			}
1709 1962
 			$Spotter = new Spotter($this->db);
1710 1963
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1711 1964
 			foreach ($alldata as $number) {
1712 1965
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1713 1966
 			}
1714
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1967
+			if ($globalDebug) {
1968
+				echo 'Count all aircraft registrations by airlines...'."\n";
1969
+			}
1715 1970
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1716 1971
 			foreach ($alldata as $number) {
1717 1972
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1718 1973
 			}
1719
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1974
+			if ($globalDebug) {
1975
+				echo 'Count all callsigns by airlines...'."\n";
1976
+			}
1720 1977
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1721 1978
 			foreach ($alldata as $number) {
1722 1979
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1723 1980
 			}
1724
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1981
+			if ($globalDebug) {
1982
+				echo 'Count all owners by airlines...'."\n";
1983
+			}
1725 1984
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1726 1985
 			foreach ($alldata as $number) {
1727 1986
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1728 1987
 			}
1729
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1988
+			if ($globalDebug) {
1989
+				echo 'Count all pilots by airlines...'."\n";
1990
+			}
1730 1991
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1731 1992
 			foreach ($alldata as $number) {
1732 1993
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1733 1994
 			}
1734
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1995
+			if ($globalDebug) {
1996
+				echo 'Count all departure airports by airlines...'."\n";
1997
+			}
1735 1998
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1736
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1999
+			if ($globalDebug) {
2000
+				echo 'Count all detected departure airports by airlines...'."\n";
2001
+			}
1737 2002
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1738
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2003
+			if ($globalDebug) {
2004
+				echo 'Order detected departure airports by airlines...'."\n";
2005
+			}
1739 2006
 	        	//$alldata = array();
1740 2007
     			foreach ($dall as $value) {
1741 2008
     				$icao = $value['airport_departure_icao'];
@@ -1756,11 +2023,17 @@  discard block
 block discarded – undo
1756 2023
 			foreach ($alldata as $number) {
1757 2024
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
1758 2025
 			}
1759
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2026
+			if ($globalDebug) {
2027
+				echo 'Count all arrival airports by airlines...'."\n";
2028
+			}
1760 2029
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1761
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2030
+			if ($globalDebug) {
2031
+				echo 'Count all detected arrival airports by airlines...'."\n";
2032
+			}
1762 2033
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1763
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2034
+			if ($globalDebug) {
2035
+				echo 'Order arrival airports by airlines...'."\n";
2036
+			}
1764 2037
 	        	//$alldata = array();
1765 2038
     			foreach ($dall as $value) {
1766 2039
     				$icao = $value['airport_arrival_icao'];
@@ -1779,37 +2052,53 @@  discard block
 block discarded – undo
1779 2052
     			}
1780 2053
     			$alldata = $pall;
1781 2054
                         foreach ($alldata as $number) {
1782
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
2055
+				if ($number['airline_icao'] != '') {
2056
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
2057
+				}
2058
+			}
2059
+			if ($globalDebug) {
2060
+				echo 'Count all flights by months by airlines...'."\n";
1783 2061
 			}
1784
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1785 2062
 			$Spotter = new Spotter($this->db);
1786 2063
 			$alldata = $Spotter->countAllMonthsByAirlines();
1787 2064
 			$lastyear = false;
1788 2065
 			foreach ($alldata as $number) {
1789
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2066
+				if ($number['year_name'] != date('Y')) {
2067
+					$lastyear = true;
2068
+				}
1790 2069
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1791 2070
 			}
1792
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2071
+			if ($globalDebug) {
2072
+				echo 'Count all owners by months by airlines...'."\n";
2073
+			}
1793 2074
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1794 2075
 			foreach ($alldata as $number) {
1795 2076
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1796 2077
 			}
1797
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2078
+			if ($globalDebug) {
2079
+				echo 'Count all pilots by months by airlines...'."\n";
2080
+			}
1798 2081
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1799 2082
 			foreach ($alldata as $number) {
1800 2083
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1801 2084
 			}
1802
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2085
+			if ($globalDebug) {
2086
+				echo 'Count all aircrafts by months by airlines...'."\n";
2087
+			}
1803 2088
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1804 2089
 			foreach ($alldata as $number) {
1805 2090
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1806 2091
 			}
1807
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2092
+			if ($globalDebug) {
2093
+				echo 'Count all real arrivals by months by airlines...'."\n";
2094
+			}
1808 2095
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1809 2096
 			foreach ($alldata as $number) {
1810 2097
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1811 2098
 			}
1812
-			if ($globalDebug) echo '...Departure'."\n";
2099
+			if ($globalDebug) {
2100
+				echo '...Departure'."\n";
2101
+			}
1813 2102
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1814 2103
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1815 2104
     			foreach ($dall as $value) {
@@ -1832,7 +2121,9 @@  discard block
 block discarded – undo
1832 2121
 			foreach ($alldata as $number) {
1833 2122
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1834 2123
 			}
1835
-			if ($globalDebug) echo '...Arrival'."\n";
2124
+			if ($globalDebug) {
2125
+				echo '...Arrival'."\n";
2126
+			}
1836 2127
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1837 2128
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1838 2129
     			foreach ($dall as $value) {
@@ -1856,13 +2147,19 @@  discard block
 block discarded – undo
1856 2147
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1857 2148
 			}
1858 2149
 
1859
-			if ($globalDebug) echo 'Flights data...'."\n";
1860
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2150
+			if ($globalDebug) {
2151
+				echo 'Flights data...'."\n";
2152
+			}
2153
+			if ($globalDebug) {
2154
+				echo '-> countAllDatesLastMonth...'."\n";
2155
+			}
1861 2156
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1862 2157
 			foreach ($alldata as $number) {
1863 2158
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1864 2159
 			}
1865
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2160
+			if ($globalDebug) {
2161
+				echo '-> countAllDates...'."\n";
2162
+			}
1866 2163
 			//$previousdata = $this->countAllDatesByAirlines();
1867 2164
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1868 2165
 			$values = array();
@@ -1875,7 +2172,9 @@  discard block
 block discarded – undo
1875 2172
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1876 2173
 			}
1877 2174
 			
1878
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2175
+			if ($globalDebug) {
2176
+				echo '-> countAllHours...'."\n";
2177
+			}
1879 2178
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1880 2179
 			foreach ($alldata as $number) {
1881 2180
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1883,7 +2182,9 @@  discard block
 block discarded – undo
1883 2182
 			
1884 2183
 
1885 2184
 			// Stats by filters
1886
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2185
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2186
+				$globalStatsFilters = array();
2187
+			}
1887 2188
 			foreach ($globalStatsFilters as $name => $filter) {
1888 2189
 				//$filter_name = $filter['name'];
1889 2190
 				$filter_name = $name;
@@ -1891,11 +2192,15 @@  discard block
 block discarded – undo
1891 2192
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1892 2193
 				if (isset($last_update[0]['value'])) {
1893 2194
 					$last_update_day = $last_update[0]['value'];
1894
-				} else $last_update_day = '2012-12-12 12:12:12';
2195
+				} else {
2196
+					$last_update_day = '2012-12-12 12:12:12';
2197
+				}
1895 2198
 				$reset = false;
1896 2199
 
1897 2200
 				// Count by filter
1898
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2201
+				if ($globalDebug) {
2202
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2203
+				}
1899 2204
 				$Spotter = new Spotter($this->db);
1900 2205
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1901 2206
 				foreach ($alldata as $number) {
@@ -1932,7 +2237,9 @@  discard block
 block discarded – undo
1932 2237
 	    				$icao = $value['airport_departure_icao'];
1933 2238
         				if (isset($alldata[$icao])) {
1934 2239
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1935
-        				} else $alldata[$icao] = $value;
2240
+        				} else {
2241
+        					$alldata[$icao] = $value;
2242
+        				}
1936 2243
 				}
1937 2244
 	    			$count = array();
1938 2245
     				foreach ($alldata as $key => $row) {
@@ -1953,7 +2260,9 @@  discard block
 block discarded – undo
1953 2260
 	    				$icao = $value['airport_arrival_icao'];
1954 2261
         				if (isset($alldata[$icao])) {
1955 2262
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1956
-		        		} else $alldata[$icao] = $value;
2263
+		        		} else {
2264
+		        			$alldata[$icao] = $value;
2265
+		        		}
1957 2266
 	    			}
1958 2267
         			$count = array();
1959 2268
         			foreach ($alldata as $key => $row) {
@@ -1967,7 +2276,9 @@  discard block
 block discarded – undo
1967 2276
 				$alldata = $Spotter->countAllMonths($filter);
1968 2277
 				$lastyear = false;
1969 2278
 				foreach ($alldata as $number) {
1970
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2279
+					if ($number['year_name'] != date('Y')) {
2280
+						$lastyear = true;
2281
+					}
1971 2282
 					$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1972 2283
 				}
1973 2284
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.