Completed
Push — master ( 79cbb4...2c41c0 )
by Yannick
30:50
created
require/class.Connection.php 2 patches
Doc Comments   +20 added lines patch added patch discarded remove patch
@@ -6,6 +6,9 @@  discard block
 block discarded – undo
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 48;
8 8
 
9
+	/**
10
+	 * @param string $dbname
11
+	 */
9 12
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10 13
 		global $globalNoDB;
11 14
 		if (isset($globalNoDB) && $globalNoDB === TRUE) {
@@ -142,6 +145,9 @@  discard block
 block discarded – undo
142 145
 		return true;
143 146
 	}
144 147
 
148
+	/**
149
+	 * @param string $table
150
+	 */
145 151
 	public function tableExists($table)
146 152
 	{
147 153
 		global $globalDBdriver, $globalDBname;
@@ -192,6 +198,11 @@  discard block
 block discarded – undo
192 198
 	/*
193 199
 	* Check if index exist
194 200
 	*/
201
+
202
+	/**
203
+	 * @param string $table
204
+	 * @param string $index
205
+	 */
195 206
 	public function indexExists($table,$index)
196 207
 	{
197 208
 		global $globalDBdriver, $globalDBname;
@@ -234,6 +245,10 @@  discard block
 block discarded – undo
234 245
 		return $columns;
235 246
 	}
236 247
 
248
+	/**
249
+	 * @param string $table
250
+	 * @param string $column
251
+	 */
237 252
 	public function getColumnType($table,$column) {
238 253
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
239 254
 		$tomet = $select->getColumnMeta(0);
@@ -244,6 +259,11 @@  discard block
 block discarded – undo
244 259
 	* Check if a column name exist in a table
245 260
 	* @return Boolean column exist or not
246 261
 	*/
262
+
263
+	/**
264
+	 * @param string $table
265
+	 * @param string $name
266
+	 */
247 267
 	public function checkColumnName($table,$name)
248 268
 	{
249 269
 		global $globalDBdriver, $globalDBname;
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 
4
-class Connection{
4
+class Connection {
5 5
 	public $db = null;
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 48;
8 8
 
9
-	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
9
+	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) {
10 10
 		global $globalNoDB;
11 11
 		if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 			$this->db = null;
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 					if ($user === null && $pass === null) {
17 17
 						$this->createDBConnection();
18 18
 					} else {
19
-						$this->createDBConnection(null,$user,$pass);
19
+						$this->createDBConnection(null, $user, $pass);
20 20
 					}
21 21
 				} else {
22 22
 					$this->createDBConnection($dbname);
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 		while (true) {
101 101
 			try {
102 102
 				if ($globalDBSdriver == 'mysql') {
103
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass);
103
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass);
104 104
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
105 105
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
106
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
107
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
108
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
109
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
110
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
106
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
107
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500);
108
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
109
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
110
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
111 111
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
112 112
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
113 113
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -117,19 +117,19 @@  discard block
 block discarded – undo
117 117
 					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"');
118 118
 					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"');
119 119
 				} else {
120
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass);
120
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass);
121 121
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
122 122
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
123
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
124
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
125
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
126
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
127
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
123
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
124
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200);
125
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
126
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
127
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
128 128
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
129 129
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
130 130
 				}
131 131
 				break;
132
-			} catch(PDOException $e) {
132
+			} catch (PDOException $e) {
133 133
 				$i++;
134 134
 				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
135 135
 				//exit;
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 		try {
155 155
 			//$Connection = new Connection();
156 156
 			$results = $this->db->query($query);
157
-		} catch(PDOException $e) {
157
+		} catch (PDOException $e) {
158 158
 			return false;
159 159
 		}
160
-		if($results->rowCount()>0) {
160
+		if ($results->rowCount() > 0) {
161 161
 		    return true; 
162 162
 		}
163 163
 		else return false;
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 			     return false;
180 180
 			}
181 181
 			
182
-		} catch(PDOException $e) {
183
-			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182
+		} catch (PDOException $e) {
183
+			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
184 184
             			throw $e;
185 185
 	                }
186 186
 	                //echo 'error ! '.$e->getMessage();
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	/*
193 193
 	* Check if index exist
194 194
 	*/
195
-	public function indexExists($table,$index)
195
+	public function indexExists($table, $index)
196 196
 	{
197 197
 		global $globalDBdriver, $globalDBname;
198 198
 		if ($globalDBdriver == 'mysql') {
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 		try {
204 204
 			//$Connection = new Connection();
205 205
 			$results = $this->db->query($query);
206
-		} catch(PDOException $e) {
206
+		} catch (PDOException $e) {
207 207
 			return false;
208 208
 		}
209 209
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
210
-		if($nb[0]['nb'] > 0) {
210
+		if ($nb[0]['nb'] > 0) {
211 211
 			return true; 
212 212
 		}
213 213
 		else return false;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		$query = "SELECT * FROM ".$table." LIMIT 0";
223 223
 		try {
224 224
 			$results = $this->db->query($query);
225
-		} catch(PDOException $e) {
225
+		} catch (PDOException $e) {
226 226
 			return "error : ".$e->getMessage()."\n";
227 227
 		}
228 228
 		$columns = array();
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		return $columns;
235 235
 	}
236 236
 
237
-	public function getColumnType($table,$column) {
237
+	public function getColumnType($table, $column) {
238 238
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
239 239
 		$tomet = $select->getColumnMeta(0);
240 240
 		return $tomet['native_type'];
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	* Check if a column name exist in a table
245 245
 	* @return Boolean column exist or not
246 246
 	*/
247
-	public function checkColumnName($table,$name)
247
+	public function checkColumnName($table, $name)
248 248
 	{
249 249
 		global $globalDBdriver, $globalDBname;
250 250
 		if ($globalDBdriver == 'mysql') {
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 		}
255 255
 			try {
256 256
 				$sth = $this->db()->prepare($query);
257
-				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name));
258
-			} catch(PDOException $e) {
257
+				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name));
258
+			} catch (PDOException $e) {
259 259
 				echo "error : ".$e->getMessage()."\n";
260 260
 			}
261 261
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 				try {
295 295
 					$sth = $this->db->prepare($query);
296 296
 					$sth->execute();
297
-				} catch(PDOException $e) {
297
+				} catch (PDOException $e) {
298 298
 					return "error : ".$e->getMessage()."\n";
299 299
 				}
300 300
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
require/class.AIS.php 2 patches
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -117,31 +117,31 @@  discard block
 block discarded – undo
117 117
 
118 118
 	private function make_latf($temp) { // unsigned long 
119 119
 		$flat = 0.0; // float
120
-		$temp = $temp & 0x07FFFFFF;
121
-		if ($temp & 0x04000000) {
122
-			$temp = $temp ^ 0x07FFFFFF;
120
+		$temp = $temp&0x07FFFFFF;
121
+		if ($temp&0x04000000) {
122
+			$temp = $temp^0x07FFFFFF;
123 123
 			$temp += 1;
124
-			$flat = (float)($temp / (60.0 * 10000.0));
124
+			$flat = (float) ($temp/(60.0*10000.0));
125 125
 			$flat *= -1.0;
126
-		} else $flat = (float)($temp / (60.0 * 10000.0));
126
+		} else $flat = (float) ($temp/(60.0*10000.0));
127 127
 		return $flat; // float
128 128
 	}
129 129
 
130 130
 	private function make_lonf($temp) { // unsigned long
131 131
 		$flon = 0.0; // float
132
-		$temp = $temp & 0x0FFFFFFF;
133
-		if ($temp & 0x08000000) {
134
-			$temp = $temp ^ 0x0FFFFFFF;
132
+		$temp = $temp&0x0FFFFFFF;
133
+		if ($temp&0x08000000) {
134
+			$temp = $temp^0x0FFFFFFF;
135 135
 			$temp += 1;
136
-			$flon = (float)($temp / (60.0 * 10000.0));
136
+			$flon = (float) ($temp/(60.0*10000.0));
137 137
 			$flon *= -1.0;
138
-		} else $flon = (float)($temp / (60.0 * 10000.0));
138
+		} else $flon = (float) ($temp/(60.0*10000.0));
139 139
 		return $flon;
140 140
 	}
141 141
 
142 142
 	private function ascii_2_dec($chr) {
143
-		$dec=ord($chr);//get decimal ascii code
144
-		$hex=dechex($dec);//convert decimal to hex
143
+		$dec = ord($chr); //get decimal ascii code
144
+		$hex = dechex($dec); //convert decimal to hex
145 145
 		return ($dec);
146 146
 	}
147 147
 	
@@ -160,15 +160,15 @@  discard block
 block discarded – undo
160 160
 		//only process in the following range: 48-87, 96-119
161 161
 		if ($ascii < 48) { }
162 162
 		else {
163
-			if($ascii>119) { }
163
+			if ($ascii > 119) { }
164 164
 			else {
165
-				if ($ascii>87 && $ascii<96) ;
165
+				if ($ascii > 87 && $ascii < 96);
166 166
 				else {
167
-					$ascii=$ascii+40;
168
-					if ($ascii>128){
169
-						$ascii=$ascii+32;
167
+					$ascii = $ascii + 40;
168
+					if ($ascii > 128) {
169
+						$ascii = $ascii + 32;
170 170
 					} else {
171
-						$ascii=$ascii+40;
171
+						$ascii = $ascii + 40;
172 172
 					}
173 173
 				}
174 174
 			}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	}
178 178
 
179 179
 	private function dec_2_6bit($dec) {
180
-		$bin=decbin($dec);
180
+		$bin = decbin($dec);
181 181
 		return(substr($bin, -6)); 
182 182
 	}
183 183
 
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 		);
196 196
 		// "
197 197
 		$rv = '';
198
-		if ($_size % 6 == 0) {
199
-			$len = $_size / 6;
200
-			for ($i=0; $i<$len; $i++) {
201
-				$offset = $i * 6;
202
-				$rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ];
198
+		if ($_size%6 == 0) {
199
+			$len = $_size/6;
200
+			for ($i = 0; $i < $len; $i++) {
201
+				$offset = $i*6;
202
+				$rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))];
203 203
 			}
204 204
 		}
205 205
 		return $rv;
@@ -226,93 +226,93 @@  discard block
 block discarded – undo
226 226
 		$ro->eta_hour = '';
227 227
 		$ro->eta_minute = '';
228 228
 		$ro->ts = time();
229
-		$ro->id = bindec(substr($_aisdata,0,6));
230
-		$ro->mmsi = bindec(substr($_aisdata,8,30));
229
+		$ro->id = bindec(substr($_aisdata, 0, 6));
230
+		$ro->mmsi = bindec(substr($_aisdata, 8, 30));
231 231
 		if ($ro->id >= 1 && $ro->id <= 3) {
232
-			$ro->cog = bindec(substr($_aisdata,116,12))/10;
233
-			$ro->sog = bindec(substr($_aisdata,50,10))/10;
234
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
235
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
232
+			$ro->cog = bindec(substr($_aisdata, 116, 12))/10;
233
+			$ro->sog = bindec(substr($_aisdata, 50, 10))/10;
234
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
235
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
236 236
 			$ro->cls = 1; // class A
237 237
 		} else if ($ro->id == 4) {
238
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28)));
239
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27)));
238
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28)));
239
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27)));
240 240
 			$ro->cls = 1; // class A
241 241
 		} else if ($ro->id == 5) {
242
-			$ro->imo = bindec(substr($_aisdata,40,30));
243
-			$ro->callsign = $this->binchar($_aisdata,70,42);
244
-			$ro->name = $this->binchar($_aisdata,112,120);
245
-			$ro->typeid = bindec(substr($_aisdata,232,8));
242
+			$ro->imo = bindec(substr($_aisdata, 40, 30));
243
+			$ro->callsign = $this->binchar($_aisdata, 70, 42);
244
+			$ro->name = $this->binchar($_aisdata, 112, 120);
245
+			$ro->typeid = bindec(substr($_aisdata, 232, 8));
246 246
 			$ro->type = $this->getShipType($ro->typeid);
247 247
 			//$ro->to_bow = bindec(substr($_aisdata,240,9));
248 248
 			//$ro->to_stern = bindec(substr($_aisdata,249,9));
249 249
 			//$ro->to_port = bindec(substr($_aisdata,258,6));
250 250
 			//$ro->to_starboard = bindec(substr($_aisdata,264,6));
251
-			$ro->eta_month = bindec(substr($_aisdata,274,4));
252
-			$ro->eta_day = bindec(substr($_aisdata,278,5));
253
-			$ro->eta_hour = bindec(substr($_aisdata,283,5));
254
-			$ro->eta_minute = bindec(substr($_aisdata,288,6));
251
+			$ro->eta_month = bindec(substr($_aisdata, 274, 4));
252
+			$ro->eta_day = bindec(substr($_aisdata, 278, 5));
253
+			$ro->eta_hour = bindec(substr($_aisdata, 283, 5));
254
+			$ro->eta_minute = bindec(substr($_aisdata, 288, 6));
255 255
 			//$ro->draught = bindec(substr($_aisdata,294,8));
256
-			$ro->destination = $this->binchar($_aisdata,302,120);
256
+			$ro->destination = $this->binchar($_aisdata, 302, 120);
257 257
 			$ro->cls = 1; // class A
258 258
 		} else if ($ro->id == 9) {
259 259
 			// Search and Rescue aircraft position report
260 260
 		} else if ($ro->id == 18) {
261
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
262
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
263
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
264
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
265
-			$ro->heading = bindec(substr($_aisdata,124,9));
261
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
262
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
263
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28)));
264
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27)));
265
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
266 266
 			if ($ro->heading == 511) $ro->heading = '';
267 267
 			$ro->cls = 2; // class B
268 268
 		} else if ($ro->id == 19) {
269
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
270
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
271
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
272
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
273
-			$ro->name = $this->binchar($_aisdata,143,120);
269
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
270
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
271
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
272
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
273
+			$ro->name = $this->binchar($_aisdata, 143, 120);
274 274
 			$ro->cls = 2; // class B
275
-			$ro->heading = bindec(substr($_aisdata,124,9));
275
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
276 276
 			if ($ro->heading == 511) $ro->heading = '';
277
-			$ro->typeid = bindec(substr($_aisdata,263,8));
277
+			$ro->typeid = bindec(substr($_aisdata, 263, 8));
278 278
 			$ro->type = $this->getShipType($ro->typeid);
279 279
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
280 280
 			//$ro->to_stern = bindec(substr($_aisdata,280,9));
281 281
 			//$ro->to_port = bindec(substr($_aisdata,289,6));
282 282
 			//$ro->to_starboard = bindec(substr($_aisdata,295,6));
283 283
 		} else if ($ro->id == 21) {
284
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28)));
285
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27)));
286
-			$ro->name = $this->binchar($_aisdata,43,120);
284
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28)));
285
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27)));
286
+			$ro->name = $this->binchar($_aisdata, 43, 120);
287 287
 			//$ro->to_bow = bindec(substr($_aisdata,219,9));
288 288
 			//$ro->to_stern = bindec(substr($_aisdata,228,9));
289 289
 			//$ro->to_port = bindec(substr($_aisdata,237,6));
290 290
 			//$ro->to_starboard = bindec(substr($_aisdata,243,6));
291 291
 			$ro->cls = 2; // class B
292 292
 		} else if ($ro->id == 24) {
293
-			$pn = bindec(substr($_aisdata,38,2));
293
+			$pn = bindec(substr($_aisdata, 38, 2));
294 294
 			if ($pn == 0) {
295
-				$ro->name = $this->binchar($_aisdata,40,120);
295
+				$ro->name = $this->binchar($_aisdata, 40, 120);
296 296
 			}
297
-			$ro->typeid = bindec(substr($_aisdata,40,8));
297
+			$ro->typeid = bindec(substr($_aisdata, 40, 8));
298 298
 			$ro->type = $this->getShipType($ro->typeid);
299
-			$ro->callsign = $this->binchar($_aisdata,90,42);
299
+			$ro->callsign = $this->binchar($_aisdata, 90, 42);
300 300
 			//$ro->to_bow = bindec(substr($_aisdata,132,9));
301 301
 			//$ro->to_stern = bindec(substr($_aisdata,141,9));
302 302
 			//$ro->to_port = bindec(substr($_aisdata,150,6));
303 303
 			//$ro->to_starboard = bindec(substr($_aisdata,156,6));
304 304
 			$ro->cls = 2; // class B
305 305
 		} else if ($ro->id == 27) {
306
-			$ro->cog = bindec(substr($_aisdata,85,9));
306
+			$ro->cog = bindec(substr($_aisdata, 85, 9));
307 307
 			if ($ro->cog == 511) $ro->cog = 0.0;
308
-			$ro->sog = bindec(substr($_aisdata,79,6));
308
+			$ro->sog = bindec(substr($_aisdata, 79, 6));
309 309
 			if ($ro->sog == 63) $ro->sog = 0.0;
310
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
311
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
310
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10);
311
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10);
312 312
 			$ro->cls = 1; // class A
313 313
 		
314 314
 		}
315
-		$ro->statusid = bindec(substr($_aisdata,38,4));
315
+		$ro->statusid = bindec(substr($_aisdata, 38, 4));
316 316
 		$ro->status = $this->getStatus($ro->statusid);
317 317
 		return $ro;
318 318
 	}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	}
360 360
 
361 361
 	public function getShipTypeID($type) {
362
-		$typeid = array_search($type,$this->shiptype);
362
+		$typeid = array_search($type, $this->shiptype);
363 363
 		if ($typeid !== FALSE) return $typeid;
364 364
 		else return '';
365 365
 	}
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
368 368
 		global $port; // tcpip port...
369 369
 		static $debug_counter = 0;
370
-		$aisdata168='';//six bit array of ascii characters
370
+		$aisdata168 = ''; //six bit array of ascii characters
371 371
 		$ais_nmea_array = str_split($_itu); // convert to an array
372 372
 		foreach ($ais_nmea_array as $value) {
373 373
 			$dec = $this->ascii_2_dec($value);
374 374
 			$bit8 = $this->asciidec_2_8bit($dec);
375 375
 			$bit6 = $this->dec_2_6bit($bit8);
376 376
 			//echo $value ."-" .$bit6 ."";
377
-			$aisdata168 .=$bit6;
377
+			$aisdata168 .= $bit6;
378 378
 		}
379 379
 		//echo $aisdata168 . "<br/>";
380 380
 		//return $this->decode_ais($aisdata168, $aux);
@@ -397,24 +397,24 @@  discard block
 block discarded – undo
397 397
 		// calculate checksum after ! till *
398 398
 		// assume 1st ! is valid
399 399
 		// find * ensure that it is at correct position
400
-		$end = strrpos ( $rawdata , '*' );
400
+		$end = strrpos($rawdata, '*');
401 401
 		if ($end === FALSE) return -1; // check for NULLS!!!
402
-		$cs = substr( $rawdata, $end + 1 );
403
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
404
-		$dcs = (int)hexdec( $cs );
405
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
406
-		if ( $chksum == $dcs ) { // NMEA checksum pass
402
+		$cs = substr($rawdata, $end + 1);
403
+		if (strlen($cs) != 2) return -1; // correct cs length
404
+		$dcs = (int) hexdec($cs);
405
+		for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum
406
+		if ($chksum == $dcs) { // NMEA checksum pass
407 407
 			$pcs = explode(',', $rawdata);
408 408
 			// !AI??? identifier
409 409
 			if (!isset($pcs[1])) {
410 410
 				echo "ERROR,INVALID_DATA ".time()." $rawdata\n";
411 411
 				return -1;
412 412
 			}
413
-			$num_seq = (int)$pcs[1]; // number of sequences
414
-			$seq = (int)$pcs[2]; // get sequence
413
+			$num_seq = (int) $pcs[1]; // number of sequences
414
+			$seq = (int) $pcs[2]; // get sequence
415 415
 			// get msg sequence id
416 416
 			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
417
-			else $msg_sid = (int)$pcs[3]; // multipart message
417
+			else $msg_sid = (int) $pcs[3]; // multipart message
418 418
 			$ais_ch = $pcs[4]; // get AIS channel
419 419
 			// message sequence checking
420 420
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 					}
448 448
 				}
449 449
 				$itu = $itu.$pcs[5]; // get itu message
450
-				$filler += (int)$pcs[6][0]; // get filler
450
+				$filler += (int) $pcs[6][0]; // get filler
451 451
 				if ($num_seq == 1 // valid single message
452 452
 				    || $num_seq == $pseq // valid multi-part message
453 453
 				) {
@@ -469,13 +469,13 @@  discard block
 block discarded – undo
469 469
 		$cbuf = $cbuf.$ibuf;
470 470
 		$last_pos = 0;
471 471
 		$result = new stdClass();
472
-		while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) {
472
+		while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) {
473 473
 		//while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) {
474 474
 			//DEBUG echo $cbuf;
475
-			if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim?
475
+			if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim?
476 476
 				$tst = substr($cbuf, $start - 3, ($end - $start + 3));
477 477
 				//DEBUG echo "[$start $end $tst]\n";
478
-				$result = $this->process_ais_raw( $tst, "" );
478
+				$result = $this->process_ais_raw($tst, "");
479 479
 				$last_pos = $end + 1;
480 480
 			} else break;
481 481
 		}
@@ -487,41 +487,41 @@  discard block
 block discarded – undo
487 487
 	// incoming data from serial or IP comms
488 488
 	public function process_ais_line($cbuf) {
489 489
 		$result = new stdClass();
490
-		$start = strpos($cbuf,"VDM");
490
+		$start = strpos($cbuf, "VDM");
491 491
 		$tst = substr($cbuf, $start - 3);
492
-		$result = $this->process_ais_raw( $tst, "" );
492
+		$result = $this->process_ais_raw($tst, "");
493 493
 		return $result;
494 494
 	}
495 495
 
496 496
 	/* AIS Encoding
497 497
 	*/
498
-	private function mk_ais_lat( $lat ) {
498
+	private function mk_ais_lat($lat) {
499 499
 		//$lat = 1.2569;
500
-		if ($lat<0.0) {
500
+		if ($lat < 0.0) {
501 501
 			$lat = -$lat;
502
-			$neg=true;
503
-		} else $neg=false;
502
+			$neg = true;
503
+		} else $neg = false;
504 504
 		$latd = 0x00000000;
505
-		$latd = intval ($lat * 600000.0);
506
-		if ($neg==true) {
505
+		$latd = intval($lat*600000.0);
506
+		if ($neg == true) {
507 507
 			$latd = ~$latd;
508
-			$latd+=1;
508
+			$latd += 1;
509 509
 			$latd &= 0x07FFFFFF;
510 510
 		}
511 511
 		return $latd;
512 512
 	}
513 513
 
514
-	private function mk_ais_lon( $lon ) {
514
+	private function mk_ais_lon($lon) {
515 515
 		//$lon = 103.851;
516
-		if ($lon<0.0) {
516
+		if ($lon < 0.0) {
517 517
 			$lon = -$lon;
518
-			$neg=true;
519
-		} else $neg=false;
518
+			$neg = true;
519
+		} else $neg = false;
520 520
 		$lond = 0x00000000;
521
-		$lond = intval ($lon * 600000.0);
522
-		if ($neg==true) {
521
+		$lond = intval($lon*600000.0);
522
+		if ($neg == true) {
523 523
 			$lond = ~$lond;
524
-			$lond+=1;
524
+			$lond += 1;
525 525
 			$lond &= 0x0FFFFFFF;
526 526
 		}
527 527
 		return $lond;
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
 
530 530
 	private function char2bin($name, $max_len) {
531 531
 		$len = strlen($name);
532
-		if ($len > $max_len) $name = substr($name,0,$max_len);
533
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
532
+		if ($len > $max_len) $name = substr($name, 0, $max_len);
533
+		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6);
534 534
 		else $pad = '';
535 535
 		$rv = '';
536 536
 		$ais_chars = array(
@@ -547,26 +547,26 @@  discard block
 block discarded – undo
547 547
 		if ($_a) foreach ($_a as $_1) {
548 548
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
549 549
 			else $dec = 0;
550
-			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
550
+			$bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT);
551 551
 			$rv .= $bin;
552 552
 			//echo "$_1 $dec ($bin)<br/>";
553 553
 		}
554 554
 		return $rv.$pad;
555 555
 	}
556 556
 
557
-	private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') {
557
+	private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') {
558 558
 		$len_bit = strlen($_enc);
559
-		$rem6 = $len_bit % 6;
559
+		$rem6 = $len_bit%6;
560 560
 		$pad6_len = 0;
561 561
 		if ($rem6) $pad6_len = 6 - $rem6;
562 562
 		//echo  $pad6_len.'<br>';
563 563
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
564
-		$len_enc = strlen($_enc) / 6;
564
+		$len_enc = strlen($_enc)/6;
565 565
 		//echo $_enc.' '.$len_enc.'<br/>';
566 566
 		$itu = '';
567
-		for ($i=0; $i<$len_enc; $i++) {
568
-			$offset = $i * 6;
569
-			$dec = bindec(substr($_enc,$offset,6));
567
+		for ($i = 0; $i < $len_enc; $i++) {
568
+			$offset = $i*6;
569
+			$dec = bindec(substr($_enc, $offset, 6));
570 570
 			if ($dec < 40) $dec += 48;
571 571
 			else $dec += 56;
572 572
 			//echo chr($dec)." $dec<br/>";
@@ -576,15 +576,15 @@  discard block
 block discarded – undo
576 576
 		$chksum = 0;
577 577
 		$itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0";
578 578
 		$len_itu = strlen($itu);
579
-		for ($i=0; $i<$len_itu; $i++) {
580
-			$chksum ^= ord( $itu[$i] );
579
+		for ($i = 0; $i < $len_itu; $i++) {
580
+			$chksum ^= ord($itu[$i]);
581 581
 		}
582
-		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
583
-		$lsb = $chksum & 0x0F;
584
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
582
+		$hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
583
+		$lsb = $chksum&0x0F;
584
+		if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb];
585 585
 		else $lsbc = '0';
586
-		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
587
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
586
+		$msb = (($chksum&0xF0) >> 4)&0x0F;
587
+		if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb];
588 588
 		else $msbc = '0';
589 589
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
590 590
 		return $itu;
@@ -610,14 +610,14 @@  discard block
 block discarded – undo
610 610
 
611 611
 	public function mmsitype($mmsi) {
612 612
 		if (strlen($mmsi) == 9) {
613
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
614
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
615
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
616
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
617
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
618
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
619
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
620
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
613
+			if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
614
+			elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device';
615
+			elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
616
+			elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft';
617
+			elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship';
618
+			elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation';
619
+			elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations';
620
+			elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships';
621 621
 			else return 'Ship';
622 622
 		}
623 623
 
@@ -627,19 +627,19 @@  discard block
 block discarded – undo
627 627
 	public function parse_line($buffer) {
628 628
 		global $globalDebug;
629 629
 		$result = array();
630
-		$start = strpos($buffer,"VDM");
630
+		$start = strpos($buffer, "VDM");
631 631
 		$tst = substr($buffer, $start - 3);
632
-		$data = $this->process_ais_raw( $tst, "" );
632
+		$data = $this->process_ais_raw($tst, "");
633 633
 		if (!is_object($data)) {
634 634
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
635 635
 			return array();
636 636
 		}
637 637
 		if ($data->lon != 0) $result['longitude'] = $data->lon;
638 638
 		if ($data->lat != 0) $result['latitude'] = $data->lat;
639
-		$result['ident'] = trim(str_replace('@','',$data->name));
639
+		$result['ident'] = trim(str_replace('@', '', $data->name));
640 640
 		$result['timestamp'] = $data->ts;
641 641
 		$result['mmsi'] = $data->mmsi;
642
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
642
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
643 643
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
644 644
 		if ($data->sog != -1.0) $result['speed'] = $data->sog;
645 645
 		if ($data->heading !== '') $result['heading'] = $data->heading;
@@ -649,16 +649,16 @@  discard block
 block discarded – undo
649 649
 		if ($data->type !== '') $result['type'] = $data->type;
650 650
 		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
651 651
 		if ($data->imo !== '') $result['imo'] = $data->imo;
652
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
652
+		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign));
653 653
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
654
-			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
654
+			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d", $data->eta_month).'-'.sprintf("%02d", $data->eta_day).' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
655 655
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
656 656
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
657
-			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
657
+			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
658 658
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
659 659
 		}
660 660
 		if ($data->destination != '') {
661
-			$dest = trim(str_replace('@','',$data->destination));
661
+			$dest = trim(str_replace('@', '', $data->destination));
662 662
 			if ($dest != '') $result['destination'] = $dest;
663 663
 		}
664 664
 		$result['all'] = (array) $data;
Please login to merge, or discard this patch.
Braces   +176 added lines, -65 removed lines patch added patch discarded remove patch
@@ -123,7 +123,9 @@  discard block
 block discarded – undo
123 123
 			$temp += 1;
124 124
 			$flat = (float)($temp / (60.0 * 10000.0));
125 125
 			$flat *= -1.0;
126
-		} else $flat = (float)($temp / (60.0 * 10000.0));
126
+		} else {
127
+			$flat = (float)($temp / (60.0 * 10000.0));
128
+		}
127 129
 		return $flat; // float
128 130
 	}
129 131
 
@@ -135,7 +137,9 @@  discard block
 block discarded – undo
135 137
 			$temp += 1;
136 138
 			$flon = (float)($temp / (60.0 * 10000.0));
137 139
 			$flon *= -1.0;
138
-		} else $flon = (float)($temp / (60.0 * 10000.0));
140
+		} else {
141
+			$flon = (float)($temp / (60.0 * 10000.0));
142
+		}
139 143
 		return $flon;
140 144
 	}
141 145
 
@@ -158,10 +162,8 @@  discard block
 block discarded – undo
158 162
     */
159 163
 	private function asciidec_2_8bit($ascii) {
160 164
 		//only process in the following range: 48-87, 96-119
161
-		if ($ascii < 48) { }
162
-		else {
163
-			if($ascii>119) { }
164
-			else {
165
+		if ($ascii < 48) { } else {
166
+			if($ascii>119) { } else {
165 167
 				if ($ascii>87 && $ascii<96) ;
166 168
 				else {
167 169
 					$ascii=$ascii+40;
@@ -263,7 +265,9 @@  discard block
 block discarded – undo
263 265
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
264 266
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
265 267
 			$ro->heading = bindec(substr($_aisdata,124,9));
266
-			if ($ro->heading == 511) $ro->heading = '';
268
+			if ($ro->heading == 511) {
269
+				$ro->heading = '';
270
+			}
267 271
 			$ro->cls = 2; // class B
268 272
 		} else if ($ro->id == 19) {
269 273
 			$ro->cog = bindec(substr($_aisdata,112,12))/10;
@@ -273,7 +277,9 @@  discard block
 block discarded – undo
273 277
 			$ro->name = $this->binchar($_aisdata,143,120);
274 278
 			$ro->cls = 2; // class B
275 279
 			$ro->heading = bindec(substr($_aisdata,124,9));
276
-			if ($ro->heading == 511) $ro->heading = '';
280
+			if ($ro->heading == 511) {
281
+				$ro->heading = '';
282
+			}
277 283
 			$ro->typeid = bindec(substr($_aisdata,263,8));
278 284
 			$ro->type = $this->getShipType($ro->typeid);
279 285
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
@@ -304,9 +310,13 @@  discard block
 block discarded – undo
304 310
 			$ro->cls = 2; // class B
305 311
 		} else if ($ro->id == 27) {
306 312
 			$ro->cog = bindec(substr($_aisdata,85,9));
307
-			if ($ro->cog == 511) $ro->cog = 0.0;
313
+			if ($ro->cog == 511) {
314
+				$ro->cog = 0.0;
315
+			}
308 316
 			$ro->sog = bindec(substr($_aisdata,79,6));
309
-			if ($ro->sog == 63) $ro->sog = 0.0;
317
+			if ($ro->sog == 63) {
318
+				$ro->sog = 0.0;
319
+			}
310 320
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
311 321
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
312 322
 			$ro->cls = 1; // class A
@@ -354,14 +364,20 @@  discard block
 block discarded – undo
354 364
 	}
355 365
 	
356 366
 	public function getShipType($code) {
357
-		if (isset($this->shiptype[$code])) return $this->shiptype[$code];
358
-		else return '';
367
+		if (isset($this->shiptype[$code])) {
368
+			return $this->shiptype[$code];
369
+		} else {
370
+			return '';
371
+		}
359 372
 	}
360 373
 
361 374
 	public function getShipTypeID($type) {
362 375
 		$typeid = array_search($type,$this->shiptype);
363
-		if ($typeid !== FALSE) return $typeid;
364
-		else return '';
376
+		if ($typeid !== FALSE) {
377
+			return $typeid;
378
+		} else {
379
+			return '';
380
+		}
365 381
 	}
366 382
 
367 383
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
@@ -398,11 +414,20 @@  discard block
 block discarded – undo
398 414
 		// assume 1st ! is valid
399 415
 		// find * ensure that it is at correct position
400 416
 		$end = strrpos ( $rawdata , '*' );
401
-		if ($end === FALSE) return -1; // check for NULLS!!!
417
+		if ($end === FALSE) {
418
+			return -1;
419
+		}
420
+		// check for NULLS!!!
402 421
 		$cs = substr( $rawdata, $end + 1 );
403
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
422
+		if ( strlen($cs) != 2 ) {
423
+			return -1;
424
+		}
425
+		// correct cs length
404 426
 		$dcs = (int)hexdec( $cs );
405
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
427
+		for ( $alias=1; $alias<$end; $alias++) {
428
+			$chksum ^= ord( $rawdata[$alias] );
429
+		}
430
+		// perform XOR for NMEA checksum
406 431
 		if ( $chksum == $dcs ) { // NMEA checksum pass
407 432
 			$pcs = explode(',', $rawdata);
408 433
 			// !AI??? identifier
@@ -413,8 +438,14 @@  discard block
 block discarded – undo
413 438
 			$num_seq = (int)$pcs[1]; // number of sequences
414 439
 			$seq = (int)$pcs[2]; // get sequence
415 440
 			// get msg sequence id
416
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
417
-			else $msg_sid = (int)$pcs[3]; // multipart message
441
+			if ($pcs[3] == '') {
442
+				$msg_sid = -1;
443
+			}
444
+			// non-multipart message, set to -1
445
+			else {
446
+				$msg_sid = (int)$pcs[3];
447
+			}
448
+			// multipart message
418 449
 			$ais_ch = $pcs[4]; // get AIS channel
419 450
 			// message sequence checking
420 451
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -477,10 +508,18 @@  discard block
 block discarded – undo
477 508
 				//DEBUG echo "[$start $end $tst]\n";
478 509
 				$result = $this->process_ais_raw( $tst, "" );
479 510
 				$last_pos = $end + 1;
480
-			} else break;
511
+			} else {
512
+				break;
513
+			}
514
+		}
515
+		if ($last_pos > 0) {
516
+			$cbuf = substr($cbuf, $last_pos);
481 517
 		}
482
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
483
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
518
+		// move...
519
+		if (strlen($cbuf) > 1024) {
520
+			$cbuf = "";
521
+		}
522
+		// prevent overflow simple mode...
484 523
 		return $result;
485 524
 	}
486 525
 
@@ -500,7 +539,9 @@  discard block
 block discarded – undo
500 539
 		if ($lat<0.0) {
501 540
 			$lat = -$lat;
502 541
 			$neg=true;
503
-		} else $neg=false;
542
+		} else {
543
+			$neg=false;
544
+		}
504 545
 		$latd = 0x00000000;
505 546
 		$latd = intval ($lat * 600000.0);
506 547
 		if ($neg==true) {
@@ -516,7 +557,9 @@  discard block
 block discarded – undo
516 557
 		if ($lon<0.0) {
517 558
 			$lon = -$lon;
518 559
 			$neg=true;
519
-		} else $neg=false;
560
+		} else {
561
+			$neg=false;
562
+		}
520 563
 		$lond = 0x00000000;
521 564
 		$lond = intval ($lon * 600000.0);
522 565
 		if ($neg==true) {
@@ -529,9 +572,14 @@  discard block
 block discarded – undo
529 572
 
530 573
 	private function char2bin($name, $max_len) {
531 574
 		$len = strlen($name);
532
-		if ($len > $max_len) $name = substr($name,0,$max_len);
533
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
534
-		else $pad = '';
575
+		if ($len > $max_len) {
576
+			$name = substr($name,0,$max_len);
577
+		}
578
+		if ($len < $max_len) {
579
+			$pad = str_repeat('0', ($max_len - $len) * 6);
580
+		} else {
581
+			$pad = '';
582
+		}
535 583
 		$rv = '';
536 584
 		$ais_chars = array(
537 585
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -544,9 +592,12 @@  discard block
 block discarded – undo
544 592
 		);
545 593
 		// "
546 594
 		$_a = str_split($name);
547
-		if ($_a) foreach ($_a as $_1) {
595
+		if ($_a) {
596
+			foreach ($_a as $_1) {
548 597
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
549
-			else $dec = 0;
598
+		} else {
599
+				$dec = 0;
600
+			}
550 601
 			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
551 602
 			$rv .= $bin;
552 603
 			//echo "$_1 $dec ($bin)<br/>";
@@ -558,7 +609,9 @@  discard block
 block discarded – undo
558 609
 		$len_bit = strlen($_enc);
559 610
 		$rem6 = $len_bit % 6;
560 611
 		$pad6_len = 0;
561
-		if ($rem6) $pad6_len = 6 - $rem6;
612
+		if ($rem6) {
613
+			$pad6_len = 6 - $rem6;
614
+		}
562 615
 		//echo  $pad6_len.'<br>';
563 616
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
564 617
 		$len_enc = strlen($_enc) / 6;
@@ -567,8 +620,11 @@  discard block
 block discarded – undo
567 620
 		for ($i=0; $i<$len_enc; $i++) {
568 621
 			$offset = $i * 6;
569 622
 			$dec = bindec(substr($_enc,$offset,6));
570
-			if ($dec < 40) $dec += 48;
571
-			else $dec += 56;
623
+			if ($dec < 40) {
624
+				$dec += 48;
625
+			} else {
626
+				$dec += 56;
627
+			}
572 628
 			//echo chr($dec)." $dec<br/>";
573 629
 			$itu .= chr($dec);
574 630
 		}
@@ -581,26 +637,42 @@  discard block
 block discarded – undo
581 637
 		}
582 638
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
583 639
 		$lsb = $chksum & 0x0F;
584
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
585
-		else $lsbc = '0';
640
+		if ($lsb >=0 && $lsb <= 15 ) {
641
+			$lsbc = $hex_arr[$lsb];
642
+		} else {
643
+			$lsbc = '0';
644
+		}
586 645
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
587
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
588
-		else $msbc = '0';
646
+		if ($msb >=0 && $msb <= 15 ) {
647
+			$msbc = $hex_arr[$msb];
648
+		} else {
649
+			$msbc = '0';
650
+		}
589 651
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
590 652
 		return $itu;
591 653
 	}
592 654
 
593 655
 	public function parse($buffer) {
594 656
 		$data = $this->process_ais_buf($buffer);
595
-		if (!is_object($data)) return array();
657
+		if (!is_object($data)) {
658
+			return array();
659
+		}
596 660
 		$result = array();
597
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
598
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
661
+		if ($data->lon != 0) {
662
+			$result['longitude'] = $data->lon;
663
+		}
664
+		if ($data->lat != 0) {
665
+			$result['latitude'] = $data->lat;
666
+		}
599 667
 		$result['ident'] = trim($data->name);
600 668
 		$result['timestamp'] = $data->ts;
601 669
 		$result['mmsi'] = $data->mmsi;
602
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
603
-		if ($data->cog != 0) $result['heading'] = $data->cog;
670
+		if ($data->sog != -1.0) {
671
+			$result['speed'] = $data->sog;
672
+		}
673
+		if ($data->cog != 0) {
674
+			$result['heading'] = $data->cog;
675
+		}
604 676
 		/*
605 677
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
606 678
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -610,15 +682,25 @@  discard block
 block discarded – undo
610 682
 
611 683
 	public function mmsitype($mmsi) {
612 684
 		if (strlen($mmsi) == 9) {
613
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
614
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
615
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
616
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
617
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
618
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
619
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
620
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
621
-			else return 'Ship';
685
+			if (substr($mmsi,0,3) == '974') {
686
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
687
+			} elseif (substr($mmsi,0,3) == '972') {
688
+				return 'MOB (Man Overboard) device';
689
+			} elseif (substr($mmsi,0,3) == '970') {
690
+				return 'AIS SART (Search and Rescue Transmitter)';
691
+			} elseif (substr($mmsi,0,3) == '111') {
692
+				return 'SAR (Search and Rescue) aircraft';
693
+			} elseif (substr($mmsi,0,2) == '98') {
694
+				return 'Auxiliary craft associated with a parent ship';
695
+			} elseif (substr($mmsi,0,2) == '99') {
696
+				return 'Aids to Navigation';
697
+			} elseif (substr($mmsi,0,2) == '00') {
698
+				return 'Coastal stations';
699
+			} elseif (substr($mmsi,0,1) == '0') {
700
+				return 'Group of ships';
701
+			} else {
702
+				return 'Ship';
703
+			}
622 704
 		}
623 705
 
624 706
 	
@@ -634,32 +716,61 @@  discard block
 block discarded – undo
634 716
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
635 717
 			return array();
636 718
 		}
637
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
638
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
719
+		if ($data->lon != 0) {
720
+			$result['longitude'] = $data->lon;
721
+		}
722
+		if ($data->lat != 0) {
723
+			$result['latitude'] = $data->lat;
724
+		}
639 725
 		$result['ident'] = trim(str_replace('@','',$data->name));
640 726
 		$result['timestamp'] = $data->ts;
641 727
 		$result['mmsi'] = $data->mmsi;
642
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
728
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') {
729
+			$result['mmsi'] = '3'.$result['mmsi'];
730
+		}
643 731
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
644
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
645
-		if ($data->heading !== '') $result['heading'] = $data->heading;
646
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
647
-		if ($data->status != '') $result['status'] = $data->status;
648
-		if ($data->statusid !== '') $result['statusid'] = $data->statusid;
649
-		if ($data->type !== '') $result['type'] = $data->type;
650
-		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
651
-		if ($data->imo !== '') $result['imo'] = $data->imo;
652
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
732
+		if ($data->sog != -1.0) {
733
+			$result['speed'] = $data->sog;
734
+		}
735
+		if ($data->heading !== '') {
736
+			$result['heading'] = $data->heading;
737
+		} elseif ($data->cog != 0) {
738
+			$result['heading'] = $data->cog;
739
+		}
740
+		if ($data->status != '') {
741
+			$result['status'] = $data->status;
742
+		}
743
+		if ($data->statusid !== '') {
744
+			$result['statusid'] = $data->statusid;
745
+		}
746
+		if ($data->type !== '') {
747
+			$result['type'] = $data->type;
748
+		}
749
+		if ($data->typeid !== '') {
750
+			$result['typeid'] = $data->typeid;
751
+		}
752
+		if ($data->imo !== '') {
753
+			$result['imo'] = $data->imo;
754
+		}
755
+		if ($data->callsign !== '') {
756
+			$result['callsign'] = trim(str_replace('@','',$data->callsign));
757
+		}
653 758
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
654 759
 			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
655
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
760
+			if ($eta_ts != '') {
761
+				$result['eta_ts'] = $eta_ts;
762
+			}
656 763
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
657 764
 			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
658
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
765
+			if ($eta_ts != '') {
766
+				$result['eta_ts'] = $eta_ts;
767
+			}
659 768
 		}
660 769
 		if ($data->destination != '') {
661 770
 			$dest = trim(str_replace('@','',$data->destination));
662
-			if ($dest != '') $result['destination'] = $dest;
771
+			if ($dest != '') {
772
+				$result['destination'] = $dest;
773
+			}
663 774
 		}
664 775
 		$result['all'] = (array) $data;
665 776
 		/*
Please login to merge, or discard this patch.
require/class.Stats.php 2 patches
Spacing   +616 added lines, -616 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 		if ($this->db === null) die('Error: No DB connection. (Stats)');
22 22
 	}
23 23
 
24
-	public function addLastStatsUpdate($type,$stats_date) {
24
+	public function addLastStatsUpdate($type, $stats_date) {
25 25
 		$query = "DELETE FROM config WHERE name = :type;
26 26
 			    INSERT INTO config (name,value) VALUES (:type,:stats_date);";
27
-		$query_values = array('type' => $type,':stats_date' => $stats_date);
27
+		$query_values = array('type' => $type, ':stats_date' => $stats_date);
28 28
 		try {
29 29
 			$sth = $this->db->prepare($query);
30 30
 			$sth->execute($query_values);
31
-		} catch(PDOException $e) {
31
+		} catch (PDOException $e) {
32 32
 			return "error : ".$e->getMessage();
33 33
 		}
34 34
 	}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		try {
39 39
 			$sth = $this->db->prepare($query);
40 40
 			$sth->execute(array(':type' => $type));
41
-		} catch(PDOException $e) {
41
+		} catch (PDOException $e) {
42 42
 			echo "error : ".$e->getMessage();
43 43
 		}
44 44
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		try {
60 60
 			$sth = $this->db->prepare($query);
61 61
 			$sth->execute(array(':filter_name' => $filter_name));
62
-		} catch(PDOException $e) {
62
+		} catch (PDOException $e) {
63 63
 			return "error : ".$e->getMessage();
64 64
 		}
65 65
 	}
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
 		try {
73 73
 			$sth = $this->db->prepare($query);
74 74
 			$sth->execute();
75
-		} catch(PDOException $e) {
75
+		} catch (PDOException $e) {
76 76
 			return "error : ".$e->getMessage();
77 77
 		}
78 78
 		$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
79 79
 		try {
80 80
 			$sth = $this->db->prepare($query);
81 81
 			$sth->execute(array(':filter_name' => $filter_name));
82
-		} catch(PDOException $e) {
82
+		} catch (PDOException $e) {
83 83
 			return "error : ".$e->getMessage();
84 84
 		}
85 85
 	}
@@ -91,77 +91,77 @@  discard block
 block discarded – undo
91 91
 		 try {
92 92
 			$sth = $this->db->prepare($query);
93 93
 			$sth->execute(array(':filter_name' => $filter_name));
94
-		} catch(PDOException $e) {
94
+		} catch (PDOException $e) {
95 95
 			echo "error : ".$e->getMessage();
96 96
 		}
97 97
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
98 98
 		if (empty($all)) {
99 99
 			$filters = array();
100 100
 			if ($filter_name != '') {
101
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
101
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
102 102
 			}
103 103
 			$Spotter = new Spotter($this->db);
104
-			$all = $Spotter->getAllAirlineNames('',NULL,$filters);
104
+			$all = $Spotter->getAllAirlineNames('', NULL, $filters);
105 105
 		}
106 106
 		return $all;
107 107
 	}
108
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
108
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
109 109
 		if ($filter_name == '') $filter_name = $this->filter_name;
110 110
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
111 111
 		try {
112 112
 			$sth = $this->db->prepare($query);
113
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
114
-		} catch(PDOException $e) {
113
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
114
+		} catch (PDOException $e) {
115 115
 			echo "error : ".$e->getMessage();
116 116
 		}
117 117
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
118 118
 		return $all;
119 119
 	}
120
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
120
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
121 121
 		if ($filter_name == '') $filter_name = $this->filter_name;
122 122
 		$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";
123 123
 		try {
124 124
 			$sth = $this->db->prepare($query);
125
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
126
-		} catch(PDOException $e) {
125
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
126
+		} catch (PDOException $e) {
127 127
 			echo "error : ".$e->getMessage();
128 128
 		}
129 129
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
130 130
 		return $all;
131 131
 	}
132
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
132
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
133 133
 		if ($filter_name == '') $filter_name = $this->filter_name;
134 134
 		$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";
135 135
 		try {
136 136
 			$sth = $this->db->prepare($query);
137
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
138
-		} catch(PDOException $e) {
137
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
138
+		} catch (PDOException $e) {
139 139
 			echo "error : ".$e->getMessage();
140 140
 		}
141 141
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
142 142
 		return $all;
143 143
 	}
144 144
 
145
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
145
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
146 146
 		if ($filter_name == '') $filter_name = $this->filter_name;
147 147
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
148 148
 		try {
149 149
 			$sth = $this->db->prepare($query);
150
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
151
-		} catch(PDOException $e) {
150
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
151
+		} catch (PDOException $e) {
152 152
 			echo "error : ".$e->getMessage();
153 153
 		}
154 154
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
155 155
 		return $all;
156 156
 	}
157 157
 
158
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
158
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
159 159
 		if ($filter_name == '') $filter_name = $this->filter_name;
160 160
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
161 161
 		try {
162 162
 			$sth = $this->db->prepare($query);
163
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
164
-		} catch(PDOException $e) {
163
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
164
+		} catch (PDOException $e) {
165 165
 			echo "error : ".$e->getMessage();
166 166
 		}
167 167
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -169,23 +169,23 @@  discard block
 block discarded – undo
169 169
 	}
170 170
 
171 171
 
172
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
172
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
173 173
 		global $globalStatsFilters;
174 174
 		if ($filter_name == '') $filter_name = $this->filter_name;
175
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
175
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
176 176
 			$Spotter = new Spotter($this->db);
177
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
177
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
178 178
 			$alliance_airlines = array();
179 179
 			foreach ($airlines as $airline) {
180
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
180
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
181 181
 			}
182 182
 			if ($year == '' && $month == '') {
183
-				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 aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
183
+				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 aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
+				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
185 185
 				try {
186 186
 					$sth = $this->db->prepare($query);
187 187
 					$sth->execute(array(':filter_name' => $filter_name));
188
-				} catch(PDOException $e) {
188
+				} catch (PDOException $e) {
189 189
 					echo "error : ".$e->getMessage();
190 190
 				}
191 191
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -196,29 +196,29 @@  discard block
 block discarded – undo
196 196
 				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
197 197
 				try {
198 198
 					$sth = $this->db->prepare($query);
199
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
200
-				} catch(PDOException $e) {
199
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
200
+				} catch (PDOException $e) {
201 201
 					echo "error : ".$e->getMessage();
202 202
 				}
203 203
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
204 204
 			} else $all = array();
205 205
 		}
206 206
 		if (empty($all)) {
207
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
208
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
207
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
208
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
209 209
 			} else {
210
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
210
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
211 211
 			}
212 212
 			if ($filter_name != '') {
213
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
213
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
214 214
 			}
215 215
 			$Spotter = new Spotter($this->db);
216 216
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
217
-			$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
217
+			$all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
218 218
 		}
219 219
 		return $all;
220 220
 	}
221
-	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
221
+	public function countAllMarineTypes($limit = true, $filter_name = '', $year = '', $month = '') {
222 222
 		global $globalStatsFilters;
223 223
 		if ($filter_name == '') $filter_name = $this->filter_name;
224 224
 		if ($year == '' && $month == '') {
@@ -227,23 +227,23 @@  discard block
 block discarded – undo
227 227
 			try {
228 228
 				$sth = $this->db->prepare($query);
229 229
 				$sth->execute(array(':filter_name' => $filter_name));
230
-			} catch(PDOException $e) {
230
+			} catch (PDOException $e) {
231 231
 				echo "error : ".$e->getMessage();
232 232
 			}
233 233
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
234 234
 		} else $all = array();
235 235
 		if (empty($all)) {
236
-			$filters = array('year' => $year,'month' => $month);
236
+			$filters = array('year' => $year, 'month' => $month);
237 237
 			if ($filter_name != '') {
238
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
238
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
239 239
 			}
240 240
 			$Marine = new Marine($this->db);
241 241
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
242
-			$all = $Marine->countAllMarineTypes($limit,0,'',$filters);
242
+			$all = $Marine->countAllMarineTypes($limit, 0, '', $filters);
243 243
 		}
244 244
 		return $all;
245 245
 	}
246
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
246
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
247 247
 		global $globalStatsFilters;
248 248
 		if ($filter_name == '') $filter_name = $this->filter_name;
249 249
 		if ($year == '' && $month == '') {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			try {
253 253
 				$sth = $this->db->prepare($query);
254 254
 				$sth->execute(array(':filter_name' => $filter_name));
255
-			} catch(PDOException $e) {
255
+			} catch (PDOException $e) {
256 256
 				echo "error : ".$e->getMessage();
257 257
 			}
258 258
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -260,32 +260,32 @@  discard block
 block discarded – undo
260 260
 		if (empty($all)) {
261 261
 			$Spotter = new Spotter($this->db);
262 262
 			$filters = array();
263
-			$filters = array('year' => $year,'month' => $month);
263
+			$filters = array('year' => $year, 'month' => $month);
264 264
 			if ($filter_name != '') {
265
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
265
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
266 266
 			}
267 267
 			//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
268
-			$all = $Spotter->countAllAirlineCountries($limit,$filters);
268
+			$all = $Spotter->countAllAirlineCountries($limit, $filters);
269 269
 		}
270 270
 		return $all;
271 271
 	}
272
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
272
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
273 273
 		global $globalStatsFilters;
274 274
 		if ($filter_name == '') $filter_name = $this->filter_name;
275
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
275
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
276 276
 			$Spotter = new Spotter($this->db);
277
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
277
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
278 278
 			$alliance_airlines = array();
279 279
 			foreach ($airlines as $airline) {
280
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
280
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
281 281
 			}
282 282
 			if ($year == '' && $month == '') {
283
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
284
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
283
+				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
284
+				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
285 285
 				try {
286 286
 					$sth = $this->db->prepare($query);
287 287
 					$sth->execute(array(':filter_name' => $filter_name));
288
-				} catch(PDOException $e) {
288
+				} catch (PDOException $e) {
289 289
 					echo "error : ".$e->getMessage();
290 290
 				}
291 291
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -296,21 +296,21 @@  discard block
 block discarded – undo
296 296
 				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";
297 297
 				try {
298 298
 					$sth = $this->db->prepare($query);
299
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
300
-				} catch(PDOException $e) {
299
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
300
+				} catch (PDOException $e) {
301 301
 					echo "error : ".$e->getMessage();
302 302
 				}
303 303
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
304 304
 			} else $all = array();
305 305
 		}
306 306
 		if (empty($all)) {
307
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
308
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
307
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
308
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
309 309
 			} else {
310
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
310
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
311 311
 			}
312 312
 			if ($filter_name != '') {
313
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
313
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
314 314
 			}
315 315
 			$Spotter = new Spotter($this->db);
316 316
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -319,23 +319,23 @@  discard block
 block discarded – undo
319 319
 		return $all;
320 320
 	}
321 321
 
322
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
322
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
323 323
 		global $globalStatsFilters;
324 324
 		if ($filter_name == '') $filter_name = $this->filter_name;
325
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
325
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
326 326
 			$Spotter = new Spotter($this->db);
327
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
327
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
328 328
 			$alliance_airlines = array();
329 329
 			foreach ($airlines as $airline) {
330
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
330
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
331 331
 			}
332 332
 			if ($year == '' && $month == '') {
333
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
334
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
333
+				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
334
+				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
335 335
 				try {
336 336
 					$sth = $this->db->prepare($query);
337 337
 					$sth->execute(array(':filter_name' => $filter_name));
338
-				} catch(PDOException $e) {
338
+				} catch (PDOException $e) {
339 339
 					echo "error : ".$e->getMessage();
340 340
 				}
341 341
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -346,61 +346,61 @@  discard block
 block discarded – undo
346 346
 				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
347 347
 				try {
348 348
 					$sth = $this->db->prepare($query);
349
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
350
-				} catch(PDOException $e) {
349
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
350
+				} catch (PDOException $e) {
351 351
 					echo "error : ".$e->getMessage();
352 352
 				}
353 353
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
354 354
 			} else $all = array();
355 355
 		}
356 356
 		if (empty($all)) {
357
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
358
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
357
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
358
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
359 359
 			} else {
360
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
360
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
361 361
 			}
362 362
 			if ($filter_name != '') {
363
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
363
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
364 364
 			}
365 365
 			$Spotter = new Spotter($this->db);
366 366
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
367
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
367
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
368 368
 		}
369 369
 		return $all;
370 370
 	}
371 371
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
372 372
 		global $globalStatsFilters;
373 373
 		if ($filter_name == '') $filter_name = $this->filter_name;
374
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
374
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
375 375
 			$Spotter = new Spotter($this->db);
376
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
376
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
377 377
 			$alliance_airlines = array();
378 378
 			foreach ($airlines as $airline) {
379
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
379
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
380 380
 			}
381
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
382
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
381
+			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
382
+			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
383 383
 			$query_values = array(':filter_name' => $filter_name);
384 384
 		} else {
385 385
 			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
386 386
 			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
387
-			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
387
+			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
388 388
 		}
389 389
 		try {
390 390
 			$sth = $this->db->prepare($query);
391 391
 			$sth->execute($query_values);
392
-		} catch(PDOException $e) {
392
+		} catch (PDOException $e) {
393 393
 			echo "error : ".$e->getMessage();
394 394
 		}
395 395
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
396 396
 		if (empty($all)) {
397
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
398
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
397
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
398
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
399 399
 			} else {
400
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
400
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
401 401
 			}
402 402
 			if ($filter_name != '') {
403
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
403
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
404 404
 			}
405 405
 			$Spotter = new Spotter($this->db);
406 406
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		return $all;
410 410
 	}
411 411
 
412
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
412
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
413 413
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
414 414
 		if ($filter_name == '') $filter_name = $this->filter_name;
415 415
 		if ($year == '' && $month == '') {
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 			if (isset($forsource)) {
419 419
 				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";
420 420
 				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";
421
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
421
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
422 422
 			} else {
423 423
 				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";
424 424
 				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";
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 			try {
428 428
 				$sth = $this->db->prepare($query);
429 429
 				$sth->execute($query_values);
430
-			} catch(PDOException $e) {
430
+			} catch (PDOException $e) {
431 431
 				echo "error : ".$e->getMessage();
432 432
 			}
433 433
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -435,32 +435,32 @@  discard block
 block discarded – undo
435 435
                 if (empty($all)) {
436 436
 	                $Spotter = new Spotter($this->db);
437 437
             		$filters = array();
438
-			$filters = array('year' => $year,'month' => $month);
438
+			$filters = array('year' => $year, 'month' => $month);
439 439
             		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
440
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
441 441
 			}
442 442
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
443
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
443
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
444 444
                 }
445 445
                 return $all;
446 446
 	}
447
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
447
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
448 448
 		global $globalStatsFilters;
449 449
 		if ($filter_name == '') $filter_name = $this->filter_name;
450
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
450
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
451 451
 			$Spotter = new Spotter($this->db);
452
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
452
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
453 453
 			$alliance_airlines = array();
454 454
 			foreach ($airlines as $airline) {
455
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
455
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
456 456
 			}
457 457
 			if ($year == '' && $month == '') {
458
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
459
-				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
458
+				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
459
+				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
460 460
 				try {
461 461
 					$sth = $this->db->prepare($query);
462 462
 					$sth->execute(array(':filter_name' => $filter_name));
463
-				} catch(PDOException $e) {
463
+				} catch (PDOException $e) {
464 464
 					echo "error : ".$e->getMessage();
465 465
 				}
466 466
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -471,45 +471,45 @@  discard block
 block discarded – undo
471 471
 				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC";
472 472
 				try {
473 473
 					$sth = $this->db->prepare($query);
474
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
475
-				} catch(PDOException $e) {
474
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
475
+				} catch (PDOException $e) {
476 476
 					echo "error : ".$e->getMessage();
477 477
 				}
478 478
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
479 479
 			} else $all = array();
480 480
 		}
481 481
 		if (empty($all)) {
482
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
483
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
482
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
483
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
484 484
 			} else {
485
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
485
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
486 486
 			}
487 487
 			if ($filter_name != '') {
488
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
488
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
489 489
 			}
490 490
 			$Spotter = new Spotter($this->db);
491 491
 			//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
492
-			$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
492
+			$all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
493 493
 		}
494 494
 		return $all;
495 495
 	}
496
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
496
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
497 497
 		global $globalStatsFilters;
498 498
 		if ($filter_name == '') $filter_name = $this->filter_name;
499
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
499
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
500 500
 			$Spotter = new Spotter($this->db);
501
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
501
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
502 502
 			$alliance_airlines = array();
503 503
 			foreach ($airlines as $airline) {
504
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
504
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
505 505
 			}
506 506
 			if ($year == '' && $month == '') {
507
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
508
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
507
+				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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
508
+				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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
509 509
 				 try {
510 510
 					$sth = $this->db->prepare($query);
511 511
 					$sth->execute(array(':filter_name' => $filter_name));
512
-				} catch(PDOException $e) {
512
+				} catch (PDOException $e) {
513 513
 					echo "error : ".$e->getMessage();
514 514
 				}
515 515
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -520,46 +520,46 @@  discard block
 block discarded – undo
520 520
 				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";
521 521
 				 try {
522 522
 					$sth = $this->db->prepare($query);
523
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
524
-				} catch(PDOException $e) {
523
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
524
+				} catch (PDOException $e) {
525 525
 					echo "error : ".$e->getMessage();
526 526
 				}
527 527
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
528 528
 			} else $all = array();
529 529
 		}
530 530
 		if (empty($all)) {
531
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
532
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
531
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
532
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
533 533
 			} else {
534
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
534
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
535 535
 			}
536 536
 			if ($filter_name != '') {
537
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
537
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
538 538
 			}
539 539
 			$Spotter = new Spotter($this->db);
540 540
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
541
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
541
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
542 542
 		}
543 543
 		return $all;
544 544
 	}
545
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
545
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
546 546
 		$Connection = new Connection($this->db);
547 547
 		if ($filter_name == '') $filter_name = $this->filter_name;
548 548
 		if ($Connection->tableExists('countries')) {
549
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
549
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
550 550
 				$Spotter = new Spotter($this->db);
551
-				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
551
+				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
552 552
 				if ($year == '' && $month == '') {
553 553
 					$alliance_airlines = array();
554 554
 					foreach ($airlines as $airline) {
555
-						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
555
+						$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
556 556
 					}
557
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
558
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
557
+					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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
558
+					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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
559 559
 					 try {
560 560
 						$sth = $this->db->prepare($query);
561 561
 						$sth->execute(array(':filter_name' => $filter_name));
562
-					} catch(PDOException $e) {
562
+					} catch (PDOException $e) {
563 563
 						echo "error : ".$e->getMessage();
564 564
 					}
565 565
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
 					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";
572 572
 					 try {
573 573
 						$sth = $this->db->prepare($query);
574
-						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
575
-					} catch(PDOException $e) {
574
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
575
+					} catch (PDOException $e) {
576 576
 						echo "error : ".$e->getMessage();
577 577
 					}
578 578
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 			return $Spotter->countAllFlightOverCountries($limit);
584 584
 		} else return array();
585 585
 	}
586
-	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
586
+	public function countAllMarineOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
587 587
 		$Connection = new Connection($this->db);
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		if ($Connection->tableExists('countries')) {
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 				 try {
595 595
 					$sth = $this->db->prepare($query);
596 596
 					$sth->execute(array(':filter_name' => $filter_name));
597
-				} catch(PDOException $e) {
597
+				} catch (PDOException $e) {
598 598
 					echo "error : ".$e->getMessage();
599 599
 				}
600 600
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -602,15 +602,15 @@  discard block
 block discarded – undo
602 602
 			if (empty($all)) {
603 603
 				$filters = array();
604 604
 				if ($filter_name != '') {
605
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
605
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
606 606
 				}
607 607
 				$Marine = new Marine($this->db);
608
-				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
608
+				$all = $Marine->countAllMarineOverCountries($limit, 0, '', $filters);
609 609
 			}
610 610
 			return $all;
611 611
 		} else return array();
612 612
 	}
613
-	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
613
+	public function countAllTrackerOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
614 614
 		$Connection = new Connection($this->db);
615 615
 		if ($filter_name == '') $filter_name = $this->filter_name;
616 616
 		if ($Connection->tableExists('countries')) {
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 				 try {
622 622
 					$sth = $this->db->prepare($query);
623 623
 					$sth->execute(array(':filter_name' => $filter_name));
624
-				} catch(PDOException $e) {
624
+				} catch (PDOException $e) {
625 625
 					echo "error : ".$e->getMessage();
626 626
 				}
627 627
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -630,15 +630,15 @@  discard block
 block discarded – undo
630 630
 			if (empty($all)) {
631 631
 				$filters = array();
632 632
 				if ($filter_name != '') {
633
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
633
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
634 634
 				}
635 635
 				$Tracker = new Tracker($this->db);
636
-				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
636
+				$all = $Tracker->countAllTrackerOverCountries($limit, 0, '', $filters);
637 637
 			}
638 638
 			return $all;
639 639
 		} else return array();
640 640
 	}
641
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
641
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
642 642
 		global $globalStatsFilters;
643 643
 		if ($filter_name == '') $filter_name = $this->filter_name;
644 644
 		if ($year == '' && $month == '') {
@@ -646,41 +646,41 @@  discard block
 block discarded – undo
646 646
 			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";
647 647
 			try {
648 648
 				$sth = $this->db->prepare($query);
649
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
650
-			} catch(PDOException $e) {
649
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
650
+			} catch (PDOException $e) {
651 651
 				echo "error : ".$e->getMessage();
652 652
 			}
653 653
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
654 654
 		} else $all = array();
655 655
 		if (empty($all)) {
656
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
656
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
657 657
 			if ($filter_name != '') {
658
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
658
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
659 659
 			}
660 660
 			$Spotter = new Spotter($this->db);
661 661
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
662
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
662
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
663 663
 		}
664 664
 		return $all;
665 665
 	}
666 666
 
667
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
667
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
668 668
 		global $globalStatsFilters;
669 669
 		if ($filter_name == '') $filter_name = $this->filter_name;
670
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
670
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
671 671
 			$Spotter = new Spotter($this->db);
672
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
672
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
673 673
 			if ($year == '' && $month == '') {
674 674
 				$alliance_airlines = array();
675 675
 				foreach ($airlines as $airline) {
676
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
676
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
677 677
 				}
678
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
679
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
678
+				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
679
+				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
680 680
 				try {
681 681
 					$sth = $this->db->prepare($query);
682 682
 					$sth->execute(array(':filter_name' => $filter_name));
683
-				} catch(PDOException $e) {
683
+				} catch (PDOException $e) {
684 684
 					echo "error : ".$e->getMessage();
685 685
 				}
686 686
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -691,45 +691,45 @@  discard block
 block discarded – undo
691 691
 				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";
692 692
 				try {
693 693
 					$sth = $this->db->prepare($query);
694
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
695
-				} catch(PDOException $e) {
694
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
695
+				} catch (PDOException $e) {
696 696
 					echo "error : ".$e->getMessage();
697 697
 				}
698 698
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
699 699
 			} else $all = array();
700 700
 		}
701 701
 		if (empty($all)) {
702
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
703
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
702
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
703
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
704 704
 			} else {
705
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
705
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
706 706
 			}
707 707
 			if ($filter_name != '') {
708
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
708
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
709 709
 			}
710 710
 			$Spotter = new Spotter($this->db);
711 711
 			//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
712
-			$all = $Spotter->countAllOwners($limit,0,'',$filters);
712
+			$all = $Spotter->countAllOwners($limit, 0, '', $filters);
713 713
 		}
714 714
 		return $all;
715 715
 	}
716
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
716
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
717 717
 		global $globalStatsFilters;
718 718
 		if ($filter_name == '') $filter_name = $this->filter_name;
719
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
719
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
720 720
 			$Spotter = new Spotter($this->db);
721
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
721
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
722 722
 			if ($year == '' && $month == '') {
723 723
 				$alliance_airlines = array();
724 724
 				foreach ($airlines as $airline) {
725
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
725
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
726 726
 				}
727
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
728
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
727
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
728
+				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
729 729
 				try {
730 730
 					$sth = $this->db->prepare($query);
731 731
 					$sth->execute(array(':filter_name' => $filter_name));
732
-				} catch(PDOException $e) {
732
+				} catch (PDOException $e) {
733 733
 					echo "error : ".$e->getMessage();
734 734
 				}
735 735
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -740,27 +740,27 @@  discard block
 block discarded – undo
740 740
 				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
741 741
 				try {
742 742
 					$sth = $this->db->prepare($query);
743
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
744
-				} catch(PDOException $e) {
743
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
744
+				} catch (PDOException $e) {
745 745
 					echo "error : ".$e->getMessage();
746 746
 				}
747 747
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
748 748
 			} else $all = array();
749 749
 		}
750 750
 		if (empty($all)) {
751
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
752
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
751
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
752
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
753 753
 			} else {
754
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
754
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
755 755
 			}
756 756
 			if ($filter_name != '') {
757
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
757
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
758 758
 			}
759 759
 			$Spotter = new Spotter($this->db);
760 760
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
761 761
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
762
-			$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
763
-			$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
762
+			$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
763
+			$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
764 764
 			$all = array();
765 765
 			foreach ($pall as $value) {
766 766
 				$icao = $value['airport_departure_icao'];
@@ -776,27 +776,27 @@  discard block
 block discarded – undo
776 776
 			foreach ($all as $key => $row) {
777 777
 				$count[$key] = $row['airport_departure_icao_count'];
778 778
 			}
779
-			array_multisort($count,SORT_DESC,$all);
779
+			array_multisort($count, SORT_DESC, $all);
780 780
 		}
781 781
 		return $all;
782 782
 	}
783
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
783
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
784 784
 		global $globalStatsFilters;
785 785
 		if ($filter_name == '') $filter_name = $this->filter_name;
786
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
786
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
787 787
 			$Spotter = new Spotter($this->db);
788
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
788
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
789 789
 			if ($year == '' && $month == '') {
790 790
 				$alliance_airlines = array();
791 791
 				foreach ($airlines as $airline) {
792
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
792
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
793 793
 				}
794
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
795
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
794
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
795
+				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
796 796
 				try {
797 797
 					$sth = $this->db->prepare($query);
798 798
 					$sth->execute(array(':filter_name' => $filter_name));
799
-				} catch(PDOException $e) {
799
+				} catch (PDOException $e) {
800 800
 					echo "error : ".$e->getMessage();
801 801
 				}
802 802
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -807,27 +807,27 @@  discard block
 block discarded – undo
807 807
 				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
808 808
 				try {
809 809
 					$sth = $this->db->prepare($query);
810
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
811
-				} catch(PDOException $e) {
810
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
811
+				} catch (PDOException $e) {
812 812
 					echo "error : ".$e->getMessage();
813 813
 				}
814 814
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
815 815
 			} else $all = array();
816 816
 		}
817 817
 		if (empty($all)) {
818
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
819
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
818
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
819
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
820 820
 			} else {
821
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
821
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
822 822
 			}
823 823
 			if ($filter_name != '') {
824
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
824
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
825 825
 			}
826 826
 			$Spotter = new Spotter($this->db);
827 827
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
828 828
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
829
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
830
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
829
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
830
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
831 831
 			$all = array();
832 832
 			foreach ($pall as $value) {
833 833
 				$icao = $value['airport_arrival_icao'];
@@ -843,26 +843,26 @@  discard block
 block discarded – undo
843 843
 			foreach ($all as $key => $row) {
844 844
 				$count[$key] = $row['airport_arrival_icao_count'];
845 845
 			}
846
-			array_multisort($count,SORT_DESC,$all);
846
+			array_multisort($count, SORT_DESC, $all);
847 847
 		}
848 848
 		return $all;
849 849
 	}
850
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
850
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
851 851
 		global $globalDBdriver, $globalStatsFilters;
852 852
 		if ($filter_name == '') $filter_name = $this->filter_name;
853
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
853
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
854 854
 			$Spotter = new Spotter($this->db);
855
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
855
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
856 856
 			$alliance_airlines = array();
857 857
 			foreach ($airlines as $airline) {
858
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
858
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
859 859
 			}
860 860
 			if ($globalDBdriver == 'mysql') {
861
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
862
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
861
+				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
862
+				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
863 863
 			} else {
864
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
865
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
864
+				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
865
+				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
866 866
 			}
867 867
 			$query_data = array(':filter_name' => $filter_name);
868 868
 		} else {
@@ -873,23 +873,23 @@  discard block
 block discarded – undo
873 873
 				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";
874 874
 				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";
875 875
 			}
876
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
876
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
877 877
 		}
878 878
 		try {
879 879
 			$sth = $this->db->prepare($query);
880 880
 			$sth->execute($query_data);
881
-		} catch(PDOException $e) {
881
+		} catch (PDOException $e) {
882 882
 			echo "error : ".$e->getMessage();
883 883
 		}
884 884
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
885 885
 		if (empty($all)) {
886
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
887
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
886
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
887
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
888 888
 			} else {
889 889
 				$filters = array('airlines' => array($stats_airline));
890 890
 			}
891 891
 			if ($filter_name != '') {
892
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
892
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
893 893
 			}
894 894
 			$Spotter = new Spotter($this->db);
895 895
 			$all = $Spotter->countAllMonthsLastYear($filters);
@@ -897,57 +897,57 @@  discard block
 block discarded – undo
897 897
 		return $all;
898 898
 	}
899 899
 	
900
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
900
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
901 901
 		global $globalStatsFilters;
902 902
 		if ($filter_name == '') $filter_name = $this->filter_name;
903
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
903
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
904 904
 			$Spotter = new Spotter($this->db);
905
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
905
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
906 906
 			$alliance_airlines = array();
907 907
 			foreach ($airlines as $airline) {
908
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
908
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
909 909
 			}
910
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
910
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
911 911
 			$query_data = array(':filter_name' => $filter_name);
912 912
 		} else {
913 913
 			$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";
914
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
914
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
915 915
 		}
916 916
 		try {
917 917
 			$sth = $this->db->prepare($query);
918 918
 			$sth->execute($query_data);
919
-		} catch(PDOException $e) {
919
+		} catch (PDOException $e) {
920 920
 			echo "error : ".$e->getMessage();
921 921
 		}
922 922
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
923 923
 		if (empty($all)) {
924
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
925
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
924
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
925
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
926 926
 			} else {
927 927
 				$filters = array('airlines' => array($stats_airline));
928 928
 			}
929 929
 			if ($filter_name != '') {
930
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
930
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
931 931
 			}
932 932
 			$Spotter = new Spotter($this->db);
933 933
 			$all = $Spotter->countAllDatesLastMonth($filters);
934 934
 		}
935 935
 		return $all;
936 936
 	}
937
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
937
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
938 938
 		global $globalDBdriver, $globalStatsFilters;
939 939
 		if ($filter_name == '') $filter_name = $this->filter_name;
940
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
940
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
941 941
 			$Spotter = new Spotter($this->db);
942
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
942
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
943 943
 			$alliance_airlines = array();
944 944
 			foreach ($airlines as $airline) {
945
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
945
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
946 946
 			}
947 947
 			if ($globalDBdriver == 'mysql') {
948
-				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
948
+				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
949 949
 			} else {
950
-				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
950
+				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
951 951
 			}
952 952
 			$query_data = array(':filter_name' => $filter_name);
953 953
 		} else {
@@ -956,60 +956,60 @@  discard block
 block discarded – undo
956 956
 			} else {
957 957
 				$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
958 958
 			}
959
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
959
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
960 960
 		}
961 961
 		try {
962 962
 			$sth = $this->db->prepare($query);
963 963
 			$sth->execute($query_data);
964
-		} catch(PDOException $e) {
964
+		} catch (PDOException $e) {
965 965
 			echo "error : ".$e->getMessage();
966 966
 		}
967 967
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
968 968
 		if (empty($all)) {
969
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
970
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
969
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
970
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
971 971
 			} else {
972 972
 				$filters = array('airlines' => array($stats_airline));
973 973
 			}
974 974
 			if ($filter_name != '') {
975
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
975
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
976 976
 			}
977 977
 			$Spotter = new Spotter($this->db);
978 978
 			$all = $Spotter->countAllDatesLast7Days($filters);
979 979
 		}
980 980
 		return $all;
981 981
 	}
982
-	public function countAllDates($stats_airline = '',$filter_name = '') {
982
+	public function countAllDates($stats_airline = '', $filter_name = '') {
983 983
 		global $globalStatsFilters;
984 984
 		if ($filter_name == '') $filter_name = $this->filter_name;
985
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
985
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
986 986
 			$Spotter = new Spotter($this->db);
987
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
987
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
988 988
 			$alliance_airlines = array();
989 989
 			foreach ($airlines as $airline) {
990
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
990
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
991 991
 			}
992
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
992
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
993 993
 			$query_data = array(':filter_name' => $filter_name);
994 994
 		} else {
995 995
 			$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 ORDER BY date_count DESC";
996
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
996
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
997 997
 		}
998 998
 		try {
999 999
 			$sth = $this->db->prepare($query);
1000 1000
 			$sth->execute($query_data);
1001
-		} catch(PDOException $e) {
1001
+		} catch (PDOException $e) {
1002 1002
 			echo "error : ".$e->getMessage();
1003 1003
 		}
1004 1004
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1005 1005
 		if (empty($all)) {
1006
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1007
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1006
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1007
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1008 1008
 			} else {
1009 1009
 				$filters = array('airlines' => array($stats_airline));
1010 1010
 			}
1011 1011
 			if ($filter_name != '') {
1012
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1012
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1013 1013
 			}
1014 1014
 			$Spotter = new Spotter($this->db);
1015 1015
 			$all = $Spotter->countAllDates($filters);
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 		try {
1025 1025
 			$sth = $this->db->prepare($query);
1026 1026
 			$sth->execute($query_data);
1027
-		} catch(PDOException $e) {
1027
+		} catch (PDOException $e) {
1028 1028
 			echo "error : ".$e->getMessage();
1029 1029
 		}
1030 1030
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 		try {
1047 1047
 			$sth = $this->db->prepare($query);
1048 1048
 			$sth->execute($query_data);
1049
-		} catch(PDOException $e) {
1049
+		} catch (PDOException $e) {
1050 1050
 			echo "error : ".$e->getMessage();
1051 1051
 		}
1052 1052
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1068,34 +1068,34 @@  discard block
 block discarded – undo
1068 1068
 		try {
1069 1069
 			$sth = $this->db->prepare($query);
1070 1070
 			$sth->execute($query_data);
1071
-		} catch(PDOException $e) {
1071
+		} catch (PDOException $e) {
1072 1072
 			echo "error : ".$e->getMessage();
1073 1073
 		}
1074 1074
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1075 1075
 		if (empty($all)) {
1076 1076
 			$filters = array();
1077 1077
 			if ($filter_name != '') {
1078
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1078
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1079 1079
 			}
1080 1080
 			$Spotter = new Spotter($this->db);
1081 1081
 			$all = $Spotter->countAllDatesByAirlines($filters);
1082 1082
 		}
1083 1083
 		return $all;
1084 1084
 	}
1085
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
1085
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
1086 1086
 		global $globalStatsFilters, $globalDBdriver;
1087 1087
 		if ($filter_name == '') $filter_name = $this->filter_name;
1088
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1088
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1089 1089
 			$Spotter = new Spotter($this->db);
1090
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1090
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1091 1091
 			$alliance_airlines = array();
1092 1092
 			foreach ($airlines as $airline) {
1093
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1093
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1094 1094
 			}
1095 1095
 			if ($globalDBdriver == 'mysql') {
1096
-				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1096
+				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1097 1097
 			} else {
1098
-				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1098
+				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1099 1099
 			}
1100 1100
 			$query_data = array(':filter_name' => $filter_name);
1101 1101
 		} else {
@@ -1109,18 +1109,18 @@  discard block
 block discarded – undo
1109 1109
 		try {
1110 1110
 			$sth = $this->db->prepare($query);
1111 1111
 			$sth->execute($query_data);
1112
-		} catch(PDOException $e) {
1112
+		} catch (PDOException $e) {
1113 1113
 			echo "error : ".$e->getMessage();
1114 1114
 		}
1115 1115
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1116 1116
 		if (empty($all)) {
1117
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1118
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1117
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1118
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1119 1119
 			} else {
1120 1120
 				$filters = array('airlines' => array($stats_airline));
1121 1121
 			}
1122 1122
 			if ($filter_name != '') {
1123
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1123
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1124 1124
 			}
1125 1125
 			$Spotter = new Spotter($this->db);
1126 1126
 			$all = $Spotter->countAllMonths($filters);
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 		try {
1138 1138
 			$sth = $this->db->prepare($query);
1139 1139
 			$sth->execute();
1140
-		} catch(PDOException $e) {
1140
+		} catch (PDOException $e) {
1141 1141
 			echo "error : ".$e->getMessage();
1142 1142
 		}
1143 1143
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 		try {
1158 1158
 			$sth = $this->db->prepare($query);
1159 1159
 			$sth->execute();
1160
-		} catch(PDOException $e) {
1160
+		} catch (PDOException $e) {
1161 1161
 			echo "error : ".$e->getMessage();
1162 1162
 		}
1163 1163
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1174,32 +1174,32 @@  discard block
 block discarded – undo
1174 1174
 		try {
1175 1175
 			$sth = $this->db->prepare($query);
1176 1176
 			$sth->execute(array(':filter_name' => $filter_name));
1177
-		} catch(PDOException $e) {
1177
+		} catch (PDOException $e) {
1178 1178
 			echo "error : ".$e->getMessage();
1179 1179
 		}
1180 1180
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1181 1181
 		if (empty($all)) {
1182 1182
 			$filters = array();
1183 1183
 			if ($filter_name != '') {
1184
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1184
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1185 1185
 			}
1186 1186
 			$Spotter = new Spotter($this->db);
1187 1187
 			$all = $Spotter->countAllMilitaryMonths($filters);
1188 1188
 		}
1189 1189
 		return $all;
1190 1190
 	}
1191
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1191
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
1192 1192
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1193 1193
 		if ($filter_name == '') $filter_name = $this->filter_name;
1194
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1194
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1195 1195
 			$Spotter = new Spotter($this->db);
1196
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1196
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1197 1197
 			$alliance_airlines = array();
1198 1198
 			foreach ($airlines as $airline) {
1199
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1199
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1200 1200
 			}
1201
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1202
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1201
+			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1202
+			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1203 1203
 			$query_data = array(':filter_name' => $filter_name);
1204 1204
 		} else {
1205 1205
 			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";
@@ -1217,37 +1217,37 @@  discard block
 block discarded – undo
1217 1217
 		try {
1218 1218
 			$sth = $this->db->prepare($query);
1219 1219
 			$sth->execute($query_data);
1220
-		} catch(PDOException $e) {
1220
+		} catch (PDOException $e) {
1221 1221
 			echo "error : ".$e->getMessage();
1222 1222
 		}
1223 1223
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1224 1224
 		if (empty($all)) {
1225
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1226
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1225
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1226
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1227 1227
 			} else {
1228 1228
 				$filters = array('airlines' => array($stats_airline));
1229 1229
 			}
1230 1230
 			if ($filter_name != '') {
1231
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1231
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1232 1232
 			}
1233 1233
 			$Spotter = new Spotter($this->db);
1234
-			$all = $Spotter->countAllHours($orderby,$filters);
1234
+			$all = $Spotter->countAllHours($orderby, $filters);
1235 1235
 		}
1236 1236
 		return $all;
1237 1237
 	}
1238
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1238
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1239 1239
 		global $globalStatsFilters;
1240 1240
 		if ($filter_name == '') $filter_name = $this->filter_name;
1241 1241
 		if ($year == '') $year = date('Y');
1242
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1242
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
1243 1243
 		if (empty($all)) {
1244
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1245
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1244
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1245
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1246 1246
 			} else {
1247
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1247
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1248 1248
 			}
1249 1249
 			if ($filter_name != '') {
1250
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1250
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1251 1251
 			}
1252 1252
 			$Spotter = new Spotter($this->db);
1253 1253
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1255,15 +1255,15 @@  discard block
 block discarded – undo
1255 1255
 		}
1256 1256
 		return $all;
1257 1257
 	}
1258
-	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1258
+	public function countOverallMarine($filter_name = '', $year = '', $month = '') {
1259 1259
 		global $globalStatsFilters;
1260 1260
 		if ($filter_name == '') $filter_name = $this->filter_name;
1261 1261
 		if ($year == '') $year = date('Y');
1262
-		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1262
+		$all = $this->getSumStats('marine_bymonth', $year, '', $filter_name, $month);
1263 1263
 		if (empty($all)) {
1264
-			$filters = array('year' => $year,'month' => $month);
1264
+			$filters = array('year' => $year, 'month' => $month);
1265 1265
 			if ($filter_name != '') {
1266
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1266
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1267 1267
 			}
1268 1268
 			$Marine = new Marine($this->db);
1269 1269
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1271,15 +1271,15 @@  discard block
 block discarded – undo
1271 1271
 		}
1272 1272
 		return $all;
1273 1273
 	}
1274
-	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1274
+	public function countOverallTracker($filter_name = '', $year = '', $month = '') {
1275 1275
 		global $globalStatsFilters;
1276 1276
 		if ($filter_name == '') $filter_name = $this->filter_name;
1277 1277
 		if ($year == '') $year = date('Y');
1278
-		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1278
+		$all = $this->getSumStats('tracker_bymonth', $year, '', $filter_name, $month);
1279 1279
 		if (empty($all)) {
1280
-			$filters = array('year' => $year,'month' => $month);
1280
+			$filters = array('year' => $year, 'month' => $month);
1281 1281
 			if ($filter_name != '') {
1282
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1282
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1283 1283
 			}
1284 1284
 			$Tracker = new Tracker($this->db);
1285 1285
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1287,16 +1287,16 @@  discard block
 block discarded – undo
1287 1287
 		}
1288 1288
 		return $all;
1289 1289
 	}
1290
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1290
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
1291 1291
 		global $globalStatsFilters;
1292 1292
 		if ($filter_name == '') $filter_name = $this->filter_name;
1293 1293
 		if ($year == '') $year = date('Y');
1294
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1294
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
1295 1295
 		if (empty($all)) {
1296 1296
 			$filters = array();
1297
-			$filters = array('year' => $year,'month' => $month);
1297
+			$filters = array('year' => $year, 'month' => $month);
1298 1298
 			if ($filter_name != '') {
1299
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1299
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1300 1300
 			}
1301 1301
 			$Spotter = new Spotter($this->db);
1302 1302
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -1304,19 +1304,19 @@  discard block
 block discarded – undo
1304 1304
 		}
1305 1305
 		return $all;
1306 1306
 	}
1307
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1307
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1308 1308
 		global $globalStatsFilters;
1309 1309
 		if ($filter_name == '') $filter_name = $this->filter_name;
1310 1310
 		if ($year == '') $year = date('Y');
1311
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1311
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
1312 1312
 		if (empty($all)) {
1313
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1314
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1313
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1314
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1315 1315
 			} else {
1316
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1316
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1317 1317
 			}
1318 1318
 			if ($filter_name != '') {
1319
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1319
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1320 1320
 			}
1321 1321
 			$Spotter = new Spotter($this->db);
1322 1322
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -1324,48 +1324,48 @@  discard block
 block discarded – undo
1324 1324
 		}
1325 1325
 		return $all;
1326 1326
 	}
1327
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1327
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1328 1328
 		global $globalStatsFilters;
1329 1329
 		if ($filter_name == '') $filter_name = $this->filter_name;
1330
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1330
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1331 1331
 			$Spotter = new Spotter($this->db);
1332
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1332
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1333 1333
 			if ($year == '' && $month == '') {
1334 1334
 				$alliance_airlines = array();
1335 1335
 				foreach ($airlines as $airline) {
1336
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1336
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1337 1337
 				}
1338
-				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1338
+				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1339 1339
 				try {
1340 1340
 					$sth = $this->db->prepare($query);
1341 1341
 					$sth->execute(array(':filter_name' => $filter_name));
1342
-				} catch(PDOException $e) {
1342
+				} catch (PDOException $e) {
1343 1343
 					echo "error : ".$e->getMessage();
1344 1344
 				}
1345 1345
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1346 1346
 				$all = $result[0]['nb'];
1347
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1347
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1348 1348
 		} else {
1349 1349
 			if ($year == '' && $month == '') {
1350 1350
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1351 1351
 				try {
1352 1352
 					$sth = $this->db->prepare($query);
1353
-					$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
1354
-				} catch(PDOException $e) {
1353
+					$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
1354
+				} catch (PDOException $e) {
1355 1355
 					echo "error : ".$e->getMessage();
1356 1356
 				}
1357 1357
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1358 1358
 				$all = $result[0]['nb'];
1359
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1359
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1360 1360
 		}
1361 1361
 		if (empty($all)) {
1362
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1363
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1362
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1363
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1364 1364
 			} else {
1365
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1365
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1366 1366
 			}
1367 1367
 			if ($filter_name != '') {
1368
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1368
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1369 1369
 			}
1370 1370
 			$Spotter = new Spotter($this->db);
1371 1371
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 		}
1374 1374
 		return $all;
1375 1375
 	}
1376
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1376
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
1377 1377
 		global $globalStatsFilters;
1378 1378
 		if ($filter_name == '') $filter_name = $this->filter_name;
1379 1379
 		if ($year == '' && $month == '') {
@@ -1381,17 +1381,17 @@  discard block
 block discarded – undo
1381 1381
 			try {
1382 1382
 				$sth = $this->db->prepare($query);
1383 1383
 				$sth->execute(array(':filter_name' => $filter_name));
1384
-			} catch(PDOException $e) {
1384
+			} catch (PDOException $e) {
1385 1385
 				echo "error : ".$e->getMessage();
1386 1386
 			}
1387 1387
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1388 1388
 			$all = $result[0]['nb_airline'];
1389
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1389
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
1390 1390
 		if (empty($all)) {
1391 1391
 			$filters = array();
1392
-			$filters = array('year' => $year,'month' => $month);
1392
+			$filters = array('year' => $year, 'month' => $month);
1393 1393
 			if ($filter_name != '') {
1394
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1394
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1395 1395
 			}
1396 1396
 			$Spotter = new Spotter($this->db);
1397 1397
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
 		}
1400 1400
 		return $all;
1401 1401
 	}
1402
-	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1402
+	public function countOverallMarineTypes($filter_name = '', $year = '', $month = '') {
1403 1403
 		global $globalStatsFilters;
1404 1404
 		if ($filter_name == '') $filter_name = $this->filter_name;
1405 1405
 		$all = array();
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
 			try {
1409 1409
 				$sth = $this->db->prepare($query);
1410 1410
 				$sth->execute(array(':filter_name' => $filter_name));
1411
-			} catch(PDOException $e) {
1411
+			} catch (PDOException $e) {
1412 1412
 				echo "error : ".$e->getMessage();
1413 1413
 			}
1414 1414
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1416,9 +1416,9 @@  discard block
 block discarded – undo
1416 1416
 		}
1417 1417
 		if (empty($all)) {
1418 1418
 			$filters = array();
1419
-			$filters = array('year' => $year,'month' => $month);
1419
+			$filters = array('year' => $year, 'month' => $month);
1420 1420
 			if ($filter_name != '') {
1421
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1421
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1422 1422
 			}
1423 1423
 			$Marine = new Marine($this->db);
1424 1424
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1426,29 +1426,29 @@  discard block
 block discarded – undo
1426 1426
 		}
1427 1427
 		return $all;
1428 1428
 	}
1429
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1429
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1430 1430
 		global $globalStatsFilters;
1431 1431
 		if ($filter_name == '') $filter_name = $this->filter_name;
1432
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1432
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1433 1433
 			$Spotter = new Spotter($this->db);
1434
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1434
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1435 1435
 			if ($year == '' && $month == '') {
1436 1436
 				$alliance_airlines = array();
1437 1437
 				foreach ($airlines as $airline) {
1438
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1438
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1439 1439
 				}
1440
-				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1440
+				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1441 1441
 				$query_values = array(':filter_name' => $filter_name);
1442 1442
 				try {
1443 1443
 					$sth = $this->db->prepare($query);
1444 1444
 					$sth->execute($query_values);
1445
-				} catch(PDOException $e) {
1445
+				} catch (PDOException $e) {
1446 1446
 					echo "error : ".$e->getMessage();
1447 1447
 				}
1448 1448
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1449 1449
 				$all = $result[0]['nb'];
1450 1450
 			} else {
1451
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1451
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1452 1452
 			}
1453 1453
 		} else {
1454 1454
 			if ($year == '' && $month == '') {
@@ -1457,23 +1457,23 @@  discard block
 block discarded – undo
1457 1457
 				try {
1458 1458
 					$sth = $this->db->prepare($query);
1459 1459
 					$sth->execute($query_values);
1460
-				} catch(PDOException $e) {
1460
+				} catch (PDOException $e) {
1461 1461
 					echo "error : ".$e->getMessage();
1462 1462
 				}
1463 1463
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1464 1464
 				$all = $result[0]['nb'];
1465 1465
 			} else {
1466
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1466
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1467 1467
 			}
1468 1468
 		}
1469 1469
 		if (empty($all)) {
1470
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1471
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1470
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1471
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1472 1472
 			} else {
1473
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1473
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1474 1474
 			}
1475 1475
 			if ($filter_name != '') {
1476
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1476
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1477 1477
 			}
1478 1478
 			$Spotter = new Spotter($this->db);
1479 1479
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
 		}
1482 1482
 		return $all;
1483 1483
 	}
1484
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1484
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1485 1485
 		global $globalStatsFilters;
1486 1486
 		if ($filter_name == '') $filter_name = $this->filter_name;
1487 1487
 		//if ($year == '') $year = date('Y');
@@ -1491,18 +1491,18 @@  discard block
 block discarded – undo
1491 1491
 			try {
1492 1492
 				$sth = $this->db->prepare($query);
1493 1493
 				$sth->execute($query_values);
1494
-			} catch(PDOException $e) {
1494
+			} catch (PDOException $e) {
1495 1495
 				echo "error : ".$e->getMessage();
1496 1496
 			}
1497 1497
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1498 1498
 			$all = $result[0]['nb'];
1499 1499
 		} else {
1500
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
1500
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
1501 1501
 		}
1502 1502
 		if (empty($all)) {
1503
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1503
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1504 1504
 			if ($filter_name != '') {
1505
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1505
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1506 1506
 			}
1507 1507
 			$Spotter = new Spotter($this->db);
1508 1508
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -1511,104 +1511,104 @@  discard block
 block discarded – undo
1511 1511
 		return $all;
1512 1512
 	}
1513 1513
 
1514
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1514
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
1515 1515
 		if ($filter_name == '') $filter_name = $this->filter_name;
1516
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1516
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1517 1517
 			$Spotter = new Spotter($this->db);
1518
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1518
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1519 1519
 			$alliance_airlines = array();
1520 1520
 			foreach ($airlines as $airline) {
1521
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1521
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1522 1522
 			}
1523
-			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1524
-			$query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name);
1523
+			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1524
+			$query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name);
1525 1525
 		} else {
1526 1526
 			$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";
1527
-			$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1527
+			$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1528 1528
 		}
1529 1529
 		try {
1530 1530
 			$sth = $this->db->prepare($query);
1531 1531
 			$sth->execute($query_values);
1532
-		} catch(PDOException $e) {
1532
+		} catch (PDOException $e) {
1533 1533
 			echo "error : ".$e->getMessage();
1534 1534
 		}
1535 1535
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1536 1536
 		return $all;
1537 1537
 	}
1538
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
1538
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
1539 1539
 		if ($filter_name == '') $filter_name = $this->filter_name;
1540 1540
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1541
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1541
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1542 1542
 		try {
1543 1543
 			$sth = $this->db->prepare($query);
1544 1544
 			$sth->execute($query_values);
1545
-		} catch(PDOException $e) {
1545
+		} catch (PDOException $e) {
1546 1546
 			echo "error : ".$e->getMessage();
1547 1547
 		}
1548 1548
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1549 1549
 		return $all;
1550 1550
 	}
1551
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1551
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
1552 1552
 		if ($filter_name == '') $filter_name = $this->filter_name;
1553 1553
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1554
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1554
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1555 1555
 		try {
1556 1556
 			$sth = $this->db->prepare($query);
1557 1557
 			$sth->execute($query_values);
1558
-		} catch(PDOException $e) {
1558
+		} catch (PDOException $e) {
1559 1559
 			echo "error : ".$e->getMessage();
1560 1560
 		}
1561 1561
 	}
1562
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1562
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
1563 1563
 		if ($filter_name == '') $filter_name = $this->filter_name;
1564 1564
 		global $globalArchiveMonths, $globalDBdriver;
1565
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1565
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1566 1566
 			$Spotter = new Spotter($this->db);
1567
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1567
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1568 1568
 			$alliance_airlines = array();
1569 1569
 			foreach ($airlines as $airline) {
1570
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1570
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1571 1571
 			}
1572 1572
 			if ($globalDBdriver == 'mysql') {
1573 1573
 				if ($month == '') {
1574
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1574
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1575 1575
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1576 1576
 				} else {
1577
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1578
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1577
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1578
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1579 1579
 				}
1580 1580
 			} else {
1581 1581
 				if ($month == '') {
1582
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1582
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1583 1583
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1584 1584
 				} else {
1585
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1586
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1585
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1586
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1587 1587
 				}
1588 1588
 			}
1589 1589
 		} else {
1590 1590
 			if ($globalDBdriver == 'mysql') {
1591 1591
 				if ($month == '') {
1592 1592
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
1593
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1593
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1594 1594
 				} else {
1595 1595
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
1596
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1596
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1597 1597
 				}
1598 1598
 			} else {
1599 1599
 				if ($month == '') {
1600 1600
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
1601
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1601
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1602 1602
 				} else {
1603 1603
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
1604
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1604
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1605 1605
 				}
1606 1606
 			}
1607 1607
 		}
1608 1608
 		try {
1609 1609
 			$sth = $this->db->prepare($query);
1610 1610
 			$sth->execute($query_values);
1611
-		} catch(PDOException $e) {
1611
+		} catch (PDOException $e) {
1612 1612
 			echo "error : ".$e->getMessage();
1613 1613
 		}
1614 1614
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1617,17 +1617,17 @@  discard block
 block discarded – undo
1617 1617
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1618 1618
 		global $globalArchiveMonths, $globalDBdriver;
1619 1619
 		if ($filter_name == '') $filter_name = $this->filter_name;
1620
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1620
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1621 1621
 			$Spotter = new Spotter($this->db);
1622
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1622
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1623 1623
 			$alliance_airlines = array();
1624 1624
 			foreach ($airlines as $airline) {
1625
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1625
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1626 1626
 			}
1627 1627
 			if ($globalDBdriver == 'mysql') {
1628
-				$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1628
+				$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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1629 1629
 			} else {
1630
-				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1630
+				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1631 1631
 			}
1632 1632
 			$query_values = array(':type' => $type, ':filter_name' => $filter_name);
1633 1633
 		} else {
@@ -1641,7 +1641,7 @@  discard block
 block discarded – undo
1641 1641
 		try {
1642 1642
 			$sth = $this->db->prepare($query);
1643 1643
 			$sth->execute($query_values);
1644
-		} catch(PDOException $e) {
1644
+		} catch (PDOException $e) {
1645 1645
 			echo "error : ".$e->getMessage();
1646 1646
 		}
1647 1647
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1650,17 +1650,17 @@  discard block
 block discarded – undo
1650 1650
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1651 1651
 		global $globalArchiveMonths, $globalDBdriver;
1652 1652
 		if ($filter_name == '') $filter_name = $this->filter_name;
1653
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1653
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1654 1654
 			$Spotter = new Spotter($this->db);
1655
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1655
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1656 1656
 			$alliance_airlines = array();
1657 1657
 			foreach ($airlines as $airline) {
1658
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1658
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1659 1659
 			}
1660 1660
 			if ($globalDBdriver == 'mysql') {
1661
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1661
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1662 1662
 			} else {
1663
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1663
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1664 1664
 			}
1665 1665
 		} else {
1666 1666
 			if ($globalDBdriver == 'mysql') {
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 		try {
1673 1673
 			$sth = $this->db->prepare($query);
1674 1674
 			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1675
-		} catch(PDOException $e) {
1675
+		} catch (PDOException $e) {
1676 1676
 			echo "error : ".$e->getMessage();
1677 1677
 		}
1678 1678
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1689,7 +1689,7 @@  discard block
 block discarded – undo
1689 1689
 		try {
1690 1690
 			$sth = $this->db->prepare($query);
1691 1691
 			$sth->execute(array(':filter_name' => $filter_name));
1692
-		} catch(PDOException $e) {
1692
+		} catch (PDOException $e) {
1693 1693
 			echo "error : ".$e->getMessage();
1694 1694
 		}
1695 1695
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1706,20 +1706,20 @@  discard block
 block discarded – undo
1706 1706
 		try {
1707 1707
 			$sth = $this->db->prepare($query);
1708 1708
 			$sth->execute(array(':filter_name' => $filter_name));
1709
-		} catch(PDOException $e) {
1709
+		} catch (PDOException $e) {
1710 1710
 			echo "error : ".$e->getMessage();
1711 1711
 		}
1712 1712
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1713 1713
 		return $all[0]['total'];
1714 1714
 	}
1715
-	public function getStatsOwner($owner_name,$filter_name = '') {
1715
+	public function getStatsOwner($owner_name, $filter_name = '') {
1716 1716
 		global $globalArchiveMonths, $globalDBdriver;
1717 1717
 		if ($filter_name == '') $filter_name = $this->filter_name;
1718 1718
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1719 1719
 		try {
1720 1720
 			$sth = $this->db->prepare($query);
1721
-			$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1722
-		} catch(PDOException $e) {
1721
+			$sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1722
+		} catch (PDOException $e) {
1723 1723
 			echo "error : ".$e->getMessage();
1724 1724
 		}
1725 1725
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1737,20 +1737,20 @@  discard block
 block discarded – undo
1737 1737
 		try {
1738 1738
 			$sth = $this->db->prepare($query);
1739 1739
 			$sth->execute(array(':filter_name' => $filter_name));
1740
-		} catch(PDOException $e) {
1740
+		} catch (PDOException $e) {
1741 1741
 			echo "error : ".$e->getMessage();
1742 1742
 		}
1743 1743
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1744 1744
 		return $all[0]['total'];
1745 1745
 	}
1746
-	public function getStatsPilot($pilot,$filter_name = '') {
1746
+	public function getStatsPilot($pilot, $filter_name = '') {
1747 1747
 		global $globalArchiveMonths, $globalDBdriver;
1748 1748
 		if ($filter_name == '') $filter_name = $this->filter_name;
1749 1749
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1750 1750
 		try {
1751 1751
 			$sth = $this->db->prepare($query);
1752
-			$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1753
-		} catch(PDOException $e) {
1752
+			$sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1753
+		} catch (PDOException $e) {
1754 1754
 			echo "error : ".$e->getMessage();
1755 1755
 		}
1756 1756
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1758,7 +1758,7 @@  discard block
 block discarded – undo
1758 1758
 		else return 0;
1759 1759
 	}
1760 1760
 
1761
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1761
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1762 1762
 		global $globalDBdriver;
1763 1763
 		if ($filter_name == '') $filter_name = $this->filter_name;
1764 1764
 		if ($globalDBdriver == 'mysql') {
@@ -1766,15 +1766,15 @@  discard block
 block discarded – undo
1766 1766
 		} else {
1767 1767
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1768 1768
 		}
1769
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1769
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1770 1770
 		try {
1771 1771
 			$sth = $this->db->prepare($query);
1772 1772
 			$sth->execute($query_values);
1773
-		} catch(PDOException $e) {
1773
+		} catch (PDOException $e) {
1774 1774
 			return "error : ".$e->getMessage();
1775 1775
 		}
1776 1776
 	}
1777
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1777
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1778 1778
 		global $globalDBdriver;
1779 1779
 		if ($filter_name == '') $filter_name = $this->filter_name;
1780 1780
 		if ($globalDBdriver == 'mysql') {
@@ -1783,11 +1783,11 @@  discard block
 block discarded – undo
1783 1783
 			//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1784 1784
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1785 1785
 		}
1786
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1786
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1787 1787
 		try {
1788 1788
 			$sth = $this->db->prepare($query);
1789 1789
 			$sth->execute($query_values);
1790
-		} catch(PDOException $e) {
1790
+		} catch (PDOException $e) {
1791 1791
 			return "error : ".$e->getMessage();
1792 1792
 		}
1793 1793
 	}
@@ -1811,95 +1811,95 @@  discard block
 block discarded – undo
1811 1811
         }
1812 1812
         */
1813 1813
 
1814
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1814
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1815 1815
 		global $globalDBdriver;
1816 1816
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1817 1817
 		$query_values = array();
1818 1818
 		if ($globalDBdriver == 'mysql') {
1819 1819
 			if ($year != '') {
1820 1820
 				$query .= ' AND YEAR(stats_date) = :year';
1821
-				$query_values = array_merge($query_values,array(':year' => $year));
1821
+				$query_values = array_merge($query_values, array(':year' => $year));
1822 1822
 			}
1823 1823
 			if ($month != '') {
1824 1824
 				$query .= ' AND MONTH(stats_date) = :month';
1825
-				$query_values = array_merge($query_values,array(':month' => $month));
1825
+				$query_values = array_merge($query_values, array(':month' => $month));
1826 1826
 			}
1827 1827
 			if ($day != '') {
1828 1828
 				$query .= ' AND DAY(stats_date) = :day';
1829
-				$query_values = array_merge($query_values,array(':day' => $day));
1829
+				$query_values = array_merge($query_values, array(':day' => $day));
1830 1830
 			}
1831 1831
 		} else {
1832 1832
 			if ($year != '') {
1833 1833
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1834
-				$query_values = array_merge($query_values,array(':year' => $year));
1834
+				$query_values = array_merge($query_values, array(':year' => $year));
1835 1835
 			}
1836 1836
 			if ($month != '') {
1837 1837
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1838
-				$query_values = array_merge($query_values,array(':month' => $month));
1838
+				$query_values = array_merge($query_values, array(':month' => $month));
1839 1839
 			}
1840 1840
 			if ($day != '') {
1841 1841
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1842
-				$query_values = array_merge($query_values,array(':day' => $day));
1842
+				$query_values = array_merge($query_values, array(':day' => $day));
1843 1843
 			}
1844 1844
 		}
1845 1845
 		$query .= " ORDER BY source_name";
1846
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1846
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1847 1847
 		try {
1848 1848
 			$sth = $this->db->prepare($query);
1849 1849
 			$sth->execute($query_values);
1850
-		} catch(PDOException $e) {
1850
+		} catch (PDOException $e) {
1851 1851
 			echo "error : ".$e->getMessage();
1852 1852
 		}
1853 1853
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1854 1854
 		return $all;
1855 1855
 	}
1856 1856
 
1857
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1857
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1858 1858
 		global $globalDBdriver;
1859 1859
 		if ($globalDBdriver == 'mysql') {
1860 1860
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1861 1861
 		} else {
1862 1862
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1863 1863
 		}
1864
-		$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1864
+		$query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1865 1865
 		try {
1866 1866
 			$sth = $this->db->prepare($query);
1867 1867
 			$sth->execute($query_values);
1868
-		} catch(PDOException $e) {
1868
+		} catch (PDOException $e) {
1869 1869
 			return "error : ".$e->getMessage();
1870 1870
 		}
1871 1871
 	}
1872
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1872
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1873 1873
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1874
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1874
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1875 1875
 		try {
1876 1876
 			$sth = $this->db->prepare($query);
1877 1877
 			$sth->execute($query_values);
1878
-		} catch(PDOException $e) {
1878
+		} catch (PDOException $e) {
1879 1879
 			return "error : ".$e->getMessage();
1880 1880
 		}
1881 1881
 	}
1882
-	public function addStatMarine($type,$date_name,$cnt,$filter_name = '') {
1882
+	public function addStatMarine($type, $date_name, $cnt, $filter_name = '') {
1883 1883
 		$query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
1884
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
1884
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1885 1885
 		try {
1886 1886
 			$sth = $this->db->prepare($query);
1887 1887
 			$sth->execute($query_values);
1888
-		} catch(PDOException $e) {
1888
+		} catch (PDOException $e) {
1889 1889
 			return "error : ".$e->getMessage();
1890 1890
 		}
1891 1891
 	}
1892
-	public function addStatTracker($type,$date_name,$cnt,$filter_name = '') {
1892
+	public function addStatTracker($type, $date_name, $cnt, $filter_name = '') {
1893 1893
 		$query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
1894
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
1894
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1895 1895
 		try {
1896 1896
 			$sth = $this->db->prepare($query);
1897 1897
 			$sth->execute($query_values);
1898
-		} catch(PDOException $e) {
1898
+		} catch (PDOException $e) {
1899 1899
 			return "error : ".$e->getMessage();
1900 1900
 		}
1901 1901
 	}
1902
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1902
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1903 1903
 		global $globalDBdriver;
1904 1904
 		if ($globalDBdriver == 'mysql') {
1905 1905
 			if ($reset) {
@@ -1914,15 +1914,15 @@  discard block
 block discarded – undo
1914 1914
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1915 1915
 			}
1916 1916
 		}
1917
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1917
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1918 1918
 		try {
1919 1919
 			$sth = $this->db->prepare($query);
1920 1920
 			$sth->execute($query_values);
1921
-		} catch(PDOException $e) {
1921
+		} catch (PDOException $e) {
1922 1922
 			return "error : ".$e->getMessage();
1923 1923
 		}
1924 1924
 	}
1925
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1925
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1926 1926
 		global $globalDBdriver;
1927 1927
 		if ($globalDBdriver == 'mysql') {
1928 1928
 			if ($reset) {
@@ -1937,15 +1937,15 @@  discard block
 block discarded – undo
1937 1937
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1938 1938
 			}
1939 1939
 		}
1940
-		$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1940
+		$query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1941 1941
 		try {
1942 1942
 			$sth = $this->db->prepare($query);
1943 1943
 			$sth->execute($query_values);
1944
-		} catch(PDOException $e) {
1944
+		} catch (PDOException $e) {
1945 1945
 			return "error : ".$e->getMessage();
1946 1946
 		}
1947 1947
 	}
1948
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1948
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1949 1949
 		global $globalDBdriver;
1950 1950
 		if ($globalDBdriver == 'mysql') {
1951 1951
 			if ($reset) {
@@ -1960,15 +1960,15 @@  discard block
 block discarded – undo
1960 1960
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
1961 1961
 			}
1962 1962
 		}
1963
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1963
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1964 1964
 		try {
1965 1965
 			$sth = $this->db->prepare($query);
1966 1966
 			$sth->execute($query_values);
1967
-		} catch(PDOException $e) {
1967
+		} catch (PDOException $e) {
1968 1968
 			return "error : ".$e->getMessage();
1969 1969
 		}
1970 1970
 	}
1971
-	public function addStatCountryMarine($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1971
+	public function addStatCountryMarine($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
1972 1972
 		global $globalDBdriver;
1973 1973
 		if ($globalDBdriver == 'mysql') {
1974 1974
 			if ($reset) {
@@ -1983,15 +1983,15 @@  discard block
 block discarded – undo
1983 1983
 				$query = "UPDATE stats_marine_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_marine_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
1984 1984
 			}
1985 1985
 		}
1986
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1986
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1987 1987
 		try {
1988 1988
 			$sth = $this->db->prepare($query);
1989 1989
 			$sth->execute($query_values);
1990
-		} catch(PDOException $e) {
1990
+		} catch (PDOException $e) {
1991 1991
 			return "error : ".$e->getMessage();
1992 1992
 		}
1993 1993
 	}
1994
-	public function addStatCountryTracker($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1994
+	public function addStatCountryTracker($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
1995 1995
 		global $globalDBdriver;
1996 1996
 		if ($globalDBdriver == 'mysql') {
1997 1997
 			if ($reset) {
@@ -2006,15 +2006,15 @@  discard block
 block discarded – undo
2006 2006
 				$query = "UPDATE stats_tracker_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_tracker_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2007 2007
 			}
2008 2008
 		}
2009
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2009
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2010 2010
 		try {
2011 2011
 			$sth = $this->db->prepare($query);
2012 2012
 			$sth->execute($query_values);
2013
-		} catch(PDOException $e) {
2013
+		} catch (PDOException $e) {
2014 2014
 			return "error : ".$e->getMessage();
2015 2015
 		}
2016 2016
 	}
2017
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2017
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2018 2018
 		global $globalDBdriver;
2019 2019
 		if ($globalDBdriver == 'mysql') {
2020 2020
 			if ($reset) {
@@ -2029,15 +2029,15 @@  discard block
 block discarded – undo
2029 2029
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2030 2030
 			}
2031 2031
 		}
2032
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2032
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2033 2033
 		try {
2034 2034
 			$sth = $this->db->prepare($query);
2035 2035
 			$sth->execute($query_values);
2036
-		} catch(PDOException $e) {
2036
+		} catch (PDOException $e) {
2037 2037
 			return "error : ".$e->getMessage();
2038 2038
 		}
2039 2039
 	}
2040
-	public function addStatMarineType($type,$type_id,$cnt, $filter_name = '', $reset = false) {
2040
+	public function addStatMarineType($type, $type_id, $cnt, $filter_name = '', $reset = false) {
2041 2041
 		global $globalDBdriver;
2042 2042
 		if ($globalDBdriver == 'mysql') {
2043 2043
 			if ($reset) {
@@ -2052,15 +2052,15 @@  discard block
 block discarded – undo
2052 2052
 				$query = "UPDATE stats_marine_type SET cnt = cnt+:cnt, type = :type, filter_name = :filter_name WHERE type_id = :type_id AND filter_name = :filter_name; INSERT INTO stats_marine_type (type,type_id,cnt,filter_name) SELECT :type,:type_id,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_type WHERE type_id = :type_id AND filter_name = :filter_name);"; 
2053 2053
 			}
2054 2054
 		}
2055
-		$query_values = array(':type' => $type,':type_id' => $type_id,':cnt' => $cnt, ':filter_name' => $filter_name);
2055
+		$query_values = array(':type' => $type, ':type_id' => $type_id, ':cnt' => $cnt, ':filter_name' => $filter_name);
2056 2056
 		try {
2057 2057
 			$sth = $this->db->prepare($query);
2058 2058
 			$sth->execute($query_values);
2059
-		} catch(PDOException $e) {
2059
+		} catch (PDOException $e) {
2060 2060
 			return "error : ".$e->getMessage();
2061 2061
 		}
2062 2062
 	}
2063
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
2063
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
2064 2064
 		global $globalDBdriver;
2065 2065
 		if ($globalDBdriver == 'mysql') {
2066 2066
 			if ($reset) {
@@ -2075,15 +2075,15 @@  discard block
 block discarded – undo
2075 2075
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
2076 2076
 			}
2077 2077
 		}
2078
-		$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
2078
+		$query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2079 2079
 		try {
2080 2080
 			$sth = $this->db->prepare($query);
2081 2081
 			$sth->execute($query_values);
2082
-		} catch(PDOException $e) {
2082
+		} catch (PDOException $e) {
2083 2083
 			return "error : ".$e->getMessage();
2084 2084
 		}
2085 2085
 	}
2086
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
2086
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
2087 2087
 		global $globalDBdriver;
2088 2088
 		if ($globalDBdriver == 'mysql') {
2089 2089
 			if ($reset) {
@@ -2098,15 +2098,15 @@  discard block
 block discarded – undo
2098 2098
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2099 2099
 			}
2100 2100
 		}
2101
-		$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2101
+		$query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2102 2102
 		try {
2103 2103
 			$sth = $this->db->prepare($query);
2104 2104
 			$sth->execute($query_values);
2105
-		} catch(PDOException $e) {
2105
+		} catch (PDOException $e) {
2106 2106
 			return "error : ".$e->getMessage();
2107 2107
 		}
2108 2108
 	}
2109
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
2109
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
2110 2110
 		global $globalDBdriver;
2111 2111
 		if ($globalDBdriver == 'mysql') {
2112 2112
 			if ($reset) {
@@ -2121,15 +2121,15 @@  discard block
 block discarded – undo
2121 2121
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
2122 2122
 			}
2123 2123
 		}
2124
-		$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
2124
+		$query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
2125 2125
 		try {
2126 2126
 			$sth = $this->db->prepare($query);
2127 2127
 			$sth->execute($query_values);
2128
-		} catch(PDOException $e) {
2128
+		} catch (PDOException $e) {
2129 2129
 			return "error : ".$e->getMessage();
2130 2130
 		}
2131 2131
 	}
2132
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
2132
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
2133 2133
 		global $globalDBdriver;
2134 2134
 		if ($airport_icao != '') {
2135 2135
 			if ($globalDBdriver == 'mysql') {
@@ -2145,16 +2145,16 @@  discard block
 block discarded – undo
2145 2145
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
2146 2146
 				}
2147 2147
 			}
2148
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2148
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2149 2149
 			try {
2150 2150
 				$sth = $this->db->prepare($query);
2151 2151
 				$sth->execute($query_values);
2152
-			} catch(PDOException $e) {
2152
+			} catch (PDOException $e) {
2153 2153
 				return "error : ".$e->getMessage();
2154 2154
 			}
2155 2155
 		}
2156 2156
 	}
2157
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
2157
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
2158 2158
 		global $globalDBdriver;
2159 2159
 		if ($airport_icao != '') {
2160 2160
 			if ($globalDBdriver == 'mysql') {
@@ -2162,16 +2162,16 @@  discard block
 block discarded – undo
2162 2162
 			} else {
2163 2163
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2164 2164
 			}
2165
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2165
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2166 2166
 			 try {
2167 2167
 				$sth = $this->db->prepare($query);
2168 2168
 				$sth->execute($query_values);
2169
-			} catch(PDOException $e) {
2169
+			} catch (PDOException $e) {
2170 2170
 				return "error : ".$e->getMessage();
2171 2171
 			}
2172 2172
 		}
2173 2173
 	}
2174
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
2174
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
2175 2175
 		global $globalDBdriver;
2176 2176
 		if ($airport_icao != '') {
2177 2177
 			if ($globalDBdriver == 'mysql') {
@@ -2187,16 +2187,16 @@  discard block
 block discarded – undo
2187 2187
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
2188 2188
 				}
2189 2189
 			}
2190
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2190
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2191 2191
 			try {
2192 2192
 				$sth = $this->db->prepare($query);
2193 2193
 				$sth->execute($query_values);
2194
-			} catch(PDOException $e) {
2194
+			} catch (PDOException $e) {
2195 2195
 				return "error : ".$e->getMessage();
2196 2196
 			}
2197 2197
 		}
2198 2198
 	}
2199
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
2199
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
2200 2200
 		global $globalDBdriver;
2201 2201
 		if ($airport_icao != '') {
2202 2202
 			if ($globalDBdriver == 'mysql') {
@@ -2204,11 +2204,11 @@  discard block
 block discarded – undo
2204 2204
 			} else {
2205 2205
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2206 2206
 			}
2207
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2207
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2208 2208
 			try {
2209 2209
 				$sth = $this->db->prepare($query);
2210 2210
 				$sth->execute($query_values);
2211
-			} catch(PDOException $e) {
2211
+			} catch (PDOException $e) {
2212 2212
 				return "error : ".$e->getMessage();
2213 2213
 			}
2214 2214
 		}
@@ -2220,7 +2220,7 @@  discard block
 block discarded – undo
2220 2220
 		try {
2221 2221
 			$sth = $this->db->prepare($query);
2222 2222
 			$sth->execute($query_values);
2223
-		} catch(PDOException $e) {
2223
+		} catch (PDOException $e) {
2224 2224
 			return "error : ".$e->getMessage();
2225 2225
 		}
2226 2226
 	}
@@ -2230,7 +2230,7 @@  discard block
 block discarded – undo
2230 2230
 		try {
2231 2231
 			$sth = $this->db->prepare($query);
2232 2232
 			$sth->execute($query_values);
2233
-		} catch(PDOException $e) {
2233
+		} catch (PDOException $e) {
2234 2234
 			return "error : ".$e->getMessage();
2235 2235
 		}
2236 2236
 	}
@@ -2240,7 +2240,7 @@  discard block
 block discarded – undo
2240 2240
 		try {
2241 2241
 			$sth = $this->db->prepare($query);
2242 2242
 			$sth->execute($query_values);
2243
-		} catch(PDOException $e) {
2243
+		} catch (PDOException $e) {
2244 2244
 			return "error : ".$e->getMessage();
2245 2245
 		}
2246 2246
 	}
@@ -2250,7 +2250,7 @@  discard block
 block discarded – undo
2250 2250
 		try {
2251 2251
 			$sth = $this->db->prepare($query);
2252 2252
 			$sth->execute($query_values);
2253
-		} catch(PDOException $e) {
2253
+		} catch (PDOException $e) {
2254 2254
 			return "error : ".$e->getMessage();
2255 2255
 		}
2256 2256
 	}
@@ -2260,13 +2260,13 @@  discard block
 block discarded – undo
2260 2260
 		try {
2261 2261
 			$sth = $this->db->prepare($query);
2262 2262
 			$sth->execute($query_values);
2263
-		} catch(PDOException $e) {
2263
+		} catch (PDOException $e) {
2264 2264
 			return "error : ".$e->getMessage();
2265 2265
 		}
2266 2266
 	}
2267 2267
 
2268 2268
 	public function addOldStats() {
2269
-		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
2269
+		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents;
2270 2270
 		$Common = new Common();
2271 2271
 		$Connection = new Connection($this->db);
2272 2272
 		date_default_timezone_set('UTC');
@@ -2281,9 +2281,9 @@  discard block
 block discarded – undo
2281 2281
 			$filtername = 'marine';
2282 2282
 			if ($Connection->tableExists('countries')) {
2283 2283
 				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2284
-				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2284
+				$alldata = $Marine->countAllMarineOverCountries(false, 0, $last_update_day);
2285 2285
 				foreach ($alldata as $number) {
2286
-					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2286
+					echo $this->addStatCountryMarine($number['marine_country_iso2'], $number['marine_country_iso3'], $number['marine_country'], $number['marine_count'], '', '', $reset);
2287 2287
 				}
2288 2288
 			}
2289 2289
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2293,44 +2293,44 @@  discard block
 block discarded – undo
2293 2293
 			$lastyear = false;
2294 2294
 			foreach ($alldata as $number) {
2295 2295
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2296
-				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2296
+				$this->addStat('marine_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2297 2297
 			}
2298 2298
 			echo 'Marine data...'."\n";
2299 2299
 			$this->deleteStatMarine('month');
2300 2300
 			echo '-> countAllDatesLastMonth...'."\n";
2301 2301
 			$alldata = $Marine->countAllDatesLastMonth($filter_last_month);
2302 2302
 			foreach ($alldata as $number) {
2303
-				$this->addStatMarine('month',$number['date_name'],$number['date_count']);
2303
+				$this->addStatMarine('month', $number['date_name'], $number['date_count']);
2304 2304
 			}
2305 2305
 			echo '-> countAllDates...'."\n";
2306 2306
 			$previousdata = $this->countAllDatesMarine();
2307 2307
 			$this->deleteStatMarine('date');
2308
-			$alldata = $Common->array_merge_noappend($previousdata,$Marine->countAllDates($filter_last_month));
2308
+			$alldata = $Common->array_merge_noappend($previousdata, $Marine->countAllDates($filter_last_month));
2309 2309
 			$values = array();
2310 2310
 			foreach ($alldata as $cnt) {
2311 2311
 				$values[] = $cnt['date_count'];
2312 2312
 			}
2313
-			array_multisort($values,SORT_DESC,$alldata);
2314
-			array_splice($alldata,11);
2313
+			array_multisort($values, SORT_DESC, $alldata);
2314
+			array_splice($alldata, 11);
2315 2315
 			foreach ($alldata as $number) {
2316
-				$this->addStatMarine('date',$number['date_name'],$number['date_count']);
2316
+				$this->addStatMarine('date', $number['date_name'], $number['date_count']);
2317 2317
 			}
2318 2318
 			
2319 2319
 			$this->deleteStatMarine('hour');
2320 2320
 			echo '-> countAllHours...'."\n";
2321
-			$alldata = $Marine->countAllHours('hour',$filter_last_month);
2321
+			$alldata = $Marine->countAllHours('hour', $filter_last_month);
2322 2322
 			foreach ($alldata as $number) {
2323
-				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2323
+				$this->addStatMarine('hour', $number['hour_name'], $number['hour_count']);
2324 2324
 			}
2325 2325
 			if ($globalDebug) echo 'Count all types...'."\n";
2326
-			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2326
+			$alldata = $Marine->countAllMarineTypes(false, 0, $last_update_day);
2327 2327
 			foreach ($alldata as $number) {
2328
-				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
2328
+				$this->addStatMarineType($number['marine_type'], $number['marine_type_id'], $number['marine_type_count'], '', $reset);
2329 2329
 			}
2330 2330
 
2331 2331
 			echo 'Insert last stats update date...'."\n";
2332 2332
 			date_default_timezone_set('UTC');
2333
-			$this->addLastStatsUpdate('last_update_stats_marine',date('Y-m-d G:i:s'));
2333
+			$this->addLastStatsUpdate('last_update_stats_marine', date('Y-m-d G:i:s'));
2334 2334
 		}
2335 2335
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2336 2336
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
@@ -2342,9 +2342,9 @@  discard block
 block discarded – undo
2342 2342
 			$Tracker = new Tracker($this->db);
2343 2343
 			if ($Connection->tableExists('countries')) {
2344 2344
 				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2345
-				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2345
+				$alldata = $Tracker->countAllTrackerOverCountries(false, 0, $last_update_day);
2346 2346
 				foreach ($alldata as $number) {
2347
-					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2347
+					$this->addStatCountryTracker($number['tracker_country_iso2'], $number['tracker_country_iso3'], $number['tracker_country'], $number['tracker_count'], '', '', $reset);
2348 2348
 				}
2349 2349
 			}
2350 2350
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2354,38 +2354,38 @@  discard block
 block discarded – undo
2354 2354
 			$lastyear = false;
2355 2355
 			foreach ($alldata as $number) {
2356 2356
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2357
-				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2357
+				$this->addStat('tracker_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2358 2358
 			}
2359 2359
 			echo 'Tracker data...'."\n";
2360 2360
 			$this->deleteStatTracker('month');
2361 2361
 			echo '-> countAllDatesLastMonth...'."\n";
2362 2362
 			$alldata = $Tracker->countAllDatesLastMonth($filter_last_month);
2363 2363
 			foreach ($alldata as $number) {
2364
-				$this->addStatTracker('month',$number['date_name'],$number['date_count']);
2364
+				$this->addStatTracker('month', $number['date_name'], $number['date_count']);
2365 2365
 			}
2366 2366
 			echo '-> countAllDates...'."\n";
2367 2367
 			$previousdata = $this->countAllDatesTracker();
2368 2368
 			$this->deleteStatTracker('date');
2369
-			$alldata = $Common->array_merge_noappend($previousdata,$Tracker->countAllDates($filter_last_month));
2369
+			$alldata = $Common->array_merge_noappend($previousdata, $Tracker->countAllDates($filter_last_month));
2370 2370
 			$values = array();
2371 2371
 			foreach ($alldata as $cnt) {
2372 2372
 				$values[] = $cnt['date_count'];
2373 2373
 			}
2374
-			array_multisort($values,SORT_DESC,$alldata);
2375
-			array_splice($alldata,11);
2374
+			array_multisort($values, SORT_DESC, $alldata);
2375
+			array_splice($alldata, 11);
2376 2376
 			foreach ($alldata as $number) {
2377
-				$this->addStatTracker('date',$number['date_name'],$number['date_count']);
2377
+				$this->addStatTracker('date', $number['date_name'], $number['date_count']);
2378 2378
 			}
2379 2379
 			
2380 2380
 			$this->deleteStatTracker('hour');
2381 2381
 			echo '-> countAllHours...'."\n";
2382
-			$alldata = $Tracker->countAllHours('hour',$filter_last_month);
2382
+			$alldata = $Tracker->countAllHours('hour', $filter_last_month);
2383 2383
 			foreach ($alldata as $number) {
2384
-				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2384
+				$this->addStatTracker('hour', $number['hour_name'], $number['hour_count']);
2385 2385
 			}
2386 2386
 			echo 'Insert last stats update date...'."\n";
2387 2387
 			date_default_timezone_set('UTC');
2388
-			$this->addLastStatsUpdate('last_update_stats_tracker',date('Y-m-d G:i:s'));
2388
+			$this->addLastStatsUpdate('last_update_stats_tracker', date('Y-m-d G:i:s'));
2389 2389
 		}
2390 2390
 
2391 2391
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
@@ -2403,41 +2403,41 @@  discard block
 block discarded – undo
2403 2403
 			$Spotter = new Spotter($this->db);
2404 2404
 
2405 2405
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2406
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2406
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
2407 2407
 			foreach ($alldata as $number) {
2408
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2408
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
2409 2409
 			}
2410 2410
 			if ($globalDebug) echo 'Count all airlines...'."\n";
2411
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2411
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
2412 2412
 			foreach ($alldata as $number) {
2413
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2413
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
2414 2414
 			}
2415 2415
 			if ($globalDebug) echo 'Count all registrations...'."\n";
2416
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2416
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
2417 2417
 			foreach ($alldata as $number) {
2418
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2418
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
2419 2419
 			}
2420 2420
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
2421
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2421
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
2422 2422
 			foreach ($alldata as $number) {
2423
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2423
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2424 2424
 			}
2425 2425
 			if ($globalDebug) echo 'Count all owners...'."\n";
2426
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2426
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
2427 2427
 			foreach ($alldata as $number) {
2428
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2428
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
2429 2429
 			}
2430 2430
 			if ($globalDebug) echo 'Count all pilots...'."\n";
2431
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2431
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
2432 2432
 			foreach ($alldata as $number) {
2433 2433
 				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2434
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2434
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
2435 2435
 			}
2436 2436
 			
2437 2437
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
2438
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2438
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
2439 2439
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2440
-			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2440
+			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
2441 2441
 			if ($globalDebug) echo 'Order departure airports...'."\n";
2442 2442
 			$alldata = array();
2443 2443
 			foreach ($pall as $value) {
@@ -2454,14 +2454,14 @@  discard block
 block discarded – undo
2454 2454
 			foreach ($alldata as $key => $row) {
2455 2455
 				$count[$key] = $row['airport_departure_icao_count'];
2456 2456
 			}
2457
-			array_multisort($count,SORT_DESC,$alldata);
2457
+			array_multisort($count, SORT_DESC, $alldata);
2458 2458
 			foreach ($alldata as $number) {
2459
-				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);
2459
+				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);
2460 2460
 			}
2461 2461
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2462
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2462
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
2463 2463
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2464
-			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2464
+			$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
2465 2465
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
2466 2466
 			$alldata = array();
2467 2467
 			foreach ($pall as $value) {
@@ -2478,18 +2478,18 @@  discard block
 block discarded – undo
2478 2478
 			foreach ($alldata as $key => $row) {
2479 2479
 				$count[$key] = $row['airport_arrival_icao_count'];
2480 2480
 			}
2481
-			array_multisort($count,SORT_DESC,$alldata);
2481
+			array_multisort($count, SORT_DESC, $alldata);
2482 2482
 			foreach ($alldata as $number) {
2483
-				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);
2483
+				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);
2484 2484
 			}
2485 2485
 			if ($Connection->tableExists('countries')) {
2486 2486
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2487 2487
 				//$SpotterArchive = new SpotterArchive();
2488 2488
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2489 2489
 				$Spotter = new Spotter($this->db);
2490
-				$alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day);
2490
+				$alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day);
2491 2491
 				foreach ($alldata as $number) {
2492
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
2492
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
2493 2493
 				}
2494 2494
 			}
2495 2495
 			
@@ -2499,12 +2499,12 @@  discard block
 block discarded – undo
2499 2499
 				$this->deleteStatsByType('fatalities_byyear');
2500 2500
 				$alldata = $Accident->countFatalitiesByYear();
2501 2501
 				foreach ($alldata as $number) {
2502
-					$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
2502
+					$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
2503 2503
 				}
2504 2504
 				$this->deleteStatsByType('fatalities_bymonth');
2505 2505
 				$alldata = $Accident->countFatalitiesLast12Months();
2506 2506
 				foreach ($alldata as $number) {
2507
-					$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
2507
+					$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
2508 2508
 				}
2509 2509
 			}
2510 2510
 
@@ -2518,37 +2518,37 @@  discard block
 block discarded – undo
2518 2518
 			$lastyear = false;
2519 2519
 			foreach ($alldata as $number) {
2520 2520
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2521
-				$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'])));
2521
+				$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'])));
2522 2522
 			}
2523 2523
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2524 2524
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2525 2525
 			foreach ($alldata as $number) {
2526
-				$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'])));
2526
+				$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'])));
2527 2527
 			}
2528 2528
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
2529 2529
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2530 2530
 			foreach ($alldata as $number) {
2531
-				$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'])));
2531
+				$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'])));
2532 2532
 			}
2533 2533
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2534 2534
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2535 2535
 			foreach ($alldata as $number) {
2536
-				$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'])));
2536
+				$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'])));
2537 2537
 			}
2538 2538
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2539 2539
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2540 2540
 			foreach ($alldata as $number) {
2541
-				$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'])));
2541
+				$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'])));
2542 2542
 			}
2543 2543
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2544 2544
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2545 2545
 			foreach ($alldata as $number) {
2546
-				$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'])));
2546
+				$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'])));
2547 2547
 			}
2548 2548
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2549 2549
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2550 2550
 			foreach ($alldata as $number) {
2551
-				$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'])));
2551
+				$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'])));
2552 2552
 			}
2553 2553
 			if ($globalDebug) echo 'Airports data...'."\n";
2554 2554
 			if ($globalDebug) echo '...Departure'."\n";
@@ -2593,7 +2593,7 @@  discard block
 block discarded – undo
2593 2593
 			}
2594 2594
 			$alldata = $pall;
2595 2595
 			foreach ($alldata as $number) {
2596
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
2596
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
2597 2597
 			}
2598 2598
 			echo '...Arrival'."\n";
2599 2599
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -2634,7 +2634,7 @@  discard block
 block discarded – undo
2634 2634
 			}
2635 2635
 			$alldata = $pall;
2636 2636
 			foreach ($alldata as $number) {
2637
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
2637
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
2638 2638
 			}
2639 2639
 
2640 2640
 			echo 'Flights data...'."\n";
@@ -2642,28 +2642,28 @@  discard block
 block discarded – undo
2642 2642
 			echo '-> countAllDatesLastMonth...'."\n";
2643 2643
 			$alldata = $Spotter->countAllDatesLastMonth($filter_last_month);
2644 2644
 			foreach ($alldata as $number) {
2645
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
2645
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
2646 2646
 			}
2647 2647
 			echo '-> countAllDates...'."\n";
2648 2648
 			$previousdata = $this->countAllDates();
2649 2649
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
2650 2650
 			$this->deleteStatFlight('date');
2651
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month));
2651
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month));
2652 2652
 			$values = array();
2653 2653
 			foreach ($alldata as $cnt) {
2654 2654
 				$values[] = $cnt['date_count'];
2655 2655
 			}
2656
-			array_multisort($values,SORT_DESC,$alldata);
2657
-			array_splice($alldata,11);
2656
+			array_multisort($values, SORT_DESC, $alldata);
2657
+			array_splice($alldata, 11);
2658 2658
 			foreach ($alldata as $number) {
2659
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
2659
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
2660 2660
 			}
2661 2661
 			
2662 2662
 			$this->deleteStatFlight('hour');
2663 2663
 			echo '-> countAllHours...'."\n";
2664
-			$alldata = $Spotter->countAllHours('hour',$filter_last_month);
2664
+			$alldata = $Spotter->countAllHours('hour', $filter_last_month);
2665 2665
 			foreach ($alldata as $number) {
2666
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
2666
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
2667 2667
 			}
2668 2668
 
2669 2669
 			// Count by airlines
@@ -2672,42 +2672,42 @@  discard block
 block discarded – undo
2672 2672
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2673 2673
 				$SpotterArchive = new SpotterArchive($this->db);
2674 2674
 				//$Spotter = new Spotter($this->db);
2675
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2675
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
2676 2676
 				//$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2677 2677
 				foreach ($alldata as $number) {
2678
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2678
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
2679 2679
 				}
2680 2680
 			}
2681 2681
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2682 2682
 			$Spotter = new Spotter($this->db);
2683
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2683
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
2684 2684
 			foreach ($alldata as $number) {
2685
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2685
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
2686 2686
 			}
2687 2687
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2688
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2688
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
2689 2689
 			foreach ($alldata as $number) {
2690
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2690
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
2691 2691
 			}
2692 2692
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2693
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2693
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
2694 2694
 			foreach ($alldata as $number) {
2695
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2695
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2696 2696
 			}
2697 2697
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2698
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2698
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
2699 2699
 			foreach ($alldata as $number) {
2700
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2700
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
2701 2701
 			}
2702 2702
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2703
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2703
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
2704 2704
 			foreach ($alldata as $number) {
2705
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2705
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
2706 2706
 			}
2707 2707
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2708
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2708
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
2709 2709
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2710
-			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2710
+			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
2711 2711
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2712 2712
 			//$alldata = array();
2713 2713
 			foreach ($dall as $value) {
@@ -2727,12 +2727,12 @@  discard block
 block discarded – undo
2727 2727
 			}
2728 2728
 			$alldata = $pall;
2729 2729
 			foreach ($alldata as $number) {
2730
-				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);
2730
+				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);
2731 2731
 			}
2732 2732
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2733
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2733
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
2734 2734
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2735
-			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2735
+			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
2736 2736
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2737 2737
 			//$alldata = array();
2738 2738
 			foreach ($dall as $value) {
@@ -2752,7 +2752,7 @@  discard block
 block discarded – undo
2752 2752
 			}
2753 2753
 			$alldata = $pall;
2754 2754
 			foreach ($alldata as $number) {
2755
-				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);
2755
+				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);
2756 2756
 			}
2757 2757
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2758 2758
 			$Spotter = new Spotter($this->db);
@@ -2760,27 +2760,27 @@  discard block
 block discarded – undo
2760 2760
 			$lastyear = false;
2761 2761
 			foreach ($alldata as $number) {
2762 2762
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2763
-				$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']);
2763
+				$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']);
2764 2764
 			}
2765 2765
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2766 2766
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2767 2767
 			foreach ($alldata as $number) {
2768
-				$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']);
2768
+				$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']);
2769 2769
 			}
2770 2770
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2771 2771
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2772 2772
 			foreach ($alldata as $number) {
2773
-				$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']);
2773
+				$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']);
2774 2774
 			}
2775 2775
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2776 2776
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2777 2777
 			foreach ($alldata as $number) {
2778
-				$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']);
2778
+				$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']);
2779 2779
 			}
2780 2780
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2781 2781
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2782 2782
 			foreach ($alldata as $number) {
2783
-				$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']);
2783
+				$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']);
2784 2784
 			}
2785 2785
 			if ($globalDebug) echo '...Departure'."\n";
2786 2786
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -2803,7 +2803,7 @@  discard block
 block discarded – undo
2803 2803
 			}
2804 2804
 			$alldata = $pall;
2805 2805
 			foreach ($alldata as $number) {
2806
-				$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']);
2806
+				$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']);
2807 2807
 			}
2808 2808
 			if ($globalDebug) echo '...Arrival'."\n";
2809 2809
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -2826,32 +2826,32 @@  discard block
 block discarded – undo
2826 2826
 			}
2827 2827
 			$alldata = $pall;
2828 2828
 			foreach ($alldata as $number) {
2829
-				$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']);
2829
+				$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']);
2830 2830
 			}
2831 2831
 
2832 2832
 			if ($globalDebug) echo 'Flights data...'."\n";
2833 2833
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2834 2834
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2835 2835
 			foreach ($alldata as $number) {
2836
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2836
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
2837 2837
 			}
2838 2838
 			if ($globalDebug) echo '-> countAllDates...'."\n";
2839 2839
 			//$previousdata = $this->countAllDatesByAirlines();
2840
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2840
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month));
2841 2841
 			$values = array();
2842 2842
 			foreach ($alldata as $cnt) {
2843 2843
 				$values[] = $cnt['date_count'];
2844 2844
 			}
2845
-			array_multisort($values,SORT_DESC,$alldata);
2846
-			array_splice($alldata,11);
2845
+			array_multisort($values, SORT_DESC, $alldata);
2846
+			array_splice($alldata, 11);
2847 2847
 			foreach ($alldata as $number) {
2848
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2848
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
2849 2849
 			}
2850 2850
 			
2851 2851
 			if ($globalDebug) echo '-> countAllHours...'."\n";
2852
-			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2852
+			$alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month);
2853 2853
 			foreach ($alldata as $number) {
2854
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2854
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
2855 2855
 			}
2856 2856
 
2857 2857
 			// Stats by filters
@@ -2875,7 +2875,7 @@  discard block
 block discarded – undo
2875 2875
 							$last_update_day = date('Y').'-01-01 00:00:00';
2876 2876
 						}
2877 2877
 					}
2878
-					if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
2878
+					if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
2879 2879
 						$last_update_day = date('Y').'-01-01 00:00:00';
2880 2880
 						$reset = true;
2881 2881
 					}
@@ -2883,38 +2883,38 @@  discard block
 block discarded – undo
2883 2883
 					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2884 2884
 					$Spotter = new Spotter($this->db);
2885 2885
 					if ($globalDebug) echo 'Count all aircraft types...'."\n";
2886
-					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2886
+					$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
2887 2887
 					foreach ($alldata as $number) {
2888
-						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2888
+						$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
2889 2889
 					}
2890 2890
 					if ($globalDebug) echo 'Count all airlines...'."\n";
2891
-					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2891
+					$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
2892 2892
 					foreach ($alldata as $number) {
2893
-						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2893
+						$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
2894 2894
 					}
2895 2895
 					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
2896
-					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2896
+					$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
2897 2897
 					foreach ($alldata as $number) {
2898
-						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2898
+						$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
2899 2899
 					}
2900 2900
 					if ($globalDebug) echo 'Count all callsigns...'."\n";
2901
-					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2901
+					$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
2902 2902
 					foreach ($alldata as $number) {
2903
-						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2903
+						$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
2904 2904
 					}
2905 2905
 					if ($globalDebug) echo 'Count all owners...'."\n";
2906
-					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2906
+					$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
2907 2907
 					foreach ($alldata as $number) {
2908
-						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2908
+						$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
2909 2909
 					}
2910 2910
 					if ($globalDebug) echo 'Count all pilots...'."\n";
2911
-					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2911
+					$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
2912 2912
 					foreach ($alldata as $number) {
2913
-						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2913
+						$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
2914 2914
 					}
2915 2915
 					if ($globalDebug) echo 'Count departure airports...'."\n";
2916
-					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2917
-					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2916
+					$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
2917
+					$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
2918 2918
 					$alldata = array();
2919 2919
 					foreach ($pall as $value) {
2920 2920
 						$icao = $value['airport_departure_icao'];
@@ -2930,13 +2930,13 @@  discard block
 block discarded – undo
2930 2930
 					foreach ($alldata as $key => $row) {
2931 2931
 						$count[$key] = $row['airport_departure_icao_count'];
2932 2932
 					}
2933
-					array_multisort($count,SORT_DESC,$alldata);
2933
+					array_multisort($count, SORT_DESC, $alldata);
2934 2934
 					foreach ($alldata as $number) {
2935
-						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
2935
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
2936 2936
 					}
2937 2937
 					if ($globalDebug) echo 'Count all arrival airports...'."\n";
2938
-					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2939
-					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2938
+					$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
2939
+					$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
2940 2940
 					$alldata = array();
2941 2941
 					foreach ($pall as $value) {
2942 2942
 						$icao = $value['airport_arrival_icao'];
@@ -2952,9 +2952,9 @@  discard block
 block discarded – undo
2952 2952
 					foreach ($alldata as $key => $row) {
2953 2953
 						$count[$key] = $row['airport_arrival_icao_count'];
2954 2954
 					}
2955
-					array_multisort($count,SORT_DESC,$alldata);
2955
+					array_multisort($count, SORT_DESC, $alldata);
2956 2956
 					foreach ($alldata as $number) {
2957
-						echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
2957
+						echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
2958 2958
 					}
2959 2959
 					if ($globalDebug) echo 'Count all months...'."\n";
2960 2960
 					$Spotter = new Spotter($this->db);
@@ -2962,36 +2962,36 @@  discard block
 block discarded – undo
2962 2962
 					$lastyear = false;
2963 2963
 					foreach ($alldata as $number) {
2964 2964
 						if ($number['year_name'] != date('Y')) $lastyear = true;
2965
-						$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);
2965
+						$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);
2966 2966
 					}
2967 2967
 					if ($globalDebug) echo 'Count all owners by months...'."\n";
2968 2968
 					$alldata = $Spotter->countAllMonthsOwners($filter);
2969 2969
 					foreach ($alldata as $number) {
2970
-						$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2970
+						$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2971 2971
 					}
2972 2972
 					if ($globalDebug) echo 'Count all pilots by months...'."\n";
2973 2973
 					$alldata = $Spotter->countAllMonthsPilots($filter);
2974 2974
 					foreach ($alldata as $number) {
2975
-						$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2975
+						$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2976 2976
 					}
2977 2977
 					if ($globalDebug) echo 'Count all military by months...'."\n";
2978 2978
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
2979 2979
 					foreach ($alldata as $number) {
2980
-						$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2980
+						$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2981 2981
 					}
2982 2982
 					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2983 2983
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
2984 2984
 				    	foreach ($alldata as $number) {
2985
-			    			$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2985
+			    			$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2986 2986
 					}
2987 2987
 					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2988 2988
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2989 2989
 					foreach ($alldata as $number) {
2990
-						$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2990
+						$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2991 2991
 					}
2992 2992
 					echo '...Departure'."\n";
2993
-					$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
2994
-					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2993
+					$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
2994
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
2995 2995
 					foreach ($dall as $value) {
2996 2996
 						$icao = $value['departure_airport_icao'];
2997 2997
 						$ddate = $value['date'];
@@ -3009,11 +3009,11 @@  discard block
 block discarded – undo
3009 3009
 					}
3010 3010
 					$alldata = $pall;
3011 3011
 					foreach ($alldata as $number) {
3012
-						$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
3012
+						$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name);
3013 3013
 					}
3014 3014
 					echo '...Arrival'."\n";
3015
-					$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
3016
-					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
3015
+					$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
3016
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
3017 3017
 					foreach ($dall as $value) {
3018 3018
 						$icao = $value['arrival_airport_icao'];
3019 3019
 						$ddate = $value['date'];
@@ -3031,39 +3031,39 @@  discard block
 block discarded – undo
3031 3031
 					}
3032 3032
 					$alldata = $pall;
3033 3033
 					foreach ($alldata as $number) {
3034
-						$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
3034
+						$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name);
3035 3035
 					}
3036 3036
 					echo 'Flights data...'."\n";
3037 3037
 					echo '-> countAllDatesLastMonth...'."\n";
3038 3038
 					$alldata = $Spotter->countAllDatesLastMonth($filter);
3039 3039
 					foreach ($alldata as $number) {
3040
-						$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
3040
+						$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
3041 3041
 					}
3042 3042
 					echo '-> countAllDates...'."\n";
3043
-					$previousdata = $this->countAllDates('',$filter_name);
3044
-					$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
3043
+					$previousdata = $this->countAllDates('', $filter_name);
3044
+					$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
3045 3045
 					$values = array();
3046 3046
 					foreach ($alldata as $cnt) {
3047 3047
 						$values[] = $cnt['date_count'];
3048 3048
 					}
3049
-					array_multisort($values,SORT_DESC,$alldata);
3050
-					array_splice($alldata,11);
3049
+					array_multisort($values, SORT_DESC, $alldata);
3050
+					array_splice($alldata, 11);
3051 3051
 					foreach ($alldata as $number) {
3052
-						$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
3052
+						$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
3053 3053
 					}
3054 3054
 				
3055 3055
 					echo '-> countAllHours...'."\n";
3056
-					$alldata = $Spotter->countAllHours('hour',$filter);
3056
+					$alldata = $Spotter->countAllHours('hour', $filter);
3057 3057
 					foreach ($alldata as $number) {
3058
-						$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
3058
+						$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
3059 3059
 					}
3060 3060
 					echo 'Insert last stats update date...'."\n";
3061 3061
 					date_default_timezone_set('UTC');
3062
-					$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
3062
+					$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
3063 3063
 					if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
3064
-						if (date('Y',strtotime($last_update_day)) != date('Y')) {
3064
+						if (date('Y', strtotime($last_update_day)) != date('Y')) {
3065 3065
 							$this->deleteOldStats($filter_name);
3066
-							$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
3066
+							$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
3067 3067
 						}
3068 3068
 					}
3069 3069
 				}
@@ -3076,16 +3076,16 @@  discard block
 block discarded – undo
3076 3076
 				// SUM all previous month to put as year
3077 3077
 				$previous_year = date('Y');
3078 3078
 				$previous_year--;
3079
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3080
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3081
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3082
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3079
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3080
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3081
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3082
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3083 3083
 				$allairlines = $this->getAllAirlineNames();
3084 3084
 				foreach ($allairlines as $data) {
3085
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3086
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3087
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3088
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3085
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3086
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3087
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3088
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3089 3089
 				}
3090 3090
 				
3091 3091
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -3094,21 +3094,21 @@  discard block
 block discarded – undo
3094 3094
 						try {
3095 3095
 							$sth = $this->db->prepare($query);
3096 3096
 							$sth->execute();
3097
-						} catch(PDOException $e) {
3097
+						} catch (PDOException $e) {
3098 3098
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3099 3099
 						}
3100 3100
 						$query = "INSERT INTO tracker_archive_output SELECT * FROM tracker_output WHERE tracker_output.date < '".date('Y')."-01-01 00:00:00'";
3101 3101
 						try {
3102 3102
 							$sth = $this->db->prepare($query);
3103 3103
 							$sth->execute();
3104
-						} catch(PDOException $e) {
3104
+						} catch (PDOException $e) {
3105 3105
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3106 3106
 						}
3107 3107
 						$query = "INSERT INTO marine_archive_output SELECT * FROM marine_output WHERE marine_output.date < '".date('Y')."-01-01 00:00:00'";
3108 3108
 						try {
3109 3109
 							$sth = $this->db->prepare($query);
3110 3110
 							$sth->execute();
3111
-						} catch(PDOException $e) {
3111
+						} catch (PDOException $e) {
3112 3112
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3113 3113
 						}
3114 3114
 					}
@@ -3121,7 +3121,7 @@  discard block
 block discarded – undo
3121 3121
 					try {
3122 3122
 						$sth = $this->db->prepare($query);
3123 3123
 						$sth->execute();
3124
-					} catch(PDOException $e) {
3124
+					} catch (PDOException $e) {
3125 3125
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3126 3126
 					}
3127 3127
 					if ($globalDBdriver == 'mysql') {
@@ -3132,7 +3132,7 @@  discard block
 block discarded – undo
3132 3132
 					try {
3133 3133
 						$sth = $this->db->prepare($query);
3134 3134
 						$sth->execute();
3135
-					} catch(PDOException $e) {
3135
+					} catch (PDOException $e) {
3136 3136
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3137 3137
 					}
3138 3138
 					if ($globalDBdriver == 'mysql') {
@@ -3143,15 +3143,15 @@  discard block
 block discarded – undo
3143 3143
 					try {
3144 3144
 						$sth = $this->db->prepare($query);
3145 3145
 						$sth->execute();
3146
-					} catch(PDOException $e) {
3146
+					} catch (PDOException $e) {
3147 3147
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3148 3148
 					}
3149 3149
 				}
3150 3150
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
3151 3151
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
3152
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
3152
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
3153 3153
 						$this->deleteOldStats();
3154
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
3154
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
3155 3155
 						$lastyearupdate = true;
3156 3156
 					}
3157 3157
 				}
@@ -3173,7 +3173,7 @@  discard block
 block discarded – undo
3173 3173
 					try {
3174 3174
 						$sth = $this->db->prepare($query);
3175 3175
 						$sth->execute();
3176
-					} catch(PDOException $e) {
3176
+					} catch (PDOException $e) {
3177 3177
 						return "error : ".$e->getMessage();
3178 3178
 					}
3179 3179
 					echo 'Archive old tracker data...'."\n";
@@ -3189,7 +3189,7 @@  discard block
 block discarded – undo
3189 3189
 					try {
3190 3190
 						$sth = $this->db->prepare($query);
3191 3191
 						$sth->execute();
3192
-					} catch(PDOException $e) {
3192
+					} catch (PDOException $e) {
3193 3193
 						return "error : ".$e->getMessage();
3194 3194
 					}
3195 3195
 					echo 'Archive old marine data...'."\n";
@@ -3205,7 +3205,7 @@  discard block
 block discarded – undo
3205 3205
 					try {
3206 3206
 						$sth = $this->db->prepare($query);
3207 3207
 						$sth->execute();
3208
-					} catch(PDOException $e) {
3208
+					} catch (PDOException $e) {
3209 3209
 						return "error : ".$e->getMessage();
3210 3210
 					}
3211 3211
 				}
@@ -3218,7 +3218,7 @@  discard block
 block discarded – undo
3218 3218
 				try {
3219 3219
 					$sth = $this->db->prepare($query);
3220 3220
 					$sth->execute();
3221
-				} catch(PDOException $e) {
3221
+				} catch (PDOException $e) {
3222 3222
 					return "error : ".$e->getMessage();
3223 3223
 				}
3224 3224
 				echo 'Deleting old tracker data...'."\n";
@@ -3230,7 +3230,7 @@  discard block
 block discarded – undo
3230 3230
 				try {
3231 3231
 					$sth = $this->db->prepare($query);
3232 3232
 					$sth->execute();
3233
-				} catch(PDOException $e) {
3233
+				} catch (PDOException $e) {
3234 3234
 					return "error : ".$e->getMessage();
3235 3235
 				}
3236 3236
 				echo 'Deleting old marine data...'."\n";
@@ -3242,14 +3242,14 @@  discard block
 block discarded – undo
3242 3242
 				try {
3243 3243
 					$sth = $this->db->prepare($query);
3244 3244
 					$sth->execute();
3245
-				} catch(PDOException $e) {
3245
+				} catch (PDOException $e) {
3246 3246
 					return "error : ".$e->getMessage();
3247 3247
 				}
3248 3248
 			}
3249 3249
 			if (!isset($lastyearupdate)) {
3250 3250
 				echo 'Insert last stats update date...'."\n";
3251 3251
 				date_default_timezone_set('UTC');
3252
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
3252
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
3253 3253
 			}
3254 3254
 			if ($globalStatsResetYear) {
3255 3255
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +715 added lines, -250 removed lines patch added patch discarded remove patch
@@ -15,10 +15,14 @@  discard block
 block discarded – undo
15 15
 	
16 16
 	public function __construct($dbc = null) {
17 17
 		global $globalFilterName;
18
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
18
+		if (isset($globalFilterName)) {
19
+			$this->filter_name = $globalFilterName;
20
+		}
19 21
 		$Connection = new Connection($dbc);
20 22
 		$this->db = $Connection->db();
21
-		if ($this->db === null) die('Error: No DB connection. (Stats)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Stats)');
25
+		}
22 26
 	}
23 27
 
24 28
 	public function addLastStatsUpdate($type,$stats_date) {
@@ -86,7 +90,9 @@  discard block
 block discarded – undo
86 90
 
87 91
 	public function getAllAirlineNames($filter_name = '') {
88 92
 		global $globalStatsFilters;
89
-		if ($filter_name == '') $filter_name = $this->filter_name;
93
+		if ($filter_name == '') {
94
+			$filter_name = $this->filter_name;
95
+		}
90 96
 		$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
91 97
 		 try {
92 98
 			$sth = $this->db->prepare($query);
@@ -106,7 +112,9 @@  discard block
 block discarded – undo
106 112
 		return $all;
107 113
 	}
108 114
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
109
-		if ($filter_name == '') $filter_name = $this->filter_name;
115
+		if ($filter_name == '') {
116
+			$filter_name = $this->filter_name;
117
+		}
110 118
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
111 119
 		try {
112 120
 			$sth = $this->db->prepare($query);
@@ -118,7 +126,9 @@  discard block
 block discarded – undo
118 126
 		return $all;
119 127
 	}
120 128
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
121
-		if ($filter_name == '') $filter_name = $this->filter_name;
129
+		if ($filter_name == '') {
130
+			$filter_name = $this->filter_name;
131
+		}
122 132
 		$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";
123 133
 		try {
124 134
 			$sth = $this->db->prepare($query);
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
 		return $all;
131 141
 	}
132 142
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
133
-		if ($filter_name == '') $filter_name = $this->filter_name;
143
+		if ($filter_name == '') {
144
+			$filter_name = $this->filter_name;
145
+		}
134 146
 		$query = "SELECT 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";
135 147
 		try {
136 148
 			$sth = $this->db->prepare($query);
@@ -143,7 +155,9 @@  discard block
 block discarded – undo
143 155
 	}
144 156
 
145 157
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
146
-		if ($filter_name == '') $filter_name = $this->filter_name;
158
+		if ($filter_name == '') {
159
+			$filter_name = $this->filter_name;
160
+		}
147 161
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
148 162
 		try {
149 163
 			$sth = $this->db->prepare($query);
@@ -156,7 +170,9 @@  discard block
 block discarded – undo
156 170
 	}
157 171
 
158 172
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
159
-		if ($filter_name == '') $filter_name = $this->filter_name;
173
+		if ($filter_name == '') {
174
+			$filter_name = $this->filter_name;
175
+		}
160 176
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
161 177
 		try {
162 178
 			$sth = $this->db->prepare($query);
@@ -171,7 +187,9 @@  discard block
 block discarded – undo
171 187
 
172 188
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
173 189
 		global $globalStatsFilters;
174
-		if ($filter_name == '') $filter_name = $this->filter_name;
190
+		if ($filter_name == '') {
191
+			$filter_name = $this->filter_name;
192
+		}
175 193
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
176 194
 			$Spotter = new Spotter($this->db);
177 195
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -180,8 +198,11 @@  discard block
 block discarded – undo
180 198
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
181 199
 			}
182 200
 			if ($year == '' && $month == '') {
183
-				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 aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
201
+				if ($limit) {
202
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
203
+				} else {
204
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
205
+				}
185 206
 				try {
186 207
 					$sth = $this->db->prepare($query);
187 208
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -189,11 +210,16 @@  discard block
 block discarded – undo
189 210
 					echo "error : ".$e->getMessage();
190 211
 				}
191 212
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-			} else $all = array();
213
+			} else {
214
+				$all = array();
215
+			}
193 216
 		} else {
194 217
 			if ($year == '' && $month == '') {
195
-				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 aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
196
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
218
+				if ($limit) {
219
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
220
+				} else {
221
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
222
+				}
197 223
 				try {
198 224
 					$sth = $this->db->prepare($query);
199 225
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -201,7 +227,9 @@  discard block
 block discarded – undo
201 227
 					echo "error : ".$e->getMessage();
202 228
 				}
203 229
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
204
-			} else $all = array();
230
+			} else {
231
+				$all = array();
232
+			}
205 233
 		}
206 234
 		if (empty($all)) {
207 235
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -220,10 +248,15 @@  discard block
 block discarded – undo
220 248
 	}
221 249
 	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
222 250
 		global $globalStatsFilters;
223
-		if ($filter_name == '') $filter_name = $this->filter_name;
251
+		if ($filter_name == '') {
252
+			$filter_name = $this->filter_name;
253
+		}
224 254
 		if ($year == '' && $month == '') {
225
-			if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
226
-			else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
255
+			if ($limit) {
256
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
257
+			} else {
258
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
259
+			}
227 260
 			try {
228 261
 				$sth = $this->db->prepare($query);
229 262
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -231,7 +264,9 @@  discard block
 block discarded – undo
231 264
 				echo "error : ".$e->getMessage();
232 265
 			}
233 266
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
234
-		} else $all = array();
267
+		} else {
268
+			$all = array();
269
+		}
235 270
 		if (empty($all)) {
236 271
 			$filters = array('year' => $year,'month' => $month);
237 272
 			if ($filter_name != '') {
@@ -245,10 +280,15 @@  discard block
 block discarded – undo
245 280
 	}
246 281
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
247 282
 		global $globalStatsFilters;
248
-		if ($filter_name == '') $filter_name = $this->filter_name;
283
+		if ($filter_name == '') {
284
+			$filter_name = $this->filter_name;
285
+		}
249 286
 		if ($year == '' && $month == '') {
250
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
251
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
287
+			if ($limit) {
288
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
289
+			} else {
290
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
291
+			}
252 292
 			try {
253 293
 				$sth = $this->db->prepare($query);
254 294
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -256,7 +296,9 @@  discard block
 block discarded – undo
256 296
 				echo "error : ".$e->getMessage();
257 297
 			}
258 298
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
259
-		} else $all = array();
299
+		} else {
300
+			$all = array();
301
+		}
260 302
 		if (empty($all)) {
261 303
 			$Spotter = new Spotter($this->db);
262 304
 			$filters = array();
@@ -271,7 +313,9 @@  discard block
 block discarded – undo
271 313
 	}
272 314
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
273 315
 		global $globalStatsFilters;
274
-		if ($filter_name == '') $filter_name = $this->filter_name;
316
+		if ($filter_name == '') {
317
+			$filter_name = $this->filter_name;
318
+		}
275 319
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
276 320
 			$Spotter = new Spotter($this->db);
277 321
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -280,8 +324,11 @@  discard block
 block discarded – undo
280 324
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
281 325
 			}
282 326
 			if ($year == '' && $month == '') {
283
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
284
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
327
+				if ($limit) {
328
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
329
+				} else {
330
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
331
+				}
285 332
 				try {
286 333
 					$sth = $this->db->prepare($query);
287 334
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -289,11 +336,16 @@  discard block
 block discarded – undo
289 336
 					echo "error : ".$e->getMessage();
290 337
 				}
291 338
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
292
-			} else $all = array();
339
+			} else {
340
+				$all = array();
341
+			}
293 342
 		} else {
294 343
 			if ($year == '' && $month == '') {
295
-				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";
296
-				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";
344
+				if ($limit) {
345
+					$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";
346
+				} else {
347
+					$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";
348
+				}
297 349
 				try {
298 350
 					$sth = $this->db->prepare($query);
299 351
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -301,7 +353,9 @@  discard block
 block discarded – undo
301 353
 					echo "error : ".$e->getMessage();
302 354
 				}
303 355
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
304
-			} else $all = array();
356
+			} else {
357
+				$all = array();
358
+			}
305 359
 		}
306 360
 		if (empty($all)) {
307 361
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -321,7 +375,9 @@  discard block
 block discarded – undo
321 375
 
322 376
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
323 377
 		global $globalStatsFilters;
324
-		if ($filter_name == '') $filter_name = $this->filter_name;
378
+		if ($filter_name == '') {
379
+			$filter_name = $this->filter_name;
380
+		}
325 381
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
326 382
 			$Spotter = new Spotter($this->db);
327 383
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -330,8 +386,11 @@  discard block
 block discarded – undo
330 386
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
331 387
 			}
332 388
 			if ($year == '' && $month == '') {
333
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
334
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
389
+				if ($limit) {
390
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
391
+				} else {
392
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
393
+				}
335 394
 				try {
336 395
 					$sth = $this->db->prepare($query);
337 396
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -339,11 +398,16 @@  discard block
 block discarded – undo
339 398
 					echo "error : ".$e->getMessage();
340 399
 				}
341 400
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
342
-			} else $all = array();
401
+			} else {
402
+				$all = array();
403
+			}
343 404
 		} else {
344 405
 			if ($year == '' && $month == '') {
345
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
346
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
406
+				if ($limit) {
407
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
408
+				} else {
409
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
410
+				}
347 411
 				try {
348 412
 					$sth = $this->db->prepare($query);
349 413
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -351,7 +415,9 @@  discard block
 block discarded – undo
351 415
 					echo "error : ".$e->getMessage();
352 416
 				}
353 417
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
354
-			} else $all = array();
418
+			} else {
419
+				$all = array();
420
+			}
355 421
 		}
356 422
 		if (empty($all)) {
357 423
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -370,7 +436,9 @@  discard block
 block discarded – undo
370 436
 	}
371 437
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
372 438
 		global $globalStatsFilters;
373
-		if ($filter_name == '') $filter_name = $this->filter_name;
439
+		if ($filter_name == '') {
440
+			$filter_name = $this->filter_name;
441
+		}
374 442
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
375 443
 			$Spotter = new Spotter($this->db);
376 444
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -378,12 +446,18 @@  discard block
 block discarded – undo
378 446
 			foreach ($airlines as $airline) {
379 447
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
380 448
 			}
381
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
382
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
449
+			if ($limit) {
450
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
451
+			} else {
452
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
453
+			}
383 454
 			$query_values = array(':filter_name' => $filter_name);
384 455
 		} else {
385
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
386
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
456
+			if ($limit) {
457
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
458
+			} else {
459
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
460
+			}
387 461
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
388 462
 		}
389 463
 		try {
@@ -411,17 +485,29 @@  discard block
 block discarded – undo
411 485
 
412 486
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
413 487
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
414
-		if ($filter_name == '') $filter_name = $this->filter_name;
488
+		if ($filter_name == '') {
489
+			$filter_name = $this->filter_name;
490
+		}
415 491
 		if ($year == '' && $month == '') {
416
-			if ($globalVATSIM) $forsource = 'vatsim';
417
-			if ($globalIVAO) $forsource = 'ivao';
492
+			if ($globalVATSIM) {
493
+				$forsource = 'vatsim';
494
+			}
495
+			if ($globalIVAO) {
496
+				$forsource = 'ivao';
497
+			}
418 498
 			if (isset($forsource)) {
419
-				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";
420
-				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";
499
+				if ($limit) {
500
+					$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";
501
+				} else {
502
+					$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";
503
+				}
421 504
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
422 505
 			} else {
423
-				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";
424
-				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";
506
+				if ($limit) {
507
+					$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";
508
+				} else {
509
+					$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";
510
+				}
425 511
 				$query_values = array(':filter_name' => $filter_name);
426 512
 			}
427 513
 			try {
@@ -431,7 +517,9 @@  discard block
 block discarded – undo
431 517
 				echo "error : ".$e->getMessage();
432 518
 			}
433 519
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
434
-		} else $all = array();
520
+		} else {
521
+			$all = array();
522
+		}
435 523
                 if (empty($all)) {
436 524
 	                $Spotter = new Spotter($this->db);
437 525
             		$filters = array();
@@ -446,7 +534,9 @@  discard block
 block discarded – undo
446 534
 	}
447 535
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
448 536
 		global $globalStatsFilters;
449
-		if ($filter_name == '') $filter_name = $this->filter_name;
537
+		if ($filter_name == '') {
538
+			$filter_name = $this->filter_name;
539
+		}
450 540
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
451 541
 			$Spotter = new Spotter($this->db);
452 542
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -455,8 +545,11 @@  discard block
 block discarded – undo
455 545
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
456 546
 			}
457 547
 			if ($year == '' && $month == '') {
458
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
459
-				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
548
+				if ($limit) {
549
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
550
+				} else {
551
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
552
+				}
460 553
 				try {
461 554
 					$sth = $this->db->prepare($query);
462 555
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -464,11 +557,16 @@  discard block
 block discarded – undo
464 557
 					echo "error : ".$e->getMessage();
465 558
 				}
466 559
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
467
-			} else $all = array();
560
+			} else {
561
+				$all = array();
562
+			}
468 563
 		} else {
469 564
 			if ($year == '' && $month == '') {
470
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC LIMIT 10 OFFSET 0";
471
-				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC";
565
+				if ($limit) {
566
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC LIMIT 10 OFFSET 0";
567
+				} else {
568
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC";
569
+				}
472 570
 				try {
473 571
 					$sth = $this->db->prepare($query);
474 572
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -476,7 +574,9 @@  discard block
 block discarded – undo
476 574
 					echo "error : ".$e->getMessage();
477 575
 				}
478 576
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
479
-			} else $all = array();
577
+			} else {
578
+				$all = array();
579
+			}
480 580
 		}
481 581
 		if (empty($all)) {
482 582
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -495,7 +595,9 @@  discard block
 block discarded – undo
495 595
 	}
496 596
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
497 597
 		global $globalStatsFilters;
498
-		if ($filter_name == '') $filter_name = $this->filter_name;
598
+		if ($filter_name == '') {
599
+			$filter_name = $this->filter_name;
600
+		}
499 601
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
500 602
 			$Spotter = new Spotter($this->db);
501 603
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -504,8 +606,11 @@  discard block
 block discarded – undo
504 606
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
505 607
 			}
506 608
 			if ($year == '' && $month == '') {
507
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
508
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
609
+				if ($limit) {
610
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
611
+				} else {
612
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
613
+				}
509 614
 				 try {
510 615
 					$sth = $this->db->prepare($query);
511 616
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -513,11 +618,16 @@  discard block
 block discarded – undo
513 618
 					echo "error : ".$e->getMessage();
514 619
 				}
515 620
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
516
-			} else $all = array();
621
+			} else {
622
+				$all = array();
623
+			}
517 624
 		} else {
518 625
 			if ($year == '' && $month == '') {
519
-				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";
520
-				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";
626
+				if ($limit) {
627
+					$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";
628
+				} else {
629
+					$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";
630
+				}
521 631
 				 try {
522 632
 					$sth = $this->db->prepare($query);
523 633
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -525,7 +635,9 @@  discard block
 block discarded – undo
525 635
 					echo "error : ".$e->getMessage();
526 636
 				}
527 637
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
528
-			} else $all = array();
638
+			} else {
639
+				$all = array();
640
+			}
529 641
 		}
530 642
 		if (empty($all)) {
531 643
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -544,7 +656,9 @@  discard block
 block discarded – undo
544 656
 	}
545 657
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
546 658
 		$Connection = new Connection($this->db);
547
-		if ($filter_name == '') $filter_name = $this->filter_name;
659
+		if ($filter_name == '') {
660
+			$filter_name = $this->filter_name;
661
+		}
548 662
 		if ($Connection->tableExists('countries')) {
549 663
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
550 664
 				$Spotter = new Spotter($this->db);
@@ -554,8 +668,11 @@  discard block
 block discarded – undo
554 668
 					foreach ($airlines as $airline) {
555 669
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
556 670
 					}
557
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
558
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
671
+					if ($limit) {
672
+						$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
673
+					} else {
674
+						$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
675
+					}
559 676
 					 try {
560 677
 						$sth = $this->db->prepare($query);
561 678
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -564,11 +681,16 @@  discard block
 block discarded – undo
564 681
 					}
565 682
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
566 683
 					return $all;
567
-				} else return array();
684
+				} else {
685
+					return array();
686
+				}
568 687
 			} else {
569 688
 				if ($year == '' && $month == '') {
570
-					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";
571
-					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";
689
+					if ($limit) {
690
+						$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";
691
+					} else {
692
+						$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";
693
+					}
572 694
 					 try {
573 695
 						$sth = $this->db->prepare($query);
574 696
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -577,20 +699,29 @@  discard block
 block discarded – undo
577 699
 					}
578 700
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
579 701
 					return $all;
580
-				} else return array();
702
+				} else {
703
+					return array();
704
+				}
581 705
 			}
582 706
 			$Spotter = new Spotter($this->db);
583 707
 			return $Spotter->countAllFlightOverCountries($limit);
584
-		} else return array();
708
+		} else {
709
+			return array();
710
+		}
585 711
 	}
586 712
 	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
587 713
 		$Connection = new Connection($this->db);
588
-		if ($filter_name == '') $filter_name = $this->filter_name;
714
+		if ($filter_name == '') {
715
+			$filter_name = $this->filter_name;
716
+		}
589 717
 		if ($Connection->tableExists('countries')) {
590 718
 			$all = array();
591 719
 			if ($year == '' && $month == '') {
592
-				if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
593
-				else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
720
+				if ($limit) {
721
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
722
+				} else {
723
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
724
+				}
594 725
 				 try {
595 726
 					$sth = $this->db->prepare($query);
596 727
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -608,16 +739,23 @@  discard block
 block discarded – undo
608 739
 				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
609 740
 			}
610 741
 			return $all;
611
-		} else return array();
742
+		} else {
743
+			return array();
744
+		}
612 745
 	}
613 746
 	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
614 747
 		$Connection = new Connection($this->db);
615
-		if ($filter_name == '') $filter_name = $this->filter_name;
748
+		if ($filter_name == '') {
749
+			$filter_name = $this->filter_name;
750
+		}
616 751
 		if ($Connection->tableExists('countries')) {
617 752
 			$all = array();
618 753
 			if ($year == '' && $month == '') {
619
-				if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
620
-				else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
754
+				if ($limit) {
755
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
756
+				} else {
757
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
758
+				}
621 759
 				 try {
622 760
 					$sth = $this->db->prepare($query);
623 761
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -636,14 +774,21 @@  discard block
 block discarded – undo
636 774
 				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
637 775
 			}
638 776
 			return $all;
639
-		} else return array();
777
+		} else {
778
+			return array();
779
+		}
640 780
 	}
641 781
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
642 782
 		global $globalStatsFilters;
643
-		if ($filter_name == '') $filter_name = $this->filter_name;
783
+		if ($filter_name == '') {
784
+			$filter_name = $this->filter_name;
785
+		}
644 786
 		if ($year == '' && $month == '') {
645
-			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";
646
-			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";
787
+			if ($limit) {
788
+				$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";
789
+			} else {
790
+				$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";
791
+			}
647 792
 			try {
648 793
 				$sth = $this->db->prepare($query);
649 794
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -651,7 +796,9 @@  discard block
 block discarded – undo
651 796
 				echo "error : ".$e->getMessage();
652 797
 			}
653 798
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
654
-		} else $all = array();
799
+		} else {
800
+			$all = array();
801
+		}
655 802
 		if (empty($all)) {
656 803
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
657 804
 			if ($filter_name != '') {
@@ -666,7 +813,9 @@  discard block
 block discarded – undo
666 813
 
667 814
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
668 815
 		global $globalStatsFilters;
669
-		if ($filter_name == '') $filter_name = $this->filter_name;
816
+		if ($filter_name == '') {
817
+			$filter_name = $this->filter_name;
818
+		}
670 819
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
671 820
 			$Spotter = new Spotter($this->db);
672 821
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -675,8 +824,11 @@  discard block
 block discarded – undo
675 824
 				foreach ($airlines as $airline) {
676 825
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
677 826
 				}
678
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
679
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
827
+				if ($limit) {
828
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
829
+				} else {
830
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
831
+				}
680 832
 				try {
681 833
 					$sth = $this->db->prepare($query);
682 834
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -684,11 +836,16 @@  discard block
 block discarded – undo
684 836
 					echo "error : ".$e->getMessage();
685 837
 				}
686 838
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
687
-			} else $all = array();
839
+			} else {
840
+				$all = array();
841
+			}
688 842
 		} else {
689 843
 			if ($year == '' && $month == '') {
690
-				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";
691
-				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";
844
+				if ($limit) {
845
+					$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";
846
+				} else {
847
+					$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";
848
+				}
692 849
 				try {
693 850
 					$sth = $this->db->prepare($query);
694 851
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -696,7 +853,9 @@  discard block
 block discarded – undo
696 853
 					echo "error : ".$e->getMessage();
697 854
 				}
698 855
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
699
-			} else $all = array();
856
+			} else {
857
+				$all = array();
858
+			}
700 859
 		}
701 860
 		if (empty($all)) {
702 861
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -715,7 +874,9 @@  discard block
 block discarded – undo
715 874
 	}
716 875
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
717 876
 		global $globalStatsFilters;
718
-		if ($filter_name == '') $filter_name = $this->filter_name;
877
+		if ($filter_name == '') {
878
+			$filter_name = $this->filter_name;
879
+		}
719 880
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
720 881
 			$Spotter = new Spotter($this->db);
721 882
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -724,8 +885,11 @@  discard block
 block discarded – undo
724 885
 				foreach ($airlines as $airline) {
725 886
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
726 887
 				}
727
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
728
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
888
+				if ($limit) {
889
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
890
+				} else {
891
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
892
+				}
729 893
 				try {
730 894
 					$sth = $this->db->prepare($query);
731 895
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -733,11 +897,16 @@  discard block
 block discarded – undo
733 897
 					echo "error : ".$e->getMessage();
734 898
 				}
735 899
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
736
-			} else $all = array();
900
+			} else {
901
+				$all = array();
902
+			}
737 903
 		} else {
738 904
 			if ($year == '' && $month == '') {
739
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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";
740
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
905
+				if ($limit) {
906
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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";
907
+				} else {
908
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
909
+				}
741 910
 				try {
742 911
 					$sth = $this->db->prepare($query);
743 912
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -745,7 +914,9 @@  discard block
 block discarded – undo
745 914
 					echo "error : ".$e->getMessage();
746 915
 				}
747 916
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
748
-			} else $all = array();
917
+			} else {
918
+				$all = array();
919
+			}
749 920
 		}
750 921
 		if (empty($all)) {
751 922
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -770,7 +941,9 @@  discard block
 block discarded – undo
770 941
 				$icao = $value['airport_departure_icao'];
771 942
 				if (isset($all[$icao])) {
772 943
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
773
-				} else $all[$icao] = $value;
944
+				} else {
945
+					$all[$icao] = $value;
946
+				}
774 947
 			}
775 948
 			$count = array();
776 949
 			foreach ($all as $key => $row) {
@@ -782,7 +955,9 @@  discard block
 block discarded – undo
782 955
 	}
783 956
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
784 957
 		global $globalStatsFilters;
785
-		if ($filter_name == '') $filter_name = $this->filter_name;
958
+		if ($filter_name == '') {
959
+			$filter_name = $this->filter_name;
960
+		}
786 961
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
787 962
 			$Spotter = new Spotter($this->db);
788 963
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -791,8 +966,11 @@  discard block
 block discarded – undo
791 966
 				foreach ($airlines as $airline) {
792 967
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
793 968
 				}
794
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
795
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
969
+				if ($limit) {
970
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
971
+				} else {
972
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
973
+				}
796 974
 				try {
797 975
 					$sth = $this->db->prepare($query);
798 976
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -800,11 +978,16 @@  discard block
 block discarded – undo
800 978
 					echo "error : ".$e->getMessage();
801 979
 				}
802 980
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
803
-			} else $all = array();
981
+			} else {
982
+				$all = array();
983
+			}
804 984
 		} else {
805 985
 			if ($year == '' && $month == '') {
806
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND 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";
807
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
986
+				if ($limit) {
987
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND 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";
988
+				} else {
989
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
990
+				}
808 991
 				try {
809 992
 					$sth = $this->db->prepare($query);
810 993
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -812,7 +995,9 @@  discard block
 block discarded – undo
812 995
 					echo "error : ".$e->getMessage();
813 996
 				}
814 997
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
815
-			} else $all = array();
998
+			} else {
999
+				$all = array();
1000
+			}
816 1001
 		}
817 1002
 		if (empty($all)) {
818 1003
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -837,7 +1022,9 @@  discard block
 block discarded – undo
837 1022
 				$icao = $value['airport_arrival_icao'];
838 1023
 				if (isset($all[$icao])) {
839 1024
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
840
-				} else $all[$icao] = $value;
1025
+				} else {
1026
+					$all[$icao] = $value;
1027
+				}
841 1028
 			}
842 1029
 			$count = array();
843 1030
 			foreach ($all as $key => $row) {
@@ -849,7 +1036,9 @@  discard block
 block discarded – undo
849 1036
 	}
850 1037
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
851 1038
 		global $globalDBdriver, $globalStatsFilters;
852
-		if ($filter_name == '') $filter_name = $this->filter_name;
1039
+		if ($filter_name == '') {
1040
+			$filter_name = $this->filter_name;
1041
+		}
853 1042
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
854 1043
 			$Spotter = new Spotter($this->db);
855 1044
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -858,20 +1047,32 @@  discard block
 block discarded – undo
858 1047
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
859 1048
 			}
860 1049
 			if ($globalDBdriver == 'mysql') {
861
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
862
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1050
+				if ($limit) {
1051
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1052
+				} else {
1053
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1054
+				}
863 1055
 			} else {
864
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
865
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1056
+				if ($limit) {
1057
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1058
+				} else {
1059
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1060
+				}
866 1061
 			}
867 1062
 			$query_data = array(':filter_name' => $filter_name);
868 1063
 		} else {
869 1064
 			if ($globalDBdriver == 'mysql') {
870
-				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";
871
-				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";
1065
+				if ($limit) {
1066
+					$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";
1067
+				} else {
1068
+					$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";
1069
+				}
872 1070
 			} else {
873
-				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";
874
-				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";
1071
+				if ($limit) {
1072
+					$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";
1073
+				} else {
1074
+					$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";
1075
+				}
875 1076
 			}
876 1077
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
877 1078
 		}
@@ -899,7 +1100,9 @@  discard block
 block discarded – undo
899 1100
 	
900 1101
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
901 1102
 		global $globalStatsFilters;
902
-		if ($filter_name == '') $filter_name = $this->filter_name;
1103
+		if ($filter_name == '') {
1104
+			$filter_name = $this->filter_name;
1105
+		}
903 1106
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
904 1107
 			$Spotter = new Spotter($this->db);
905 1108
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -936,7 +1139,9 @@  discard block
 block discarded – undo
936 1139
 	}
937 1140
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
938 1141
 		global $globalDBdriver, $globalStatsFilters;
939
-		if ($filter_name == '') $filter_name = $this->filter_name;
1142
+		if ($filter_name == '') {
1143
+			$filter_name = $this->filter_name;
1144
+		}
940 1145
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
941 1146
 			$Spotter = new Spotter($this->db);
942 1147
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -981,7 +1186,9 @@  discard block
 block discarded – undo
981 1186
 	}
982 1187
 	public function countAllDates($stats_airline = '',$filter_name = '') {
983 1188
 		global $globalStatsFilters;
984
-		if ($filter_name == '') $filter_name = $this->filter_name;
1189
+		if ($filter_name == '') {
1190
+			$filter_name = $this->filter_name;
1191
+		}
985 1192
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
986 1193
 			$Spotter = new Spotter($this->db);
987 1194
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1018,7 +1225,9 @@  discard block
 block discarded – undo
1018 1225
 	}
1019 1226
 	public function countAllDatesMarine($filter_name = '') {
1020 1227
 		global $globalStatsFilters;
1021
-		if ($filter_name == '') $filter_name = $this->filter_name;
1228
+		if ($filter_name == '') {
1229
+			$filter_name = $this->filter_name;
1230
+		}
1022 1231
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1023 1232
 		$query_data = array(':filter_name' => $filter_name);
1024 1233
 		try {
@@ -1040,7 +1249,9 @@  discard block
 block discarded – undo
1040 1249
 	}
1041 1250
 	public function countAllDatesTracker($filter_name = '') {
1042 1251
 		global $globalStatsFilters;
1043
-		if ($filter_name == '') $filter_name = $this->filter_name;
1252
+		if ($filter_name == '') {
1253
+			$filter_name = $this->filter_name;
1254
+		}
1044 1255
 		$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1045 1256
 		$query_data = array(':filter_name' => $filter_name);
1046 1257
 		try {
@@ -1062,7 +1273,9 @@  discard block
 block discarded – undo
1062 1273
 	}
1063 1274
 	public function countAllDatesByAirlines($filter_name = '') {
1064 1275
 		global $globalStatsFilters;
1065
-		if ($filter_name == '') $filter_name = $this->filter_name;
1276
+		if ($filter_name == '') {
1277
+			$filter_name = $this->filter_name;
1278
+		}
1066 1279
 		$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";
1067 1280
 		$query_data = array('filter_name' => $filter_name);
1068 1281
 		try {
@@ -1084,7 +1297,9 @@  discard block
 block discarded – undo
1084 1297
 	}
1085 1298
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
1086 1299
 		global $globalStatsFilters, $globalDBdriver;
1087
-		if ($filter_name == '') $filter_name = $this->filter_name;
1300
+		if ($filter_name == '') {
1301
+			$filter_name = $this->filter_name;
1302
+		}
1088 1303
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1089 1304
 			$Spotter = new Spotter($this->db);
1090 1305
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1169,7 +1384,9 @@  discard block
 block discarded – undo
1169 1384
 	}
1170 1385
 	public function countAllMilitaryMonths($filter_name = '') {
1171 1386
 		global $globalStatsFilters;
1172
-		if ($filter_name == '') $filter_name = $this->filter_name;
1387
+		if ($filter_name == '') {
1388
+			$filter_name = $this->filter_name;
1389
+		}
1173 1390
 		$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";
1174 1391
 		try {
1175 1392
 			$sth = $this->db->prepare($query);
@@ -1190,7 +1407,9 @@  discard block
 block discarded – undo
1190 1407
 	}
1191 1408
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1192 1409
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1193
-		if ($filter_name == '') $filter_name = $this->filter_name;
1410
+		if ($filter_name == '') {
1411
+			$filter_name = $this->filter_name;
1412
+		}
1194 1413
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1195 1414
 			$Spotter = new Spotter($this->db);
1196 1415
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1198,12 +1417,18 @@  discard block
 block discarded – undo
1198 1417
 			foreach ($airlines as $airline) {
1199 1418
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1200 1419
 			}
1201
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1202
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1420
+			if ($limit) {
1421
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1422
+			} else {
1423
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1424
+			}
1203 1425
 			$query_data = array(':filter_name' => $filter_name);
1204 1426
 		} else {
1205
-			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";
1206
-			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";
1427
+			if ($limit) {
1428
+				$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";
1429
+			} else {
1430
+				$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";
1431
+			}
1207 1432
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1208 1433
 		}
1209 1434
 		if ($orderby == 'hour') {
@@ -1213,7 +1438,9 @@  discard block
 block discarded – undo
1213 1438
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1214 1439
 			}
1215 1440
 		}
1216
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1441
+		if ($orderby == 'count') {
1442
+			$query .= " ORDER BY hour_count DESC";
1443
+		}
1217 1444
 		try {
1218 1445
 			$sth = $this->db->prepare($query);
1219 1446
 			$sth->execute($query_data);
@@ -1237,8 +1464,12 @@  discard block
 block discarded – undo
1237 1464
 	}
1238 1465
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1239 1466
 		global $globalStatsFilters;
1240
-		if ($filter_name == '') $filter_name = $this->filter_name;
1241
-		if ($year == '') $year = date('Y');
1467
+		if ($filter_name == '') {
1468
+			$filter_name = $this->filter_name;
1469
+		}
1470
+		if ($year == '') {
1471
+			$year = date('Y');
1472
+		}
1242 1473
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1243 1474
 		if (empty($all)) {
1244 1475
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1257,8 +1488,12 @@  discard block
 block discarded – undo
1257 1488
 	}
1258 1489
 	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1259 1490
 		global $globalStatsFilters;
1260
-		if ($filter_name == '') $filter_name = $this->filter_name;
1261
-		if ($year == '') $year = date('Y');
1491
+		if ($filter_name == '') {
1492
+			$filter_name = $this->filter_name;
1493
+		}
1494
+		if ($year == '') {
1495
+			$year = date('Y');
1496
+		}
1262 1497
 		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1263 1498
 		if (empty($all)) {
1264 1499
 			$filters = array('year' => $year,'month' => $month);
@@ -1273,8 +1508,12 @@  discard block
 block discarded – undo
1273 1508
 	}
1274 1509
 	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1275 1510
 		global $globalStatsFilters;
1276
-		if ($filter_name == '') $filter_name = $this->filter_name;
1277
-		if ($year == '') $year = date('Y');
1511
+		if ($filter_name == '') {
1512
+			$filter_name = $this->filter_name;
1513
+		}
1514
+		if ($year == '') {
1515
+			$year = date('Y');
1516
+		}
1278 1517
 		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1279 1518
 		if (empty($all)) {
1280 1519
 			$filters = array('year' => $year,'month' => $month);
@@ -1289,8 +1528,12 @@  discard block
 block discarded – undo
1289 1528
 	}
1290 1529
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1291 1530
 		global $globalStatsFilters;
1292
-		if ($filter_name == '') $filter_name = $this->filter_name;
1293
-		if ($year == '') $year = date('Y');
1531
+		if ($filter_name == '') {
1532
+			$filter_name = $this->filter_name;
1533
+		}
1534
+		if ($year == '') {
1535
+			$year = date('Y');
1536
+		}
1294 1537
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1295 1538
 		if (empty($all)) {
1296 1539
 			$filters = array();
@@ -1306,8 +1549,12 @@  discard block
 block discarded – undo
1306 1549
 	}
1307 1550
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1308 1551
 		global $globalStatsFilters;
1309
-		if ($filter_name == '') $filter_name = $this->filter_name;
1310
-		if ($year == '') $year = date('Y');
1552
+		if ($filter_name == '') {
1553
+			$filter_name = $this->filter_name;
1554
+		}
1555
+		if ($year == '') {
1556
+			$year = date('Y');
1557
+		}
1311 1558
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1312 1559
 		if (empty($all)) {
1313 1560
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1326,7 +1573,9 @@  discard block
 block discarded – undo
1326 1573
 	}
1327 1574
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1328 1575
 		global $globalStatsFilters;
1329
-		if ($filter_name == '') $filter_name = $this->filter_name;
1576
+		if ($filter_name == '') {
1577
+			$filter_name = $this->filter_name;
1578
+		}
1330 1579
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1331 1580
 			$Spotter = new Spotter($this->db);
1332 1581
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1344,7 +1593,9 @@  discard block
 block discarded – undo
1344 1593
 				}
1345 1594
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1346 1595
 				$all = $result[0]['nb'];
1347
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1596
+			} else {
1597
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1598
+			}
1348 1599
 		} else {
1349 1600
 			if ($year == '' && $month == '') {
1350 1601
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1356,7 +1607,9 @@  discard block
 block discarded – undo
1356 1607
 				}
1357 1608
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1358 1609
 				$all = $result[0]['nb'];
1359
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1610
+			} else {
1611
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1612
+			}
1360 1613
 		}
1361 1614
 		if (empty($all)) {
1362 1615
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1375,7 +1628,9 @@  discard block
 block discarded – undo
1375 1628
 	}
1376 1629
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1377 1630
 		global $globalStatsFilters;
1378
-		if ($filter_name == '') $filter_name = $this->filter_name;
1631
+		if ($filter_name == '') {
1632
+			$filter_name = $this->filter_name;
1633
+		}
1379 1634
 		if ($year == '' && $month == '') {
1380 1635
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1381 1636
 			try {
@@ -1386,7 +1641,9 @@  discard block
 block discarded – undo
1386 1641
 			}
1387 1642
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1388 1643
 			$all = $result[0]['nb_airline'];
1389
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1644
+		} else {
1645
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1646
+		}
1390 1647
 		if (empty($all)) {
1391 1648
 			$filters = array();
1392 1649
 			$filters = array('year' => $year,'month' => $month);
@@ -1401,7 +1658,9 @@  discard block
 block discarded – undo
1401 1658
 	}
1402 1659
 	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1403 1660
 		global $globalStatsFilters;
1404
-		if ($filter_name == '') $filter_name = $this->filter_name;
1661
+		if ($filter_name == '') {
1662
+			$filter_name = $this->filter_name;
1663
+		}
1405 1664
 		$all = array();
1406 1665
 		if ($year == '' && $month == '') {
1407 1666
 			$query = "SELECT SUM(cnt) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name";
@@ -1428,7 +1687,9 @@  discard block
 block discarded – undo
1428 1687
 	}
1429 1688
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1430 1689
 		global $globalStatsFilters;
1431
-		if ($filter_name == '') $filter_name = $this->filter_name;
1690
+		if ($filter_name == '') {
1691
+			$filter_name = $this->filter_name;
1692
+		}
1432 1693
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1433 1694
 			$Spotter = new Spotter($this->db);
1434 1695
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1483,7 +1744,9 @@  discard block
 block discarded – undo
1483 1744
 	}
1484 1745
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1485 1746
 		global $globalStatsFilters;
1486
-		if ($filter_name == '') $filter_name = $this->filter_name;
1747
+		if ($filter_name == '') {
1748
+			$filter_name = $this->filter_name;
1749
+		}
1487 1750
 		//if ($year == '') $year = date('Y');
1488 1751
 		if ($year == '' && $month == '') {
1489 1752
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1512,7 +1775,9 @@  discard block
 block discarded – undo
1512 1775
 	}
1513 1776
 
1514 1777
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1515
-		if ($filter_name == '') $filter_name = $this->filter_name;
1778
+		if ($filter_name == '') {
1779
+			$filter_name = $this->filter_name;
1780
+		}
1516 1781
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1517 1782
 			$Spotter = new Spotter($this->db);
1518 1783
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1536,7 +1801,9 @@  discard block
 block discarded – undo
1536 1801
 		return $all;
1537 1802
 	}
1538 1803
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1539
-		if ($filter_name == '') $filter_name = $this->filter_name;
1804
+		if ($filter_name == '') {
1805
+			$filter_name = $this->filter_name;
1806
+		}
1540 1807
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1541 1808
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1542 1809
 		try {
@@ -1549,7 +1816,9 @@  discard block
 block discarded – undo
1549 1816
 		return $all;
1550 1817
 	}
1551 1818
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1552
-		if ($filter_name == '') $filter_name = $this->filter_name;
1819
+		if ($filter_name == '') {
1820
+			$filter_name = $this->filter_name;
1821
+		}
1553 1822
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1554 1823
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1555 1824
 		try {
@@ -1560,7 +1829,9 @@  discard block
 block discarded – undo
1560 1829
 		}
1561 1830
 	}
1562 1831
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1563
-		if ($filter_name == '') $filter_name = $this->filter_name;
1832
+		if ($filter_name == '') {
1833
+			$filter_name = $this->filter_name;
1834
+		}
1564 1835
 		global $globalArchiveMonths, $globalDBdriver;
1565 1836
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1566 1837
 			$Spotter = new Spotter($this->db);
@@ -1616,7 +1887,9 @@  discard block
 block discarded – undo
1616 1887
 	}
1617 1888
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1618 1889
 		global $globalArchiveMonths, $globalDBdriver;
1619
-		if ($filter_name == '') $filter_name = $this->filter_name;
1890
+		if ($filter_name == '') {
1891
+			$filter_name = $this->filter_name;
1892
+		}
1620 1893
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1621 1894
 			$Spotter = new Spotter($this->db);
1622 1895
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1649,7 +1922,9 @@  discard block
 block discarded – undo
1649 1922
 	}
1650 1923
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1651 1924
 		global $globalArchiveMonths, $globalDBdriver;
1652
-		if ($filter_name == '') $filter_name = $this->filter_name;
1925
+		if ($filter_name == '') {
1926
+			$filter_name = $this->filter_name;
1927
+		}
1653 1928
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1654 1929
 			$Spotter = new Spotter($this->db);
1655 1930
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1680,7 +1955,9 @@  discard block
 block discarded – undo
1680 1955
 	}
1681 1956
 	public function getStatsAirlineTotal($filter_name = '') {
1682 1957
 		global $globalArchiveMonths, $globalDBdriver;
1683
-		if ($filter_name == '') $filter_name = $this->filter_name;
1958
+		if ($filter_name == '') {
1959
+			$filter_name = $this->filter_name;
1960
+		}
1684 1961
 		if ($globalDBdriver == 'mysql') {
1685 1962
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1686 1963
 		} else {
@@ -1697,7 +1974,9 @@  discard block
 block discarded – undo
1697 1974
 	}
1698 1975
 	public function getStatsOwnerTotal($filter_name = '') {
1699 1976
 		global $globalArchiveMonths, $globalDBdriver;
1700
-		if ($filter_name == '') $filter_name = $this->filter_name;
1977
+		if ($filter_name == '') {
1978
+			$filter_name = $this->filter_name;
1979
+		}
1701 1980
 		if ($globalDBdriver == 'mysql') {
1702 1981
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1703 1982
 		} else {
@@ -1714,7 +1993,9 @@  discard block
 block discarded – undo
1714 1993
 	}
1715 1994
 	public function getStatsOwner($owner_name,$filter_name = '') {
1716 1995
 		global $globalArchiveMonths, $globalDBdriver;
1717
-		if ($filter_name == '') $filter_name = $this->filter_name;
1996
+		if ($filter_name == '') {
1997
+			$filter_name = $this->filter_name;
1998
+		}
1718 1999
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1719 2000
 		try {
1720 2001
 			$sth = $this->db->prepare($query);
@@ -1723,12 +2004,17 @@  discard block
 block discarded – undo
1723 2004
 			echo "error : ".$e->getMessage();
1724 2005
 		}
1725 2006
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1726
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1727
-		else return 0;
2007
+		if (isset($all[0]['cnt'])) {
2008
+			return $all[0]['cnt'];
2009
+		} else {
2010
+			return 0;
2011
+		}
1728 2012
 	}
1729 2013
 	public function getStatsPilotTotal($filter_name = '') {
1730 2014
 		global $globalArchiveMonths, $globalDBdriver;
1731
-		if ($filter_name == '') $filter_name = $this->filter_name;
2015
+		if ($filter_name == '') {
2016
+			$filter_name = $this->filter_name;
2017
+		}
1732 2018
 		if ($globalDBdriver == 'mysql') {
1733 2019
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1734 2020
 		} else {
@@ -1745,7 +2031,9 @@  discard block
 block discarded – undo
1745 2031
 	}
1746 2032
 	public function getStatsPilot($pilot,$filter_name = '') {
1747 2033
 		global $globalArchiveMonths, $globalDBdriver;
1748
-		if ($filter_name == '') $filter_name = $this->filter_name;
2034
+		if ($filter_name == '') {
2035
+			$filter_name = $this->filter_name;
2036
+		}
1749 2037
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1750 2038
 		try {
1751 2039
 			$sth = $this->db->prepare($query);
@@ -1754,13 +2042,18 @@  discard block
 block discarded – undo
1754 2042
 			echo "error : ".$e->getMessage();
1755 2043
 		}
1756 2044
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1757
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1758
-		else return 0;
2045
+		if (isset($all[0]['cnt'])) {
2046
+			return $all[0]['cnt'];
2047
+		} else {
2048
+			return 0;
2049
+		}
1759 2050
 	}
1760 2051
 
1761 2052
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1762 2053
 		global $globalDBdriver;
1763
-		if ($filter_name == '') $filter_name = $this->filter_name;
2054
+		if ($filter_name == '') {
2055
+			$filter_name = $this->filter_name;
2056
+		}
1764 2057
 		if ($globalDBdriver == 'mysql') {
1765 2058
 			$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";
1766 2059
 		} else {
@@ -1776,7 +2069,9 @@  discard block
 block discarded – undo
1776 2069
 	}
1777 2070
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1778 2071
 		global $globalDBdriver;
1779
-		if ($filter_name == '') $filter_name = $this->filter_name;
2072
+		if ($filter_name == '') {
2073
+			$filter_name = $this->filter_name;
2074
+		}
1780 2075
 		if ($globalDBdriver == 'mysql') {
1781 2076
 			$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";
1782 2077
 		} else {
@@ -2272,27 +2567,37 @@  discard block
 block discarded – undo
2272 2567
 		date_default_timezone_set('UTC');
2273 2568
 		if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) {
2274 2569
 			$last_update = $this->getLastStatsUpdate('last_update_stats_marine');
2275
-			if ($globalDebug) echo '!!! Update Marine stats !!!'."\n";
2570
+			if ($globalDebug) {
2571
+				echo '!!! Update Marine stats !!!'."\n";
2572
+			}
2276 2573
 			if (isset($last_update[0]['value'])) {
2277 2574
 				$last_update_day = $last_update[0]['value'];
2278
-			} else $last_update_day = '2012-12-12 12:12:12';
2575
+			} else {
2576
+				$last_update_day = '2012-12-12 12:12:12';
2577
+			}
2279 2578
 			$reset = false;
2280 2579
 			$Marine = new Marine($this->db);
2281 2580
 			$filtername = 'marine';
2282 2581
 			if ($Connection->tableExists('countries')) {
2283
-				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2582
+				if ($globalDebug) {
2583
+					echo 'Count all vessels by countries...'."\n";
2584
+				}
2284 2585
 				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2285 2586
 				foreach ($alldata as $number) {
2286 2587
 					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2287 2588
 				}
2288 2589
 			}
2289
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2590
+			if ($globalDebug) {
2591
+				echo 'Count all vessels by months...'."\n";
2592
+			}
2290 2593
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2291 2594
 			$filter_last_month = array('since_date' => $last_month);
2292 2595
 			$alldata = $Marine->countAllMonths($filter_last_month);
2293 2596
 			$lastyear = false;
2294 2597
 			foreach ($alldata as $number) {
2295
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2598
+				if ($number['year_name'] != date('Y')) {
2599
+					$lastyear = true;
2600
+				}
2296 2601
 				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2297 2602
 			}
2298 2603
 			echo 'Marine data...'."\n";
@@ -2322,7 +2627,9 @@  discard block
 block discarded – undo
2322 2627
 			foreach ($alldata as $number) {
2323 2628
 				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2324 2629
 			}
2325
-			if ($globalDebug) echo 'Count all types...'."\n";
2630
+			if ($globalDebug) {
2631
+				echo 'Count all types...'."\n";
2632
+			}
2326 2633
 			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2327 2634
 			foreach ($alldata as $number) {
2328 2635
 				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
@@ -2334,26 +2641,36 @@  discard block
 block discarded – undo
2334 2641
 		}
2335 2642
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2336 2643
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
2337
-			if ($globalDebug) echo '!!! Update tracker stats !!!'."\n";
2644
+			if ($globalDebug) {
2645
+				echo '!!! Update tracker stats !!!'."\n";
2646
+			}
2338 2647
 			if (isset($last_update[0]['value'])) {
2339 2648
 				$last_update_day = $last_update[0]['value'];
2340
-			} else $last_update_day = '2012-12-12 12:12:12';
2649
+			} else {
2650
+				$last_update_day = '2012-12-12 12:12:12';
2651
+			}
2341 2652
 			$reset = false;
2342 2653
 			$Tracker = new Tracker($this->db);
2343 2654
 			if ($Connection->tableExists('countries')) {
2344
-				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2655
+				if ($globalDebug) {
2656
+					echo 'Count all trackers by countries...'."\n";
2657
+				}
2345 2658
 				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2346 2659
 				foreach ($alldata as $number) {
2347 2660
 					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2348 2661
 				}
2349 2662
 			}
2350
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2663
+			if ($globalDebug) {
2664
+				echo 'Count all vessels by months...'."\n";
2665
+			}
2351 2666
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2352 2667
 			$filter_last_month = array('since_date' => $last_month);
2353 2668
 			$alldata = $Tracker->countAllMonths($filter_last_month);
2354 2669
 			$lastyear = false;
2355 2670
 			foreach ($alldata as $number) {
2356
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2671
+				if ($number['year_name'] != date('Y')) {
2672
+					$lastyear = true;
2673
+				}
2357 2674
 				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2358 2675
 			}
2359 2676
 			echo 'Tracker data...'."\n";
@@ -2390,10 +2707,14 @@  discard block
 block discarded – undo
2390 2707
 
2391 2708
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
2392 2709
 			$last_update = $this->getLastStatsUpdate('last_update_stats');
2393
-			if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n";
2710
+			if ($globalDebug) {
2711
+				echo '!!! Update aicraft stats !!!'."\n";
2712
+			}
2394 2713
 			if (isset($last_update[0]['value'])) {
2395 2714
 				$last_update_day = $last_update[0]['value'];
2396
-			} else $last_update_day = '2012-12-12 12:12:12';
2715
+			} else {
2716
+				$last_update_day = '2012-12-12 12:12:12';
2717
+			}
2397 2718
 			$reset = false;
2398 2719
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
2399 2720
 			if ($globalStatsResetYear) {
@@ -2402,43 +2723,63 @@  discard block
 block discarded – undo
2402 2723
 			}
2403 2724
 			$Spotter = new Spotter($this->db);
2404 2725
 
2405
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2726
+			if ($globalDebug) {
2727
+				echo 'Count all aircraft types...'."\n";
2728
+			}
2406 2729
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2407 2730
 			foreach ($alldata as $number) {
2408 2731
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2409 2732
 			}
2410
-			if ($globalDebug) echo 'Count all airlines...'."\n";
2733
+			if ($globalDebug) {
2734
+				echo 'Count all airlines...'."\n";
2735
+			}
2411 2736
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2412 2737
 			foreach ($alldata as $number) {
2413 2738
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2414 2739
 			}
2415
-			if ($globalDebug) echo 'Count all registrations...'."\n";
2740
+			if ($globalDebug) {
2741
+				echo 'Count all registrations...'."\n";
2742
+			}
2416 2743
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2417 2744
 			foreach ($alldata as $number) {
2418 2745
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2419 2746
 			}
2420
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
2747
+			if ($globalDebug) {
2748
+				echo 'Count all callsigns...'."\n";
2749
+			}
2421 2750
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2422 2751
 			foreach ($alldata as $number) {
2423 2752
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2424 2753
 			}
2425
-			if ($globalDebug) echo 'Count all owners...'."\n";
2754
+			if ($globalDebug) {
2755
+				echo 'Count all owners...'."\n";
2756
+			}
2426 2757
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2427 2758
 			foreach ($alldata as $number) {
2428 2759
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2429 2760
 			}
2430
-			if ($globalDebug) echo 'Count all pilots...'."\n";
2761
+			if ($globalDebug) {
2762
+				echo 'Count all pilots...'."\n";
2763
+			}
2431 2764
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2432 2765
 			foreach ($alldata as $number) {
2433
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2766
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
2767
+					$number['pilot_id'] = $number['pilot_name'];
2768
+				}
2434 2769
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2435 2770
 			}
2436 2771
 			
2437
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
2772
+			if ($globalDebug) {
2773
+				echo 'Count all departure airports...'."\n";
2774
+			}
2438 2775
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2439
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2776
+			if ($globalDebug) {
2777
+				echo 'Count all detected departure airports...'."\n";
2778
+			}
2440 2779
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2441
-			if ($globalDebug) echo 'Order departure airports...'."\n";
2780
+			if ($globalDebug) {
2781
+				echo 'Order departure airports...'."\n";
2782
+			}
2442 2783
 			$alldata = array();
2443 2784
 			foreach ($pall as $value) {
2444 2785
 				$icao = $value['airport_departure_icao'];
@@ -2448,7 +2789,9 @@  discard block
 block discarded – undo
2448 2789
 				$icao = $value['airport_departure_icao'];
2449 2790
 				if (isset($alldata[$icao])) {
2450 2791
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2451
-				} else $alldata[$icao] = $value;
2792
+				} else {
2793
+					$alldata[$icao] = $value;
2794
+				}
2452 2795
 			}
2453 2796
 			$count = array();
2454 2797
 			foreach ($alldata as $key => $row) {
@@ -2458,11 +2801,17 @@  discard block
 block discarded – undo
2458 2801
 			foreach ($alldata as $number) {
2459 2802
 				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);
2460 2803
 			}
2461
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2804
+			if ($globalDebug) {
2805
+				echo 'Count all arrival airports...'."\n";
2806
+			}
2462 2807
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2463
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2808
+			if ($globalDebug) {
2809
+				echo 'Count all detected arrival airports...'."\n";
2810
+			}
2464 2811
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2465
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
2812
+			if ($globalDebug) {
2813
+				echo 'Order arrival airports...'."\n";
2814
+			}
2466 2815
 			$alldata = array();
2467 2816
 			foreach ($pall as $value) {
2468 2817
 				$icao = $value['airport_arrival_icao'];
@@ -2472,7 +2821,9 @@  discard block
 block discarded – undo
2472 2821
 				$icao = $value['airport_arrival_icao'];
2473 2822
 				if (isset($alldata[$icao])) {
2474 2823
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2475
-				} else $alldata[$icao] = $value;
2824
+				} else {
2825
+					$alldata[$icao] = $value;
2826
+				}
2476 2827
 			}
2477 2828
 			$count = array();
2478 2829
 			foreach ($alldata as $key => $row) {
@@ -2483,7 +2834,9 @@  discard block
 block discarded – undo
2483 2834
 				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);
2484 2835
 			}
2485 2836
 			if ($Connection->tableExists('countries')) {
2486
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2837
+				if ($globalDebug) {
2838
+					echo 'Count all flights by countries...'."\n";
2839
+				}
2487 2840
 				//$SpotterArchive = new SpotterArchive();
2488 2841
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2489 2842
 				$Spotter = new Spotter($this->db);
@@ -2494,7 +2847,9 @@  discard block
 block discarded – undo
2494 2847
 			}
2495 2848
 			
2496 2849
 			if (isset($globalAccidents) && $globalAccidents) {
2497
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
2850
+				if ($globalDebug) {
2851
+					echo 'Count fatalities stats...'."\n";
2852
+				}
2498 2853
 				$Accident = new Accident($this->db);
2499 2854
 				$this->deleteStatsByType('fatalities_byyear');
2500 2855
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2510,48 +2865,68 @@  discard block
 block discarded – undo
2510 2865
 
2511 2866
 			// Add by month using getstat if month finish...
2512 2867
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2513
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
2868
+			if ($globalDebug) {
2869
+				echo 'Count all flights by months...'."\n";
2870
+			}
2514 2871
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2515 2872
 			$filter_last_month = array('since_date' => $last_month);
2516 2873
 			$Spotter = new Spotter($this->db);
2517 2874
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2518 2875
 			$lastyear = false;
2519 2876
 			foreach ($alldata as $number) {
2520
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2877
+				if ($number['year_name'] != date('Y')) {
2878
+					$lastyear = true;
2879
+				}
2521 2880
 				$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'])));
2522 2881
 			}
2523
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2882
+			if ($globalDebug) {
2883
+				echo 'Count all military flights by months...'."\n";
2884
+			}
2524 2885
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2525 2886
 			foreach ($alldata as $number) {
2526 2887
 				$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'])));
2527 2888
 			}
2528
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
2889
+			if ($globalDebug) {
2890
+				echo 'Count all owners by months...'."\n";
2891
+			}
2529 2892
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2530 2893
 			foreach ($alldata as $number) {
2531 2894
 				$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'])));
2532 2895
 			}
2533
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2896
+			if ($globalDebug) {
2897
+				echo 'Count all pilots by months...'."\n";
2898
+			}
2534 2899
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2535 2900
 			foreach ($alldata as $number) {
2536 2901
 				$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'])));
2537 2902
 			}
2538
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2903
+			if ($globalDebug) {
2904
+				echo 'Count all airlines by months...'."\n";
2905
+			}
2539 2906
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2540 2907
 			foreach ($alldata as $number) {
2541 2908
 				$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'])));
2542 2909
 			}
2543
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2910
+			if ($globalDebug) {
2911
+				echo 'Count all aircrafts by months...'."\n";
2912
+			}
2544 2913
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2545 2914
 			foreach ($alldata as $number) {
2546 2915
 				$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'])));
2547 2916
 			}
2548
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2917
+			if ($globalDebug) {
2918
+				echo 'Count all real arrivals by months...'."\n";
2919
+			}
2549 2920
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2550 2921
 			foreach ($alldata as $number) {
2551 2922
 				$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'])));
2552 2923
 			}
2553
-			if ($globalDebug) echo 'Airports data...'."\n";
2554
-			if ($globalDebug) echo '...Departure'."\n";
2924
+			if ($globalDebug) {
2925
+				echo 'Airports data...'."\n";
2926
+			}
2927
+			if ($globalDebug) {
2928
+				echo '...Departure'."\n";
2929
+			}
2555 2930
 			$this->deleteStatAirport('daily');
2556 2931
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2557 2932
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2669,7 +3044,9 @@  discard block
 block discarded – undo
2669 3044
 			// Count by airlines
2670 3045
 			echo '--- Stats by airlines ---'."\n";
2671 3046
 			if ($Connection->tableExists('countries')) {
2672
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
3047
+				if ($globalDebug) {
3048
+					echo 'Count all flights by countries by airlines...'."\n";
3049
+				}
2673 3050
 				$SpotterArchive = new SpotterArchive($this->db);
2674 3051
 				//$Spotter = new Spotter($this->db);
2675 3052
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2678,37 +3055,53 @@  discard block
 block discarded – undo
2678 3055
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2679 3056
 				}
2680 3057
 			}
2681
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
3058
+			if ($globalDebug) {
3059
+				echo 'Count all aircraft types by airlines...'."\n";
3060
+			}
2682 3061
 			$Spotter = new Spotter($this->db);
2683 3062
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2684 3063
 			foreach ($alldata as $number) {
2685 3064
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2686 3065
 			}
2687
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
3066
+			if ($globalDebug) {
3067
+				echo 'Count all aircraft registrations by airlines...'."\n";
3068
+			}
2688 3069
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2689 3070
 			foreach ($alldata as $number) {
2690 3071
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2691 3072
 			}
2692
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
3073
+			if ($globalDebug) {
3074
+				echo 'Count all callsigns by airlines...'."\n";
3075
+			}
2693 3076
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2694 3077
 			foreach ($alldata as $number) {
2695 3078
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2696 3079
 			}
2697
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
3080
+			if ($globalDebug) {
3081
+				echo 'Count all owners by airlines...'."\n";
3082
+			}
2698 3083
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2699 3084
 			foreach ($alldata as $number) {
2700 3085
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2701 3086
 			}
2702
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
3087
+			if ($globalDebug) {
3088
+				echo 'Count all pilots by airlines...'."\n";
3089
+			}
2703 3090
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2704 3091
 			foreach ($alldata as $number) {
2705 3092
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2706 3093
 			}
2707
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
3094
+			if ($globalDebug) {
3095
+				echo 'Count all departure airports by airlines...'."\n";
3096
+			}
2708 3097
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2709
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
3098
+			if ($globalDebug) {
3099
+				echo 'Count all detected departure airports by airlines...'."\n";
3100
+			}
2710 3101
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2711
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
3102
+			if ($globalDebug) {
3103
+				echo 'Order detected departure airports by airlines...'."\n";
3104
+			}
2712 3105
 			//$alldata = array();
2713 3106
 			foreach ($dall as $value) {
2714 3107
 				$icao = $value['airport_departure_icao'];
@@ -2729,11 +3122,17 @@  discard block
 block discarded – undo
2729 3122
 			foreach ($alldata as $number) {
2730 3123
 				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);
2731 3124
 			}
2732
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
3125
+			if ($globalDebug) {
3126
+				echo 'Count all arrival airports by airlines...'."\n";
3127
+			}
2733 3128
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2734
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
3129
+			if ($globalDebug) {
3130
+				echo 'Count all detected arrival airports by airlines...'."\n";
3131
+			}
2735 3132
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2736
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
3133
+			if ($globalDebug) {
3134
+				echo 'Order arrival airports by airlines...'."\n";
3135
+			}
2737 3136
 			//$alldata = array();
2738 3137
 			foreach ($dall as $value) {
2739 3138
 				$icao = $value['airport_arrival_icao'];
@@ -2752,37 +3151,53 @@  discard block
 block discarded – undo
2752 3151
 			}
2753 3152
 			$alldata = $pall;
2754 3153
 			foreach ($alldata as $number) {
2755
-				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);
3154
+				if ($number['airline_icao'] != '') {
3155
+					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);
3156
+				}
3157
+			}
3158
+			if ($globalDebug) {
3159
+				echo 'Count all flights by months by airlines...'."\n";
2756 3160
 			}
2757
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2758 3161
 			$Spotter = new Spotter($this->db);
2759 3162
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
2760 3163
 			$lastyear = false;
2761 3164
 			foreach ($alldata as $number) {
2762
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3165
+				if ($number['year_name'] != date('Y')) {
3166
+					$lastyear = true;
3167
+				}
2763 3168
 				$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']);
2764 3169
 			}
2765
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3170
+			if ($globalDebug) {
3171
+				echo 'Count all owners by months by airlines...'."\n";
3172
+			}
2766 3173
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2767 3174
 			foreach ($alldata as $number) {
2768 3175
 				$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']);
2769 3176
 			}
2770
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3177
+			if ($globalDebug) {
3178
+				echo 'Count all pilots by months by airlines...'."\n";
3179
+			}
2771 3180
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2772 3181
 			foreach ($alldata as $number) {
2773 3182
 				$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']);
2774 3183
 			}
2775
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3184
+			if ($globalDebug) {
3185
+				echo 'Count all aircrafts by months by airlines...'."\n";
3186
+			}
2776 3187
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2777 3188
 			foreach ($alldata as $number) {
2778 3189
 				$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']);
2779 3190
 			}
2780
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3191
+			if ($globalDebug) {
3192
+				echo 'Count all real arrivals by months by airlines...'."\n";
3193
+			}
2781 3194
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2782 3195
 			foreach ($alldata as $number) {
2783 3196
 				$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']);
2784 3197
 			}
2785
-			if ($globalDebug) echo '...Departure'."\n";
3198
+			if ($globalDebug) {
3199
+				echo '...Departure'."\n";
3200
+			}
2786 3201
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
2787 3202
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
2788 3203
 			foreach ($dall as $value) {
@@ -2805,7 +3220,9 @@  discard block
 block discarded – undo
2805 3220
 			foreach ($alldata as $number) {
2806 3221
 				$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']);
2807 3222
 			}
2808
-			if ($globalDebug) echo '...Arrival'."\n";
3223
+			if ($globalDebug) {
3224
+				echo '...Arrival'."\n";
3225
+			}
2809 3226
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
2810 3227
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
2811 3228
 			foreach ($dall as $value) {
@@ -2829,13 +3246,19 @@  discard block
 block discarded – undo
2829 3246
 				$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']);
2830 3247
 			}
2831 3248
 
2832
-			if ($globalDebug) echo 'Flights data...'."\n";
2833
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3249
+			if ($globalDebug) {
3250
+				echo 'Flights data...'."\n";
3251
+			}
3252
+			if ($globalDebug) {
3253
+				echo '-> countAllDatesLastMonth...'."\n";
3254
+			}
2834 3255
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2835 3256
 			foreach ($alldata as $number) {
2836 3257
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2837 3258
 			}
2838
-			if ($globalDebug) echo '-> countAllDates...'."\n";
3259
+			if ($globalDebug) {
3260
+				echo '-> countAllDates...'."\n";
3261
+			}
2839 3262
 			//$previousdata = $this->countAllDatesByAirlines();
2840 3263
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2841 3264
 			$values = array();
@@ -2848,14 +3271,18 @@  discard block
 block discarded – undo
2848 3271
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2849 3272
 			}
2850 3273
 			
2851
-			if ($globalDebug) echo '-> countAllHours...'."\n";
3274
+			if ($globalDebug) {
3275
+				echo '-> countAllHours...'."\n";
3276
+			}
2852 3277
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2853 3278
 			foreach ($alldata as $number) {
2854 3279
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2855 3280
 			}
2856 3281
 
2857 3282
 			// Stats by filters
2858
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
3283
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
3284
+				$globalStatsFilters = array();
3285
+			}
2859 3286
 			foreach ($globalStatsFilters as $name => $filter) {
2860 3287
 				if (!empty($filter)) {
2861 3288
 					//$filter_name = $filter['name'];
@@ -2863,7 +3290,9 @@  discard block
 block discarded – undo
2863 3290
 					$reset = false;
2864 3291
 					$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
2865 3292
 					if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
2866
-						if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3293
+						if ($globalDebug) {
3294
+							echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3295
+						}
2867 3296
 						$this->deleteOldStats($filter_name);
2868 3297
 						unset($last_update);
2869 3298
 					}
@@ -2880,39 +3309,55 @@  discard block
 block discarded – undo
2880 3309
 						$reset = true;
2881 3310
 					}
2882 3311
 					// Count by filter
2883
-					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3312
+					if ($globalDebug) {
3313
+						echo '--- Stats for filter '.$filter_name.' ---'."\n";
3314
+					}
2884 3315
 					$Spotter = new Spotter($this->db);
2885
-					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3316
+					if ($globalDebug) {
3317
+						echo 'Count all aircraft types...'."\n";
3318
+					}
2886 3319
 					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2887 3320
 					foreach ($alldata as $number) {
2888 3321
 						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2889 3322
 					}
2890
-					if ($globalDebug) echo 'Count all airlines...'."\n";
3323
+					if ($globalDebug) {
3324
+						echo 'Count all airlines...'."\n";
3325
+					}
2891 3326
 					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2892 3327
 					foreach ($alldata as $number) {
2893 3328
 						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2894 3329
 					}
2895
-					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3330
+					if ($globalDebug) {
3331
+						echo 'Count all aircraft registrations...'."\n";
3332
+					}
2896 3333
 					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2897 3334
 					foreach ($alldata as $number) {
2898 3335
 						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2899 3336
 					}
2900
-					if ($globalDebug) echo 'Count all callsigns...'."\n";
3337
+					if ($globalDebug) {
3338
+						echo 'Count all callsigns...'."\n";
3339
+					}
2901 3340
 					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2902 3341
 					foreach ($alldata as $number) {
2903 3342
 						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2904 3343
 					}
2905
-					if ($globalDebug) echo 'Count all owners...'."\n";
3344
+					if ($globalDebug) {
3345
+						echo 'Count all owners...'."\n";
3346
+					}
2906 3347
 					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2907 3348
 					foreach ($alldata as $number) {
2908 3349
 						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2909 3350
 					}
2910
-					if ($globalDebug) echo 'Count all pilots...'."\n";
3351
+					if ($globalDebug) {
3352
+						echo 'Count all pilots...'."\n";
3353
+					}
2911 3354
 					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2912 3355
 					foreach ($alldata as $number) {
2913 3356
 						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2914 3357
 					}
2915
-					if ($globalDebug) echo 'Count departure airports...'."\n";
3358
+					if ($globalDebug) {
3359
+						echo 'Count departure airports...'."\n";
3360
+					}
2916 3361
 					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2917 3362
 					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2918 3363
 					$alldata = array();
@@ -2924,7 +3369,9 @@  discard block
 block discarded – undo
2924 3369
 						$icao = $value['airport_departure_icao'];
2925 3370
 						if (isset($alldata[$icao])) {
2926 3371
 							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2927
-						} else $alldata[$icao] = $value;
3372
+						} else {
3373
+							$alldata[$icao] = $value;
3374
+						}
2928 3375
 					}
2929 3376
 					$count = array();
2930 3377
 					foreach ($alldata as $key => $row) {
@@ -2934,7 +3381,9 @@  discard block
 block discarded – undo
2934 3381
 					foreach ($alldata as $number) {
2935 3382
 						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
2936 3383
 					}
2937
-					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3384
+					if ($globalDebug) {
3385
+						echo 'Count all arrival airports...'."\n";
3386
+					}
2938 3387
 					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2939 3388
 					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2940 3389
 					$alldata = array();
@@ -2946,7 +3395,9 @@  discard block
 block discarded – undo
2946 3395
 						$icao = $value['airport_arrival_icao'];
2947 3396
 						if (isset($alldata[$icao])) {
2948 3397
 							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2949
-						} else $alldata[$icao] = $value;
3398
+						} else {
3399
+							$alldata[$icao] = $value;
3400
+						}
2950 3401
 					}
2951 3402
 					$count = array();
2952 3403
 					foreach ($alldata as $key => $row) {
@@ -2956,35 +3407,49 @@  discard block
 block discarded – undo
2956 3407
 					foreach ($alldata as $number) {
2957 3408
 						echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
2958 3409
 					}
2959
-					if ($globalDebug) echo 'Count all months...'."\n";
3410
+					if ($globalDebug) {
3411
+						echo 'Count all months...'."\n";
3412
+					}
2960 3413
 					$Spotter = new Spotter($this->db);
2961 3414
 					$alldata = $Spotter->countAllMonths($filter);
2962 3415
 					$lastyear = false;
2963 3416
 					foreach ($alldata as $number) {
2964
-						if ($number['year_name'] != date('Y')) $lastyear = true;
3417
+						if ($number['year_name'] != date('Y')) {
3418
+							$lastyear = true;
3419
+						}
2965 3420
 						$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);
2966 3421
 					}
2967
-					if ($globalDebug) echo 'Count all owners by months...'."\n";
3422
+					if ($globalDebug) {
3423
+						echo 'Count all owners by months...'."\n";
3424
+					}
2968 3425
 					$alldata = $Spotter->countAllMonthsOwners($filter);
2969 3426
 					foreach ($alldata as $number) {
2970 3427
 						$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2971 3428
 					}
2972
-					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3429
+					if ($globalDebug) {
3430
+						echo 'Count all pilots by months...'."\n";
3431
+					}
2973 3432
 					$alldata = $Spotter->countAllMonthsPilots($filter);
2974 3433
 					foreach ($alldata as $number) {
2975 3434
 						$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2976 3435
 					}
2977
-					if ($globalDebug) echo 'Count all military by months...'."\n";
3436
+					if ($globalDebug) {
3437
+						echo 'Count all military by months...'."\n";
3438
+					}
2978 3439
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
2979 3440
 					foreach ($alldata as $number) {
2980 3441
 						$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2981 3442
 					}
2982
-					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3443
+					if ($globalDebug) {
3444
+						echo 'Count all aircrafts by months...'."\n";
3445
+					}
2983 3446
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
2984 3447
 				    	foreach ($alldata as $number) {
2985 3448
 			    			$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2986 3449
 					}
2987
-					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3450
+					if ($globalDebug) {
3451
+						echo 'Count all real arrivals by months...'."\n";
3452
+					}
2988 3453
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2989 3454
 					foreach ($alldata as $number) {
2990 3455
 						$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
Please login to merge, or discard this patch.
statistics.php 2 patches
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 }
24 24
 
25 25
 if (!isset($filter_name)) $filter_name = '';
26
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
26
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
27 27
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28 28
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29 29
 }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
33 33
 	if (isset($airline_info[0]['name'])) {
34 34
 		$airline_name = $airline_info[0]['name'];
35
-	} elseif (strpos($airline_icao,'alliance_') !== FALSE) {
35
+	} elseif (strpos($airline_icao, 'alliance_') !== FALSE) {
36 36
 		$alliance_name = $airline_icao;
37 37
 	}
38 38
 }
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	$title = _("Statistics");
43 43
 }
44 44
 
45
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
45
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
46
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
47 47
 
48 48
 require_once('header.php');
49 49
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	date_default_timezone_set('UTC');
75 75
 	$lastupdate = strtotime($last_update[0]['value']);
76 76
 	if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
77
-	print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
77
+	print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
78 78
 }
79 79
 
80 80
 ?>
@@ -86,31 +86,31 @@  discard block
 block discarded – undo
86 86
 <?php
87 87
 if ($type == 'aircraft') {
88 88
 ?>
89
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
90
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
91
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
92
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
89
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
90
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
91
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
92
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
93 93
 <?php
94 94
 	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
95 95
 ?>
96
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
97
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
96
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
97
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
98 98
 <?php
99 99
 	}
100 100
 	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
101 101
 ?>
102
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
103
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
102
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
103
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
104 104
 <?php
105 105
 	}
106 106
 ?>
107
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
108
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
107
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
108
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
109 109
 <?php
110 110
 	if ($airline_icao == '') {
111 111
 ?>
112
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
113
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
112
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
113
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
114 114
 <?php
115 115
 	}
116 116
 ?>
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	if (!(isset($globalVA) && $globalVA) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS) && !(isset($globalVAM) && $globalVAM)) {
119 119
 		if ($airline_icao == '' || $airline_icao == 'all') {
120 120
 ?>
121
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
122
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
121
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
122
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
123 123
 <?php
124 124
 		}
125 125
 	}
@@ -127,22 +127,22 @@  discard block
 block discarded – undo
127 127
 <?php
128 128
 } elseif ($type == 'marine') {
129 129
 ?>
130
-	<span><span class="badge"><?php print number_format($Stats->countOverallMarine($filter_name,$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
131
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
132
-	<span><span class="badge"><?php print number_format($Stats->countOverallMarineTypes($filter_name,$year,$month)); ?></span> <?php echo _("Types"); ?></span>
133
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
130
+	<span><span class="badge"><?php print number_format($Stats->countOverallMarine($filter_name, $year, $month)); ?></span> <?php echo _("Vessels"); ?></span>
131
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
132
+	<span><span class="badge"><?php print number_format($Stats->countOverallMarineTypes($filter_name, $year, $month)); ?></span> <?php echo _("Types"); ?></span>
133
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
134 134
 <?php
135 135
 } elseif ($type == 'tracker') {
136 136
 ?>
137
-	<span><span class="badge"><?php print number_format($Stats->countOverallTracker($filter_name,$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
138
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
139
-	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(),$year,$month)); ?></span> <?php echo _("Types"); ?></span>
140
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
137
+	<span><span class="badge"><?php print number_format($Stats->countOverallTracker($filter_name, $year, $month)); ?></span> <?php echo _("Trackers"); ?></span>
138
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
139
+	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(), $year, $month)); ?></span> <?php echo _("Types"); ?></span>
140
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
141 141
 <?php
142 142
 }
143 143
 ?>
144 144
     </p>
145
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
145
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
146 146
     <div class="specific-stats">
147 147
 <?php
148 148
 if ($type == 'aircraft') {
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
             <div class="col-md-6">
152 152
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
153 153
 <?php
154
-	$aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
154
+	$aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
155 155
 	if (count($aircraft_array) == 0) {
156 156
 		print _("No data available");
157 157
 	} else {
158 158
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
159 159
 		$aircraft_data = '';
160
-		foreach($aircraft_array as $aircraft_item) {
160
+		foreach ($aircraft_array as $aircraft_item) {
161 161
 			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162 162
 			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
163 163
 		}
@@ -186,16 +186,16 @@  discard block
 block discarded – undo
186 186
 ?>
187 187
                 </div>
188 188
             </div>
189
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
189
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
190 190
 <?php
191 191
 	if ($airline_icao == '' || $airline_icao == 'all') {
192
-		$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
192
+		$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
193 193
 		if (count($airline_array) > 0) {
194 194
 			print '<div class="col-md-6">';
195 195
 			print '<h2>'._("Top 10 Most Common Airline").'</h2>';
196 196
 			print '<div id="chart2" class="chart" width="100%"></div><script>';
197 197
 			$airline_data = '';
198
-			foreach($airline_array as $airline_item) {
198
+			foreach ($airline_array as $airline_item) {
199 199
 				$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
200 200
 			}
201 201
 			$airline_data = substr($airline_data, 0, -1);
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		}
221 221
 ?>
222 222
         </div>
223
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
223
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
224 224
 <?php
225 225
 	}
226 226
 }
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
             <div class="col-md-6">
233 233
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234 234
 <?php
235
-	$marine_array = $Stats->countAllMarineTypes(true,0,'',$filter_name,$year,$month);
235
+	$marine_array = $Stats->countAllMarineTypes(true, 0, '', $filter_name, $year, $month);
236 236
 	if (count($marine_array) == 0) print _("No data available");
237 237
 	else {
238 238
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
239 239
 		$marine_data = '';
240
-		foreach($marine_array as $marine_item) {
240
+		foreach ($marine_array as $marine_item) {
241 241
 			$marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
242 242
 		}
243 243
 		$marine_data = substr($marine_data, 0, -1);
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
             	    ?>
267 267
                 </div>
268 268
             </div>
269
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
269
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
270 270
 <!--	</div>-->
271 271
 <?php
272 272
 }
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
             <div class="col-md-6">
277 277
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
278 278
 <?php
279
-	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
279
+	$tracker_array = $Tracker->countAllTrackerTypes(true, 0, '', array(), $year, $month);
280 280
 	if (count($tracker_array) == 0) print _("No data available");
281 281
 	else {
282 282
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
283 283
 		$tracker_data = '';
284
-		foreach($tracker_array as $tracker_item) {
284
+		foreach ($tracker_array as $tracker_item) {
285 285
 			$tracker_data .= '["'.$tracker_item['tracker_type'].'",'.$tracker_item['tracker_type_count'].'],';
286 286
 		}
287 287
 		$tracker_data = substr($tracker_data, 0, -1);
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
             	    ?>
312 312
                 </div>
313 313
             </div>
314
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
314
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
315 315
 <!--	</div>-->
316 316
 <?php
317 317
 }
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		else {
327 327
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
328 328
 			$owner_data = '';
329
-			foreach($owner_array as $owner_item) {
329
+			foreach ($owner_array as $owner_item) {
330 330
 				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
331 331
 			}
332 332
 			$owner_data = substr($owner_data, 0, -1);
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
                 </div>
347 347
                 -->
348 348
             </div>
349
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
349
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
350 350
             <div class="col-md-6">
351 351
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
352 352
 <?php
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 		else {
356 356
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
357 357
 			$owner_data = '';
358
-			foreach($countries_array as $owner_item) {
358
+			foreach ($countries_array as $owner_item) {
359 359
 				$owner_data .= '["'.$owner_item['country_name'].'",'.$owner_item['country_count'].'],';
360 360
 			}
361 361
 			$owner_data = substr($owner_data, 0, -1);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                 -->
377 377
             </div>
378 378
             
379
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
379
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
380 380
 ²	</div>
381 381
         <div class="row column">
382 382
             <div class="col-md-6">
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 		else {
388 388
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
389 389
 			$launch_site_data = '';
390
-			foreach($launch_site_array as $launch_site_item) {
390
+			foreach ($launch_site_array as $launch_site_item) {
391 391
 				$launch_site_data .= '["'.$launch_site_item['launch_site'].'",'.$launch_site_item['launch_site_count'].'],';
392 392
 			}
393 393
 			$launch_site_data = substr($launch_site_data, 0, -1);
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 ?>
415 415
         <div class="row column">
416 416
 <?php
417
-	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
417
+	$flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
418 418
 	//if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
419 419
 	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
420 420
 		if (empty($flightover_array)) {
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
 ?>
426 426
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
427 427
 <?php
428
-		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
428
+		$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
429 429
 		if (count($pilot_array) == 0) print _("No data available");
430 430
 		else {
431 431
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
432 432
 			$pilot_data = '';
433
-			foreach($pilot_array as $pilot_item) {
433
+			foreach ($pilot_array as $pilot_item) {
434 434
 				$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
435 435
 			}
436 436
 			$pilot_data = substr($pilot_data, 0, -1);
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 ?>
452 452
             </div>
453 453
 
454
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
454
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
455 455
 <?php
456 456
 	}
457 457
 	// else {
@@ -460,12 +460,12 @@  discard block
 block discarded – undo
460 460
             <div class="col-md-6">
461 461
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
462 462
 <?php
463
-		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
463
+		$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
464 464
 		if (count($owner_array) == 0) print _("No data available");
465 465
 		else {
466 466
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
467 467
 			$owner_data = '';
468
-			foreach($owner_array as $owner_item) {
468
+			foreach ($owner_array as $owner_item) {
469 469
 				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
470 470
 			}
471 471
 			$owner_data = substr($owner_data, 0, -1);
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
                 </div>
485 485
             </div>
486 486
         
487
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
487
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
488 488
 <?php
489 489
 	}
490 490
 	if (!empty($flightover_array)) {
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
499 499
 			print 'var series = [';
500 500
 			$flightover_data = '';
501
-			foreach($flightover_array as $flightover_item) {
501
+			foreach ($flightover_array as $flightover_item) {
502 502
 				$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
503 503
 			}
504 504
 			$flightover_data = substr($flightover_data, 0, -1);
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 	}
544 544
 ?>
545 545
         </div>
546
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
546
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
547 547
         </div>
548 548
 <?php
549 549
 }
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
560 560
 		print 'var series = [';
561 561
 		$flightover_data = '';
562
-		foreach($flightover_array as $flightover_item) {
562
+		foreach ($flightover_array as $flightover_item) {
563 563
 			$flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
564 564
 		}
565 565
 		$flightover_data = substr($flightover_data, 0, -1);
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
617 617
 		print 'var series = [';
618 618
 		$flightover_data = '';
619
-		foreach($flightover_array as $flightover_item) {
619
+		foreach ($flightover_array as $flightover_item) {
620 620
 			$flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
621 621
 		}
622 622
 		$flightover_data = substr($flightover_data, 0, -1);
@@ -666,14 +666,14 @@  discard block
 block discarded – undo
666 666
         <div class="row column">
667 667
             <div class="col-md-6">
668 668
 <?php
669
-	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
669
+	$airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
670 670
 	if (count($airport_airport_array) > 0) {
671 671
 		print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
672 672
 		print '<div id="chart3" class="chart" width="100%"></div><script>';
673 673
 		print "\n";
674 674
 		print 'var series = [';
675 675
 		$airport_data = '';
676
-		foreach($airport_airport_array as $airport_item) {
676
+		foreach ($airport_airport_array as $airport_item) {
677 677
 			$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
678 678
 		}
679 679
 		$airport_data = substr($airport_data, 0, -1);
@@ -723,18 +723,18 @@  discard block
 block discarded – undo
723 723
 	}
724 724
 ?>
725 725
             </div>
726
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
726
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
727 727
 
728 728
             <div class="col-md-6">
729 729
 <?php
730
-	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
730
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
731 731
 	if (count($airport_airport_array2) > 0) {
732 732
 		print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
733 733
 		print '<div id="chart4" class="chart" width="100%"></div><script>';
734 734
 		print "\n";
735 735
 		print 'var series = [';
736 736
 		$airport_data = '';
737
-		foreach($airport_airport_array2 as $airport_item)
737
+		foreach ($airport_airport_array2 as $airport_item)
738 738
 		{
739 739
 			if (isset($airport_item['airport_arrival_longitude']) && isset($airport_item['airport_arrival_latitude'])) {
740 740
 				$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 ?>
789 789
             </div>
790 790
         </div>
791
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
791
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
792 792
 <?php 
793 793
 }
794 794
 if ($type == 'aircraft') {
@@ -800,18 +800,18 @@  discard block
 block discarded – undo
800 800
             <div class="col-md-6">
801 801
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
802 802
 <?php
803
-		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
803
+		$year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
804 804
 		if (count($year_array) == 0) print _("No data available");
805 805
 		else {
806 806
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
807 807
 			$year_data = '';
808 808
 			$year_cnt = '';
809
-			foreach($year_array as $year_item) {
809
+			foreach ($year_array as $year_item) {
810 810
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
811 811
 				$year_cnt .= $year_item['date_count'].',';
812 812
 			}
813 813
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
814
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
814
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
815 815
 			print 'c3.generate({
816 816
 			    bindto: "#chart8",
817 817
 			    data: { x: "x",
@@ -824,22 +824,22 @@  discard block
 block discarded – undo
824 824
                     <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>
825 825
                 </div>
826 826
             </div>
827
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
827
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
828 828
             <div class="col-md-6">
829 829
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
830 830
 <?php
831
-		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
831
+		$month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
832 832
 		if (count($month_array) == 0) print _("No data available");
833 833
 		else {
834 834
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
835 835
 			$month_data = '';
836 836
 			$month_cnt = '';
837
-			foreach($month_array as $month_item) {
837
+			foreach ($month_array as $month_item) {
838 838
 				$month_data .= '"'.$month_item['date_name'].'",';
839 839
 				$month_cnt .= $month_item['date_count'].',';
840 840
 			}
841 841
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
842
-			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
842
+			$month_cnt = "['flights',".substr($month_cnt, 0, -1)."]";
843 843
 			print 'c3.generate({
844 844
 			    bindto: "#chart9",
845 845
 			    data: { x: "x",
@@ -852,23 +852,23 @@  discard block
 block discarded – undo
852 852
                     <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>
853 853
                 </div>
854 854
             </div>
855
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
855
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
856 856
 
857 857
             <div class="col-md-6">
858 858
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
859 859
 <?php
860
-		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
860
+		$date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
861 861
 		if (empty($date_array)) print _("No data available");
862 862
 		else {
863 863
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
864 864
 			$date_data = '';
865 865
 			$date_cnt = '';
866
-			foreach($date_array as $date_item) {
866
+			foreach ($date_array as $date_item) {
867 867
 				$date_data .= '"'.$date_item['date_name'].'",';
868 868
 				$date_cnt .= $date_item['date_count'].',';
869 869
 			}
870 870
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
871
-			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
871
+			$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
872 872
 			print 'c3.generate({
873 873
 			    bindto: "#chart5",
874 874
 			    data: { x: "x",
@@ -881,22 +881,22 @@  discard block
 block discarded – undo
881 881
                     <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>
882 882
                 </div>
883 883
             </div>
884
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
884
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
885 885
             <div class="col-md-6">
886 886
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
887 887
 <?php
888
-		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
888
+		$hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
889 889
 		if (empty($hour_array)) print _("No data available");
890 890
 		else {
891 891
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
892 892
 			$hour_data = '';
893 893
 			$hour_cnt = '';
894
-			foreach($hour_array as $hour_item) {
894
+			foreach ($hour_array as $hour_item) {
895 895
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
896 896
 				$hour_cnt .= $hour_item['hour_count'].',';
897 897
 			}
898 898
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
899
-			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
899
+			$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
900 900
 			print 'c3.generate({
901 901
 			    bindto: "#chart6",
902 902
 			    data: {
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
                     <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>
910 910
                 </div>
911 911
             </div>
912
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
912
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
913 913
         </div>
914 914
 <?php
915 915
 	}
@@ -925,18 +925,18 @@  discard block
 block discarded – undo
925 925
             <div class="col-md-6">
926 926
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
927 927
 <?php
928
-		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
928
+		$year_array = $Marine->countAllMonthsLastYear(true, $airline_icao, $filter_name);
929 929
 		if (count($year_array) == 0) print _("No data available");
930 930
 		else {
931 931
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
932 932
 			$year_data = '';
933 933
 			$year_cnt = '';
934
-			foreach($year_array as $year_item) {
934
+			foreach ($year_array as $year_item) {
935 935
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
936 936
 				$year_cnt .= $year_item['date_count'].',';
937 937
 			}
938 938
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
939
-			$year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
939
+			$year_cnt = "['vessels',".substr($year_cnt, 0, -1)."]";
940 940
 			print 'c3.generate({
941 941
 			    bindto: "#chart8",
942 942
 			    data: { x: "x",
@@ -950,22 +950,22 @@  discard block
 block discarded – undo
950 950
                 </div>
951 951
             </div>
952 952
             
953
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
953
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
954 954
             <div class="col-md-6">
955 955
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
956 956
 <?php
957
-		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
957
+		$month_array = $Marine->countAllDatesLastMonth($airline_icao, $filter_name);
958 958
 		if (count($month_array) == 0) print _("No data available");
959 959
 		else {
960 960
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
961 961
 			$month_data = '';
962 962
 			$month_cnt = '';
963
-			foreach($month_array as $month_item) {
963
+			foreach ($month_array as $month_item) {
964 964
 				$month_data .= '"'.$month_item['date_name'].'",';
965 965
 				$month_cnt .= $month_item['date_count'].',';
966 966
 			}
967 967
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
968
-			$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
968
+			$month_cnt = "['vessels',".substr($month_cnt, 0, -1)."]";
969 969
 			print 'c3.generate({
970 970
 			    bindto: "#chart9",
971 971
 			    data: { x: "x",
@@ -978,23 +978,23 @@  discard block
 block discarded – undo
978 978
                     <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
979 979
                 </div>
980 980
             </div>
981
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
981
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
982 982
 
983 983
             <div class="col-md-6">
984 984
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
985 985
 <?php
986
-		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
986
+		$date_array = $Marine->countAllDatesLast7Days($airline_icao, $filter_name);
987 987
 		if (empty($date_array)) print _("No data available");
988 988
 		else {
989 989
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
990 990
 			$date_data = '';
991 991
 			$date_cnt = '';
992
-			foreach($date_array as $date_item) {
992
+			foreach ($date_array as $date_item) {
993 993
 				$date_data .= '"'.$date_item['date_name'].'",';
994 994
 				$date_cnt .= $date_item['date_count'].',';
995 995
 			}
996 996
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
997
-			$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
997
+			$date_cnt = "['vessels',".substr($date_cnt, 0, -1)."]";
998 998
 			print 'c3.generate({
999 999
 			    bindto: "#chart5",
1000 1000
 			    data: { x: "x",
@@ -1007,22 +1007,22 @@  discard block
 block discarded – undo
1007 1007
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1008 1008
                 </div>
1009 1009
             </div>
1010
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1010
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1011 1011
             <div class="col-md-6">
1012 1012
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1013 1013
 <?php
1014
-		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1014
+		$hour_array = $Marine->countAllHours('hour', true, $airline_icao, $filter_name);
1015 1015
 		if (empty($hour_array)) print _("No data available");
1016 1016
 		else {
1017 1017
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1018 1018
 			$hour_data = '';
1019 1019
 			$hour_cnt = '';
1020
-			foreach($hour_array as $hour_item) {
1020
+			foreach ($hour_array as $hour_item) {
1021 1021
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1022 1022
 				$hour_cnt .= $hour_item['hour_count'].',';
1023 1023
 			}
1024 1024
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
1025
-			$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
1025
+			$hour_cnt = "['vessels',".substr($hour_cnt, 0, -1)."]";
1026 1026
 			print 'c3.generate({
1027 1027
 			    bindto: "#chart6",
1028 1028
 			    data: {
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
                     <a href="<?php print $globalURL; ?>/marine/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1036 1036
                 </div>
1037 1037
             </div>
1038
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1038
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1039 1039
         </div>
1040 1040
 <?php
1041 1041
 	}
@@ -1057,12 +1057,12 @@  discard block
 block discarded – undo
1057 1057
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1058 1058
 			$year_data = '';
1059 1059
 			$year_cnt = '';
1060
-			foreach($year_array as $year_item) {
1060
+			foreach ($year_array as $year_item) {
1061 1061
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1062 1062
 				$year_cnt .= $year_item['date_count'].',';
1063 1063
 			}
1064 1064
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1065
-			$year_cnt = "['trackers',".substr($year_cnt,0,-1)."]";
1065
+			$year_cnt = "['trackers',".substr($year_cnt, 0, -1)."]";
1066 1066
 			print 'c3.generate({
1067 1067
 			    bindto: "#chart8",
1068 1068
 			    data: { x: "x",
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
                 </div>
1077 1077
             </div>
1078 1078
             
1079
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1079
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1080 1080
             <div class="col-md-6">
1081 1081
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1082 1082
 <?php
@@ -1086,12 +1086,12 @@  discard block
 block discarded – undo
1086 1086
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1087 1087
 			$month_data = '';
1088 1088
 			$month_cnt = '';
1089
-			foreach($month_array as $month_item) {
1089
+			foreach ($month_array as $month_item) {
1090 1090
 				$month_data .= '"'.$month_item['date_name'].'",';
1091 1091
 				$month_cnt .= $month_item['date_count'].',';
1092 1092
 			}
1093 1093
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
1094
-			$month_cnt = "['trackers',".substr($month_cnt,0,-1)."]";
1094
+			$month_cnt = "['trackers',".substr($month_cnt, 0, -1)."]";
1095 1095
 			print 'c3.generate({
1096 1096
 			    bindto: "#chart9",
1097 1097
 			    data: { x: "x",
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
                     <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1105 1105
                 </div>
1106 1106
             </div>
1107
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1107
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1108 1108
 
1109 1109
             <div class="col-md-6">
1110 1110
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
@@ -1115,12 +1115,12 @@  discard block
 block discarded – undo
1115 1115
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1116 1116
 			$date_data = '';
1117 1117
 			$date_cnt = '';
1118
-			foreach($date_array as $date_item) {
1118
+			foreach ($date_array as $date_item) {
1119 1119
 				$date_data .= '"'.$date_item['date_name'].'",';
1120 1120
 				$date_cnt .= $date_item['date_count'].',';
1121 1121
 			}
1122 1122
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
1123
-			$date_cnt = "['trackers',".substr($date_cnt,0,-1)."]";
1123
+			$date_cnt = "['trackers',".substr($date_cnt, 0, -1)."]";
1124 1124
 			print 'c3.generate({
1125 1125
 			    bindto: "#chart5",
1126 1126
 			    data: { x: "x",
@@ -1133,22 +1133,22 @@  discard block
 block discarded – undo
1133 1133
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1134 1134
                 </div>
1135 1135
             </div>
1136
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1136
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1137 1137
             <div class="col-md-6">
1138 1138
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1139 1139
 <?php
1140
-		$hour_array = $Tracker->countAllHours('hour',true);
1140
+		$hour_array = $Tracker->countAllHours('hour', true);
1141 1141
 		if (empty($hour_array)) print _("No data available");
1142 1142
 		else {
1143 1143
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1144 1144
 			$hour_data = '';
1145 1145
 			$hour_cnt = '';
1146
-			foreach($hour_array as $hour_item) {
1146
+			foreach ($hour_array as $hour_item) {
1147 1147
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1148 1148
 				$hour_cnt .= $hour_item['hour_count'].',';
1149 1149
 			}
1150 1150
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
1151
-			$hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]";
1151
+			$hour_cnt = "['trackers',".substr($hour_cnt, 0, -1)."]";
1152 1152
 			print 'c3.generate({
1153 1153
 			    bindto: "#chart6",
1154 1154
 			    data: {
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
                     <a href="<?php print $globalURL; ?>/tracker/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1162 1162
                 </div>
1163 1163
             </div>
1164
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1164
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1165 1165
         </div>
1166 1166
 <?php
1167 1167
 	}
@@ -1183,12 +1183,12 @@  discard block
 block discarded – undo
1183 1183
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1184 1184
 			$year_data = '';
1185 1185
 			$year_cnt = '';
1186
-			foreach($year_array as $year_item) {
1186
+			foreach ($year_array as $year_item) {
1187 1187
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1188 1188
 				$year_cnt .= $year_item['date_count'].',';
1189 1189
 			}
1190 1190
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1191
-			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1191
+			$year_cnt = "['satellite',".substr($year_cnt, 0, -1)."]";
1192 1192
 			print 'c3.generate({
1193 1193
 			    bindto: "#chart21",
1194 1194
 			    data: { x: "x",
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
             -->
1205 1205
             </div>
1206 1206
             
1207
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1207
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1208 1208
             <div class="col-md-6">
1209 1209
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1210 1210
 <?php
@@ -1214,12 +1214,12 @@  discard block
 block discarded – undo
1214 1214
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1215 1215
 			$year_data = '';
1216 1216
 			$year_cnt = '';
1217
-			foreach($year_array as $year_item) {
1217
+			foreach ($year_array as $year_item) {
1218 1218
 				$year_data .= '"'.$year_item['year_name'].'-01-01'.'",';
1219 1219
 				$year_cnt .= $year_item['date_count'].',';
1220 1220
 			}
1221 1221
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1222
-			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1222
+			$year_cnt = "['satellite',".substr($year_cnt, 0, -1)."]";
1223 1223
 			print 'c3.generate({
1224 1224
 			    bindto: "#chart22",
1225 1225
 			    data: { x: "x",
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
             -->
1236 1236
             </div>
1237 1237
             
1238
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1238
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1239 1239
         </div>
1240 1240
 <?php
1241 1241
 	}
@@ -1257,12 +1257,12 @@  discard block
 block discarded – undo
1257 1257
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1258 1258
 			$year_data = '';
1259 1259
 			$year_cnt = '';
1260
-			foreach($year_array as $year_item) {
1260
+			foreach ($year_array as $year_item) {
1261 1261
 				$year_data .= '"'.$year_item['year'].'-01-01",';
1262 1262
 				$year_cnt .= $year_item['count'].',';
1263 1263
 			}
1264 1264
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1265
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1265
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1266 1266
 			print 'c3.generate({
1267 1267
 			    bindto: "#chart32",
1268 1268
 			    data: { x: "x",
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1276 1276
                 </div>
1277 1277
             </div>
1278
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1278
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1279 1279
 
1280 1280
         <div class="row column">
1281 1281
             <div class="col-md-6">
@@ -1287,12 +1287,12 @@  discard block
 block discarded – undo
1287 1287
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1288 1288
 			$year_data = '';
1289 1289
 			$year_cnt = '';
1290
-			foreach($year_array as $year_item) {
1290
+			foreach ($year_array as $year_item) {
1291 1291
 				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
1292 1292
 				$year_cnt .= $year_item['count'].',';
1293 1293
 			}
1294 1294
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1295
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1295
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1296 1296
 			print 'c3.generate({
1297 1297
 			    bindto: "#chart33",
1298 1298
 			    data: { x: "x",
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1306 1306
                 </div>
1307 1307
             </div>
1308
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1308
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1309 1309
 <br/>
1310 1310
 <?php
1311 1311
 	}
@@ -1319,19 +1319,19 @@  discard block
 block discarded – undo
1319 1319
 	//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
1320 1320
 	if ($year == '' && $month == '') {
1321 1321
 		if ($type == 'aircraft') {
1322
-			$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
1322
+			$polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
1323 1323
 		} elseif ($type == 'marine') {
1324
-			$polar = $Stats->getStatsSource('polar_marine',date('Y'),date('m'),date('d'));
1324
+			$polar = $Stats->getStatsSource('polar_marine', date('Y'), date('m'), date('d'));
1325 1325
 		} elseif ($type == 'tracker') {
1326
-			$polar = $Stats->getStatsSource('polar_tracker',date('Y'),date('m'),date('d'));
1326
+			$polar = $Stats->getStatsSource('polar_tracker', date('Y'), date('m'), date('d'));
1327 1327
 		}
1328 1328
 	} else {
1329 1329
 		if ($type == 'aircraft') {
1330
-			$polar = $Stats->getStatsSource('polar',$year,$month);
1330
+			$polar = $Stats->getStatsSource('polar', $year, $month);
1331 1331
 		} elseif ($type == 'marine') {
1332
-			$polar = $Stats->getStatsSource('polar_marine',$year,$month);
1332
+			$polar = $Stats->getStatsSource('polar_marine', $year, $month);
1333 1333
 		} elseif ($type == 'tracker') {
1334
-			$polar = $Stats->getStatsSource('polar_tracker',$year,$month);
1334
+			$polar = $Stats->getStatsSource('polar_tracker', $year, $month);
1335 1335
 		}
1336 1336
 	}
1337 1337
 	if (!empty($polar)) {
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
 			unset($polar_data);
1341 1341
 			$Spotter = new Spotter();
1342 1342
 			$data = json_decode($eachpolar['source_data']);
1343
-			foreach($data as $value => $key) {
1343
+			foreach ($data as $value => $key) {
1344 1344
 				$direction = $Spotter->parseDirection(($value*22.5));
1345 1345
 				$distance = $key;
1346 1346
 				$unit = 'km';
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 ?>
1361 1361
             <div class="col-md-6">
1362 1362
                 <h4><?php print $eachpolar['source_name']; ?></h4>
1363
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1363
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1364 1364
         	<script>
1365 1365
         	    (function() {
1366 1366
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
 		      color: color,
1385 1385
 		      unit: '<?php echo $unit; ?>'
1386 1386
 		    };
1387
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1387
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1388 1388
 		    })();
1389 1389
 		</script>
1390 1390
             </div>
@@ -1399,19 +1399,19 @@  discard block
 block discarded – undo
1399 1399
 	//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1400 1400
 	if ($year == '' && $month == '') {
1401 1401
 		if ($type == 'aircraft') {
1402
-			$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1402
+			$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
1403 1403
 		} elseif ($type == 'marine') {
1404
-			$msg = $Stats->getStatsSource('msg_marine',date('Y'),date('m'),date('d'));
1404
+			$msg = $Stats->getStatsSource('msg_marine', date('Y'), date('m'), date('d'));
1405 1405
 		} elseif ($type == 'tracker') {
1406
-			$msg = $Stats->getStatsSource('msg_tracker',date('Y'),date('m'),date('d'));
1406
+			$msg = $Stats->getStatsSource('msg_tracker', date('Y'), date('m'), date('d'));
1407 1407
 		}
1408 1408
 	} else {
1409 1409
 		if ($type == 'aircraft') {
1410
-			$msg = $Stats->getStatsSource('msg',$year,$month);
1410
+			$msg = $Stats->getStatsSource('msg', $year, $month);
1411 1411
 		} elseif ($type == 'marine') {
1412
-			$msg = $Stats->getStatsSource('msg_marine',$year,$month);
1412
+			$msg = $Stats->getStatsSource('msg_marine', $year, $month);
1413 1413
 		} elseif ($type == 'tracker') {
1414
-			$msg = $Stats->getStatsSource('msg_tracker',$year,$month);
1414
+			$msg = $Stats->getStatsSource('msg_tracker', $year, $month);
1415 1415
 		}
1416 1416
 	}
1417 1417
 	if (!empty($msg)) {
@@ -1419,13 +1419,13 @@  discard block
 block discarded – undo
1419 1419
 		foreach ($msg as $eachmsg) {
1420 1420
 			//$eachmsg = $msg[0];
1421 1421
 			$data = $eachmsg['source_data'];
1422
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1422
+			if ($data > 500) $max = (round(($data + 100)/100))*100;
1423 1423
 			else $max = 500;
1424 1424
 ?>
1425
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1425
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1426 1426
         	<script>
1427 1427
 		      var g = new JustGage({
1428
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1428
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
1429 1429
 			    value: <?php echo $data; ?>,
1430 1430
 			    min: 0,
1431 1431
 			    max: <?php print $max; ?>,
@@ -1447,19 +1447,19 @@  discard block
 block discarded – undo
1447 1447
 	//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1448 1448
 	if ($year == '' && $month == '') {
1449 1449
 		if ($type == 'aircraft') {
1450
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1450
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
1451 1451
 		} elseif ($type == 'marine') {
1452
-			$hist = $Stats->getStatsSource('hist_marine',date('Y'),date('m'),date('d'));
1452
+			$hist = $Stats->getStatsSource('hist_marine', date('Y'), date('m'), date('d'));
1453 1453
 		} elseif ($type == 'tracker') {
1454
-			$hist = $Stats->getStatsSource('hist_tracker',date('Y'),date('m'),date('d'));
1454
+			$hist = $Stats->getStatsSource('hist_tracker', date('Y'), date('m'), date('d'));
1455 1455
 		}
1456 1456
 	} else {
1457 1457
 		if ($type == 'aircraft') {
1458
-			$hist = $Stats->getStatsSource('hist',$year,$month);
1458
+			$hist = $Stats->getStatsSource('hist', $year, $month);
1459 1459
 		} elseif ($type == 'marine') {
1460
-			$hist = $Stats->getStatsSource('hist_marine',$year,$month);
1460
+			$hist = $Stats->getStatsSource('hist_marine', $year, $month);
1461 1461
 		} elseif ($type == 'tracker') {
1462
-			$hist = $Stats->getStatsSource('hist_tracker',$year,$month);
1462
+			$hist = $Stats->getStatsSource('hist_tracker', $year, $month);
1463 1463
 		}
1464 1464
 	}
1465 1465
 	foreach ($hist as $hists) {
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 		$source = $hists['source_name'];
1470 1470
 		$hist_array = json_decode($hists['source_data']);
1471 1471
 		$unit = 'km';
1472
-		foreach($hist_array as $distance => $nb) {
1472
+		foreach ($hist_array as $distance => $nb) {
1473 1473
 			if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1474 1474
 				$distance = round($distance*0.539957);
1475 1475
 				$unit = 'nm';
@@ -1489,18 +1489,18 @@  discard block
 block discarded – undo
1489 1489
 		$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1490 1490
 ?>
1491 1491
             <div class="col-md-6">
1492
-                <h2><?php echo sprintf(_("Distance for %s"),$source); ?></h2>
1492
+                <h2><?php echo sprintf(_("Distance for %s"), $source); ?></h2>
1493 1493
 <?php
1494
-		print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1494
+		print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>';
1495 1495
 		print 'c3.generate({
1496
-		    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1496
+		    bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'",
1497 1497
 		    data: { x: "x",
1498 1498
 		    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1499 1499
 		    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1500 1500
 		print '</script>';
1501 1501
 ?>
1502 1502
     	    </div>
1503
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1503
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1504 1504
 <?php
1505 1505
 	}
1506 1506
 ?>
Please login to merge, or discard this patch.
Braces   +169 added lines, -80 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@  discard block
 block discarded – undo
22 22
 	require_once('require/class.Spotter.php');
23 23
 }
24 24
 
25
-if (!isset($filter_name)) $filter_name = '';
25
+if (!isset($filter_name)) {
26
+	$filter_name = '';
27
+}
26 28
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 29
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
-}
30
+	if (isset($globalFilter['airline'])) {
31
+		$airline_icao = $globalFilter['airline'][0];
32
+	}
33
+	}
30 34
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 35
 	$Spotter = new Spotter();
32 36
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -73,7 +82,9 @@  discard block
 block discarded – undo
73 82
 if (isset($last_update[0]['value'])) {
74 83
 	date_default_timezone_set('UTC');
75 84
 	$lastupdate = strtotime($last_update[0]['value']);
76
-	if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
85
+	if (isset($globalTimezone) && $globalTimezone != '') {
86
+		date_default_timezone_set($globalTimezone);
87
+	}
77 88
 	print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
78 89
 }
79 90
 
@@ -158,8 +169,11 @@  discard block
 block discarded – undo
158 169
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
159 170
 		$aircraft_data = '';
160 171
 		foreach($aircraft_array as $aircraft_item) {
161
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
173
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
174
+			} else {
175
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
176
+			}
163 177
 		}
164 178
 		$aircraft_data = substr($aircraft_data, 0, -1);
165 179
 		print 'var series = ['.$aircraft_data.'];';
@@ -176,11 +190,17 @@  discard block
 block discarded – undo
176 190
 <?php
177 191
 	if ($year != '' && $month != '') {
178 192
 ?>
179
-            	    <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>
193
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
194
+	echo '/'.$airline_icao;
195
+}
196
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 197
 <?php
181 198
 	} else {
182 199
 ?>
183
-            	    <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>
200
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
201
+	echo '/'.$airline_icao;
202
+}
203
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
184 204
 <?php
185 205
 	}
186 206
 ?>
@@ -209,11 +229,15 @@  discard block
 block discarded – undo
209 229
 			print '</script>';
210 230
 			if ($year != '' && $month != '') {
211 231
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
232
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
233
+					echo '/'.$airline_icao;
234
+				}
213 235
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 236
 			} else {
215 237
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
216
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
238
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
239
+					echo '/'.$airline_icao;
240
+				}
217 241
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
218 242
 			}
219 243
 			print '</div>';
@@ -233,8 +257,9 @@  discard block
 block discarded – undo
233 257
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234 258
 <?php
235 259
 	$marine_array = $Stats->countAllMarineTypes(true,0,'',$filter_name,$year,$month);
236
-	if (count($marine_array) == 0) print _("No data available");
237
-	else {
260
+	if (count($marine_array) == 0) {
261
+		print _("No data available");
262
+	} else {
238 263
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
239 264
 		$marine_data = '';
240 265
 		foreach($marine_array as $marine_item) {
@@ -277,8 +302,9 @@  discard block
 block discarded – undo
277 302
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
278 303
 <?php
279 304
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
280
-	if (count($tracker_array) == 0) print _("No data available");
281
-	else {
305
+	if (count($tracker_array) == 0) {
306
+		print _("No data available");
307
+	} else {
282 308
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
283 309
 		$tracker_data = '';
284 310
 		foreach($tracker_array as $tracker_item) {
@@ -322,8 +348,9 @@  discard block
 block discarded – undo
322 348
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
323 349
 <?php
324 350
 		$owner_array = $Satellite->countAllOwners(true);
325
-		if (count($owner_array) == 0) print _("No data available");
326
-		else {
351
+		if (count($owner_array) == 0) {
352
+			print _("No data available");
353
+		} else {
327 354
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
328 355
 			$owner_data = '';
329 356
 			foreach($owner_array as $owner_item) {
@@ -342,7 +369,10 @@  discard block
 block discarded – undo
342 369
 ?>
343 370
                <!--
344 371
                 <div class="more">
345
-                    <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>
372
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
373
+	echo '/'.$airline_icao;
374
+}
375
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
346 376
                 </div>
347 377
                 -->
348 378
             </div>
@@ -351,8 +381,9 @@  discard block
 block discarded – undo
351 381
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
352 382
 <?php
353 383
 		$countries_array = $Satellite->countAllCountriesOwners(true);
354
-		if (count($countries_array) == 0) print _("No data available");
355
-		else {
384
+		if (count($countries_array) == 0) {
385
+			print _("No data available");
386
+		} else {
356 387
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
357 388
 			$owner_data = '';
358 389
 			foreach($countries_array as $owner_item) {
@@ -371,7 +402,10 @@  discard block
 block discarded – undo
371 402
 ?>
372 403
 	    <!--
373 404
                 <div class="more">
374
-                    <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>
405
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
406
+	echo '/'.$airline_icao;
407
+}
408
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
375 409
                 </div>
376 410
                 -->
377 411
             </div>
@@ -383,8 +417,9 @@  discard block
 block discarded – undo
383 417
                 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
384 418
 <?php
385 419
 		$launch_site_array = $Satellite->countAllLaunchSite(true);
386
-		if (count($launch_site_array) == 0) print _("No data available");
387
-		else {
420
+		if (count($launch_site_array) == 0) {
421
+			print _("No data available");
422
+		} else {
388 423
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
389 424
 			$launch_site_data = '';
390 425
 			foreach($launch_site_array as $launch_site_item) {
@@ -403,7 +438,10 @@  discard block
 block discarded – undo
403 438
 ?>
404 439
                <!--
405 440
                 <div class="more">
406
-                    <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>
441
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
442
+	echo '/'.$airline_icao;
443
+}
444
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
407 445
                 </div>
408 446
                 -->
409 447
             </div>
@@ -426,8 +464,9 @@  discard block
 block discarded – undo
426 464
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
427 465
 <?php
428 466
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
429
-		if (count($pilot_array) == 0) print _("No data available");
430
-		else {
467
+		if (count($pilot_array) == 0) {
468
+			print _("No data available");
469
+		} else {
431 470
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
432 471
 			$pilot_data = '';
433 472
 			foreach($pilot_array as $pilot_item) {
@@ -445,7 +484,9 @@  discard block
 block discarded – undo
445 484
 		}
446 485
 		print '<div class="more">';
447 486
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
448
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
487
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
488
+			echo '/'.$airline_icao;
489
+		}
449 490
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
450 491
 		print '</div>';
451 492
 ?>
@@ -461,8 +502,9 @@  discard block
 block discarded – undo
461 502
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
462 503
 <?php
463 504
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
464
-		if (count($owner_array) == 0) print _("No data available");
465
-		else {
505
+		if (count($owner_array) == 0) {
506
+			print _("No data available");
507
+		} else {
466 508
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
467 509
 			$owner_data = '';
468 510
 			foreach($owner_array as $owner_item) {
@@ -480,7 +522,10 @@  discard block
 block discarded – undo
480 522
 		}
481 523
 ?>
482 524
                 <div class="more">
483
-                    <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>
525
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
526
+	echo '/'.$airline_icao;
527
+}
528
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
484 529
                 </div>
485 530
             </div>
486 531
         
@@ -493,8 +538,9 @@  discard block
 block discarded – undo
493 538
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
494 539
 <?php
495 540
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
496
-		if (count($flightover_array) == 0) print _("No data available");
497
-		else {
541
+		if (count($flightover_array) == 0) {
542
+			print _("No data available");
543
+		} else {
498 544
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
499 545
 			print 'var series = [';
500 546
 			$flightover_data = '';
@@ -536,7 +582,10 @@  discard block
 block discarded – undo
536 582
 		}
537 583
 ?>
538 584
                 <div class="more">
539
-                    <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>
585
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
586
+	echo '/'.$airline_icao;
587
+}
588
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
540 589
                 </div>
541 590
             </div>
542 591
 <?php
@@ -554,8 +603,9 @@  discard block
 block discarded – undo
554 603
 	<div class="col-md-6">
555 604
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
556 605
 <?php
557
-	if (count($flightover_array) == 0) print _("No data available");
558
-	else {
606
+	if (count($flightover_array) == 0) {
607
+		print _("No data available");
608
+	} else {
559 609
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
560 610
 		print 'var series = [';
561 611
 		$flightover_data = '';
@@ -611,8 +661,9 @@  discard block
 block discarded – undo
611 661
 	<div class="col-md-6">
612 662
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
613 663
 <?php
614
-	if (count($flightover_array) == 0) print _("No data available");
615
-	else {
664
+	if (count($flightover_array) == 0) {
665
+		print _("No data available");
666
+	} else {
616 667
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
617 668
 		print 'var series = [';
618 669
 		$flightover_data = '';
@@ -718,7 +769,9 @@  discard block
 block discarded – undo
718 769
 		});";
719 770
 		print '</script>';
720 771
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
721
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
772
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
773
+			echo '/'.$airline_icao;
774
+		}
722 775
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
723 776
 	}
724 777
 ?>
@@ -782,7 +835,9 @@  discard block
 block discarded – undo
782 835
 		});";
783 836
 		print '</script>';
784 837
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
785
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
838
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
839
+			echo '/'.$airline_icao;
840
+		}
786 841
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
787 842
 	}
788 843
 ?>
@@ -801,8 +856,9 @@  discard block
 block discarded – undo
801 856
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
802 857
 <?php
803 858
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
804
-		if (count($year_array) == 0) print _("No data available");
805
-		else {
859
+		if (count($year_array) == 0) {
860
+			print _("No data available");
861
+		} else {
806 862
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
807 863
 			$year_data = '';
808 864
 			$year_cnt = '';
@@ -821,7 +877,10 @@  discard block
 block discarded – undo
821 877
 		}
822 878
 ?>
823 879
                 <div class="more">
824
-                    <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>
880
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
881
+	echo '/'.$airline_icao;
882
+}
883
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
825 884
                 </div>
826 885
             </div>
827 886
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -829,8 +888,9 @@  discard block
 block discarded – undo
829 888
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
830 889
 <?php
831 890
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
832
-		if (count($month_array) == 0) print _("No data available");
833
-		else {
891
+		if (count($month_array) == 0) {
892
+			print _("No data available");
893
+		} else {
834 894
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
835 895
 			$month_data = '';
836 896
 			$month_cnt = '';
@@ -849,7 +909,10 @@  discard block
 block discarded – undo
849 909
 		}
850 910
 ?>
851 911
                 <div class="more">
852
-                    <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>
912
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
913
+	echo '/'.$airline_icao;
914
+}
915
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
853 916
                 </div>
854 917
             </div>
855 918
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -858,8 +921,9 @@  discard block
 block discarded – undo
858 921
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
859 922
 <?php
860 923
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
861
-		if (empty($date_array)) print _("No data available");
862
-		else {
924
+		if (empty($date_array)) {
925
+			print _("No data available");
926
+		} else {
863 927
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
864 928
 			$date_data = '';
865 929
 			$date_cnt = '';
@@ -878,7 +942,10 @@  discard block
 block discarded – undo
878 942
 		}
879 943
 ?>
880 944
                 <div class="more">
881
-                    <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>
945
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
946
+	echo '/'.$airline_icao;
947
+}
948
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
882 949
                 </div>
883 950
             </div>
884 951
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -886,8 +953,9 @@  discard block
 block discarded – undo
886 953
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
887 954
 <?php
888 955
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
889
-		if (empty($hour_array)) print _("No data available");
890
-		else {
956
+		if (empty($hour_array)) {
957
+			print _("No data available");
958
+		} else {
891 959
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
892 960
 			$hour_data = '';
893 961
 			$hour_cnt = '';
@@ -906,7 +974,10 @@  discard block
 block discarded – undo
906 974
 		}
907 975
 ?>
908 976
                 <div class="more">
909
-                    <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>
977
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
978
+	echo '/'.$airline_icao;
979
+}
980
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
910 981
                 </div>
911 982
             </div>
912 983
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -926,8 +997,9 @@  discard block
 block discarded – undo
926 997
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
927 998
 <?php
928 999
 		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
929
-		if (count($year_array) == 0) print _("No data available");
930
-		else {
1000
+		if (count($year_array) == 0) {
1001
+			print _("No data available");
1002
+		} else {
931 1003
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
932 1004
 			$year_data = '';
933 1005
 			$year_cnt = '';
@@ -955,8 +1027,9 @@  discard block
 block discarded – undo
955 1027
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
956 1028
 <?php
957 1029
 		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
958
-		if (count($month_array) == 0) print _("No data available");
959
-		else {
1030
+		if (count($month_array) == 0) {
1031
+			print _("No data available");
1032
+		} else {
960 1033
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
961 1034
 			$month_data = '';
962 1035
 			$month_cnt = '';
@@ -984,8 +1057,9 @@  discard block
 block discarded – undo
984 1057
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
985 1058
 <?php
986 1059
 		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
987
-		if (empty($date_array)) print _("No data available");
988
-		else {
1060
+		if (empty($date_array)) {
1061
+			print _("No data available");
1062
+		} else {
989 1063
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
990 1064
 			$date_data = '';
991 1065
 			$date_cnt = '';
@@ -1012,8 +1086,9 @@  discard block
 block discarded – undo
1012 1086
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1013 1087
 <?php
1014 1088
 		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1015
-		if (empty($hour_array)) print _("No data available");
1016
-		else {
1089
+		if (empty($hour_array)) {
1090
+			print _("No data available");
1091
+		} else {
1017 1092
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1018 1093
 			$hour_data = '';
1019 1094
 			$hour_cnt = '';
@@ -1052,8 +1127,9 @@  discard block
 block discarded – undo
1052 1127
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1053 1128
 <?php
1054 1129
 		$year_array = $Tracker->countAllMonthsLastYear(true);
1055
-		if (count($year_array) == 0) print _("No data available");
1056
-		else {
1130
+		if (count($year_array) == 0) {
1131
+			print _("No data available");
1132
+		} else {
1057 1133
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1058 1134
 			$year_data = '';
1059 1135
 			$year_cnt = '';
@@ -1081,8 +1157,9 @@  discard block
 block discarded – undo
1081 1157
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1082 1158
 <?php
1083 1159
 		$month_array = $Tracker->countAllDatesLastMonth();
1084
-		if (count($month_array) == 0) print _("No data available");
1085
-		else {
1160
+		if (count($month_array) == 0) {
1161
+			print _("No data available");
1162
+		} else {
1086 1163
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1087 1164
 			$month_data = '';
1088 1165
 			$month_cnt = '';
@@ -1110,8 +1187,9 @@  discard block
 block discarded – undo
1110 1187
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1111 1188
 <?php
1112 1189
 		$date_array = $Tracker->countAllDatesLast7Days();
1113
-		if (empty($date_array)) print _("No data available");
1114
-		else {
1190
+		if (empty($date_array)) {
1191
+			print _("No data available");
1192
+		} else {
1115 1193
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1116 1194
 			$date_data = '';
1117 1195
 			$date_cnt = '';
@@ -1138,8 +1216,9 @@  discard block
 block discarded – undo
1138 1216
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1139 1217
 <?php
1140 1218
 		$hour_array = $Tracker->countAllHours('hour',true);
1141
-		if (empty($hour_array)) print _("No data available");
1142
-		else {
1219
+		if (empty($hour_array)) {
1220
+			print _("No data available");
1221
+		} else {
1143 1222
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1144 1223
 			$hour_data = '';
1145 1224
 			$hour_cnt = '';
@@ -1178,8 +1257,9 @@  discard block
 block discarded – undo
1178 1257
                 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1179 1258
 <?php
1180 1259
 		$year_array = $Satellite->countAllMonthsLastYear();
1181
-		if (count($year_array) == 0) print _("No data available");
1182
-		else {
1260
+		if (count($year_array) == 0) {
1261
+			print _("No data available");
1262
+		} else {
1183 1263
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1184 1264
 			$year_data = '';
1185 1265
 			$year_cnt = '';
@@ -1209,8 +1289,9 @@  discard block
 block discarded – undo
1209 1289
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1210 1290
 <?php
1211 1291
 		$year_array = $Satellite->countAllYears();
1212
-		if (count($year_array) == 0) print _("No data available");
1213
-		else {
1292
+		if (count($year_array) == 0) {
1293
+			print _("No data available");
1294
+		} else {
1214 1295
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1215 1296
 			$year_data = '';
1216 1297
 			$year_cnt = '';
@@ -1252,8 +1333,9 @@  discard block
 block discarded – undo
1252 1333
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1253 1334
 <?php
1254 1335
 		$year_array = $Stats->countFatalitiesByYear();
1255
-		if (count($year_array) == 0) print _("No data available");
1256
-		else {
1336
+		if (count($year_array) == 0) {
1337
+			print _("No data available");
1338
+		} else {
1257 1339
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1258 1340
 			$year_data = '';
1259 1341
 			$year_cnt = '';
@@ -1282,8 +1364,9 @@  discard block
 block discarded – undo
1282 1364
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1283 1365
 <?php
1284 1366
 		$year_array = $Stats->countFatalitiesLast12Months();
1285
-		if (count($year_array) == 0) print _("No data available");
1286
-		else {
1367
+		if (count($year_array) == 0) {
1368
+			print _("No data available");
1369
+		} else {
1287 1370
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1288 1371
 			$year_data = '';
1289 1372
 			$year_cnt = '';
@@ -1354,8 +1437,11 @@  discard block
 block discarded – undo
1354 1437
 					$distance = $distance;
1355 1438
 					$unit = 'km';
1356 1439
 				}
1357
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1358
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1440
+				if (!isset($polar_data)) {
1441
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1442
+				} else {
1443
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1444
+				}
1359 1445
 			}
1360 1446
 ?>
1361 1447
             <div class="col-md-6">
@@ -1419,9 +1505,12 @@  discard block
 block discarded – undo
1419 1505
 		foreach ($msg as $eachmsg) {
1420 1506
 			//$eachmsg = $msg[0];
1421 1507
 			$data = $eachmsg['source_data'];
1422
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1423
-			else $max = 500;
1424
-?>
1508
+			if ($data > 500) {
1509
+				$max = (round(($data+100)/100))*100;
1510
+			} else {
1511
+				$max = 500;
1512
+			}
1513
+			?>
1425 1514
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1426 1515
         	<script>
1427 1516
 		      var g = new JustGage({
Please login to merge, or discard this patch.
install/class.update_schema.php 2 patches
Spacing   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -814,17 +814,17 @@  discard block
 block discarded – undo
814 814
 			try {
815 815
 				$sth = $Connection->db->prepare($query);
816 816
 				$sth->execute();
817
-			} catch(PDOException $e) {
817
+			} catch (PDOException $e) {
818 818
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
819 819
 			}
820 820
 		}
821
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
821
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
822 822
 			// Add aircraft_manufacturer to stats_aircraft
823 823
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824 824
 			try {
825 825
 				$sth = $Connection->db->prepare($query);
826 826
 				$sth->execute();
827
-			} catch(PDOException $e) {
827
+			} catch (PDOException $e) {
828 828
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
829 829
     			}
830 830
     		}
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 		try {
834 834
 			$sth = $Connection->db->prepare($query);
835 835
 			$sth->execute();
836
-		} catch(PDOException $e) {
836
+		} catch (PDOException $e) {
837 837
 			return "error (update schema_version) : ".$e->getMessage()."\n";
838 838
 		}
839 839
 		return $error;
@@ -849,23 +849,23 @@  discard block
 block discarded – undo
849 849
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 850
 		}
851 851
 		if ($error != '') return 'Import airlines.sql : '.$error;
852
-		if (!$Connection->checkColumnName('airlines','forsource')) {
852
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
853 853
 			// Add forsource to airlines
854 854
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
855 855
 			try {
856 856
 				$sth = $Connection->db->prepare($query);
857 857
 				$sth->execute();
858
-			} catch(PDOException $e) {
858
+			} catch (PDOException $e) {
859 859
 				return "error (add forsource column) : ".$e->getMessage()."\n";
860 860
 			}
861 861
 		}
862
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
862
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
863 863
 			// Add forsource to airlines
864 864
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
865 865
 			try {
866 866
 				$sth = $Connection->db->prepare($query);
867 867
 				$sth->execute();
868
-			} catch(PDOException $e) {
868
+			} catch (PDOException $e) {
869 869
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
870 870
 			}
871 871
 			// Add unique key
@@ -877,17 +877,17 @@  discard block
 block discarded – undo
877 877
 			try {
878 878
 				$sth = $Connection->db->prepare($query);
879 879
 				$sth->execute();
880
-			} catch(PDOException $e) {
880
+			} catch (PDOException $e) {
881 881
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
882 882
 			}
883 883
 		}
884
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
884
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
885 885
 			// Add forsource to airlines
886 886
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
887 887
 			try {
888 888
 				$sth = $Connection->db->prepare($query);
889 889
 				$sth->execute();
890
-			} catch(PDOException $e) {
890
+			} catch (PDOException $e) {
891 891
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
892 892
 			}
893 893
 			// Add unique key
@@ -899,17 +899,17 @@  discard block
 block discarded – undo
899 899
 			try {
900 900
 				$sth = $Connection->db->prepare($query);
901 901
 				$sth->execute();
902
-			} catch(PDOException $e) {
902
+			} catch (PDOException $e) {
903 903
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
904 904
 			}
905 905
 		}
906
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
906
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
907 907
 			// Add forsource to airlines
908 908
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
909 909
 			try {
910 910
 				$sth = $Connection->db->prepare($query);
911 911
 				$sth->execute();
912
-			} catch(PDOException $e) {
912
+			} catch (PDOException $e) {
913 913
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
914 914
 			}
915 915
 			// Add unique key
@@ -921,36 +921,36 @@  discard block
 block discarded – undo
921 921
 			try {
922 922
 				$sth = $Connection->db->prepare($query);
923 923
 				$sth->execute();
924
-			} catch(PDOException $e) {
924
+			} catch (PDOException $e) {
925 925
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
926 926
 			}
927 927
 		}
928
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
928
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
929 929
 			// Add forsource to airlines
930 930
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
931 931
 			try {
932 932
 				$sth = $Connection->db->prepare($query);
933 933
 				$sth->execute();
934
-			} catch(PDOException $e) {
934
+			} catch (PDOException $e) {
935 935
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
936 936
 			}
937 937
 		}
938
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
938
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
939 939
 			// Add forsource to airlines
940 940
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
941 941
 			try {
942 942
 				$sth = $Connection->db->prepare($query);
943 943
 				$sth->execute();
944
-			} catch(PDOException $e) {
944
+			} catch (PDOException $e) {
945 945
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
946 946
 			}
947
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
947
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
948 948
 				// Add unique key
949 949
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
950 950
 				try {
951 951
 					$sth = $Connection->db->prepare($query);
952 952
 					$sth->execute();
953
-				} catch(PDOException $e) {
953
+				} catch (PDOException $e) {
954 954
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
955 955
 				}
956 956
 			} else {
@@ -963,18 +963,18 @@  discard block
 block discarded – undo
963 963
 				try {
964 964
 					$sth = $Connection->db->prepare($query);
965 965
 					$sth->execute();
966
-				} catch(PDOException $e) {
966
+				} catch (PDOException $e) {
967 967
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
968 968
 				}
969 969
 			}
970 970
 		}
971
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
971
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
972 972
 			// Add forsource to airlines
973 973
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
974 974
 			try {
975 975
 				$sth = $Connection->db->prepare($query);
976 976
 				$sth->execute();
977
-			} catch(PDOException $e) {
977
+			} catch (PDOException $e) {
978 978
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
979 979
 			}
980 980
 			// Add unique key
@@ -986,17 +986,17 @@  discard block
 block discarded – undo
986 986
 			try {
987 987
 				$sth = $Connection->db->prepare($query);
988 988
 				$sth->execute();
989
-			} catch(PDOException $e) {
989
+			} catch (PDOException $e) {
990 990
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
991 991
 			}
992 992
 		}
993
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
993
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
994 994
 			// Add forsource to airlines
995 995
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
996 996
 			try {
997 997
 				$sth = $Connection->db->prepare($query);
998 998
 				$sth->execute();
999
-			} catch(PDOException $e) {
999
+			} catch (PDOException $e) {
1000 1000
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1001 1001
 			}
1002 1002
 			// Add unique key
@@ -1008,17 +1008,17 @@  discard block
 block discarded – undo
1008 1008
 			try {
1009 1009
 				$sth = $Connection->db->prepare($query);
1010 1010
 				$sth->execute();
1011
-			} catch(PDOException $e) {
1011
+			} catch (PDOException $e) {
1012 1012
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1013 1013
 			}
1014 1014
 		}
1015
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1015
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1016 1016
 			// Add forsource to airlines
1017 1017
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1018 1018
 			try {
1019 1019
 				$sth = $Connection->db->prepare($query);
1020 1020
 				$sth->execute();
1021
-			} catch(PDOException $e) {
1021
+			} catch (PDOException $e) {
1022 1022
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1023 1023
 			}
1024 1024
 			// Add unique key
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 			try {
1031 1031
 				$sth = $Connection->db->prepare($query);
1032 1032
 				$sth->execute();
1033
-			} catch(PDOException $e) {
1033
+			} catch (PDOException $e) {
1034 1034
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1035 1035
 			}
1036 1036
 		}
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 		try {
1040 1040
 			$sth = $Connection->db->prepare($query);
1041 1041
 			$sth->execute();
1042
-		} catch(PDOException $e) {
1042
+		} catch (PDOException $e) {
1043 1043
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1044 1044
 		}
1045 1045
 		return $error;
@@ -1049,13 +1049,13 @@  discard block
 block discarded – undo
1049 1049
 		global $globalDBdriver;
1050 1050
 		$Connection = new Connection();
1051 1051
 		$error = '';
1052
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1052
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1053 1053
 			// Add forsource to airlines
1054 1054
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1055 1055
 			try {
1056 1056
 				$sth = $Connection->db->prepare($query);
1057 1057
 				$sth->execute();
1058
-			} catch(PDOException $e) {
1058
+			} catch (PDOException $e) {
1059 1059
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1060 1060
 			}
1061 1061
 			// Add unique key
@@ -1067,17 +1067,17 @@  discard block
 block discarded – undo
1067 1067
 			try {
1068 1068
 				$sth = $Connection->db->prepare($query);
1069 1069
 				$sth->execute();
1070
-			} catch(PDOException $e) {
1070
+			} catch (PDOException $e) {
1071 1071
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1072 1072
 			}
1073 1073
 		}
1074
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1074
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1075 1075
 			// Add forsource to airlines
1076 1076
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1077 1077
 			try {
1078 1078
 				$sth = $Connection->db->prepare($query);
1079 1079
 				$sth->execute();
1080
-			} catch(PDOException $e) {
1080
+			} catch (PDOException $e) {
1081 1081
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1082 1082
 			}
1083 1083
 			// Add unique key
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 			try {
1090 1090
 				$sth = $Connection->db->prepare($query);
1091 1091
 				$sth->execute();
1092
-			} catch(PDOException $e) {
1092
+			} catch (PDOException $e) {
1093 1093
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1094 1094
 			}
1095 1095
 		}
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 		try {
1098 1098
 			$sth = $Connection->db->prepare($query);
1099 1099
 			$sth->execute();
1100
-		} catch(PDOException $e) {
1100
+		} catch (PDOException $e) {
1101 1101
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1102 1102
 		}
1103 1103
 		return $error;
@@ -1107,12 +1107,12 @@  discard block
 block discarded – undo
1107 1107
 		global $globalDBdriver;
1108 1108
 		$Connection = new Connection();
1109 1109
 		$error = '';
1110
-		if (!$Connection->checkColumnName('atc','format_source')) {
1110
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1111 1111
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1112 1112
 			try {
1113 1113
 				$sth = $Connection->db->prepare($query);
1114 1114
 				$sth->execute();
1115
-			} catch(PDOException $e) {
1115
+			} catch (PDOException $e) {
1116 1116
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1117 1117
 			}
1118 1118
 		}
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 		try {
1121 1121
 			$sth = $Connection->db->prepare($query);
1122 1122
 			$sth->execute();
1123
-		} catch(PDOException $e) {
1123
+		} catch (PDOException $e) {
1124 1124
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1125 1125
 		}
1126 1126
 		return $error;
@@ -1130,13 +1130,13 @@  discard block
 block discarded – undo
1130 1130
 		global $globalDBdriver;
1131 1131
 		$Connection = new Connection();
1132 1132
 		$error = '';
1133
-		if (!$Connection->checkColumnName('stats_pilot','format_source')) {
1133
+		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) {
1134 1134
 			// Add forsource to airlines
1135 1135
 			$query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''";
1136 1136
 			try {
1137 1137
 				$sth = $Connection->db->prepare($query);
1138 1138
 				$sth->execute();
1139
-			} catch(PDOException $e) {
1139
+			} catch (PDOException $e) {
1140 1140
 				return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n";
1141 1141
 			}
1142 1142
 			// Add unique key
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
 			try {
1149 1149
 				$sth = $Connection->db->prepare($query);
1150 1150
 				$sth->execute();
1151
-			} catch(PDOException $e) {
1151
+			} catch (PDOException $e) {
1152 1152
 				return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n";
1153 1153
 			}
1154 1154
 		}
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 		try {
1157 1157
 			$sth = $Connection->db->prepare($query);
1158 1158
 			$sth->execute();
1159
-		} catch(PDOException $e) {
1159
+		} catch (PDOException $e) {
1160 1160
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1161 1161
 		}
1162 1162
 		return $error;
@@ -1166,23 +1166,23 @@  discard block
 block discarded – undo
1166 1166
 		global $globalDBdriver;
1167 1167
 		$Connection = new Connection();
1168 1168
 		$error = '';
1169
-		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) {
1169
+		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) {
1170 1170
 			// Add unique key
1171 1171
 			$query = "alter table spotter_live add index(latitude,longitude)";
1172 1172
 			try {
1173 1173
 				$sth = $Connection->db->prepare($query);
1174 1174
 				$sth->execute();
1175
-			} catch(PDOException $e) {
1175
+			} catch (PDOException $e) {
1176 1176
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1177 1177
 			}
1178 1178
                 }
1179
-		if (!$Connection->checkColumnName('aircraft','mfr')) {
1179
+		if (!$Connection->checkColumnName('aircraft', 'mfr')) {
1180 1180
 			// Add mfr to aircraft
1181 1181
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
1182 1182
 			try {
1183 1183
 				$sth = $Connection->db->prepare($query);
1184 1184
 				$sth->execute();
1185
-			} catch(PDOException $e) {
1185
+			} catch (PDOException $e) {
1186 1186
 				return "error (add mfr column in aircraft) : ".$e->getMessage()."\n";
1187 1187
 			}
1188 1188
 		}
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
 		try {
1199 1199
 			$sth = $Connection->db->prepare($query);
1200 1200
 			$sth->execute();
1201
-		} catch(PDOException $e) {
1201
+		} catch (PDOException $e) {
1202 1202
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1203 1203
 		}
1204 1204
 		return $error;
@@ -1208,13 +1208,13 @@  discard block
 block discarded – undo
1208 1208
 		global $globalDBdriver;
1209 1209
 		$Connection = new Connection();
1210 1210
 		$error = '';
1211
-		if ($Connection->checkColumnName('aircraft','mfr')) {
1211
+		if ($Connection->checkColumnName('aircraft', 'mfr')) {
1212 1212
 			// drop mfr to aircraft
1213 1213
 			$query = "ALTER TABLE aircraft DROP COLUMN mfr";
1214 1214
 			try {
1215 1215
 				$sth = $Connection->db->prepare($query);
1216 1216
 				$sth->execute();
1217
-			} catch(PDOException $e) {
1217
+			} catch (PDOException $e) {
1218 1218
 				return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n";
1219 1219
 			}
1220 1220
 		}
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 		try {
1231 1231
 			$sth = $Connection->db->prepare($query);
1232 1232
 			$sth->execute();
1233
-		} catch(PDOException $e) {
1233
+		} catch (PDOException $e) {
1234 1234
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1235 1235
 		}
1236 1236
 		return $error;
@@ -1240,33 +1240,33 @@  discard block
 block discarded – undo
1240 1240
 		global $globalDBdriver;
1241 1241
 		$Connection = new Connection();
1242 1242
 		$error = '';
1243
-		if (!$Connection->indexExists('notam','ref_idx')) {
1243
+		if (!$Connection->indexExists('notam', 'ref_idx')) {
1244 1244
 			// Add index key
1245 1245
 			$query = "create index ref_idx on notam (ref)";
1246 1246
 			try {
1247 1247
 				$sth = $Connection->db->prepare($query);
1248 1248
 				$sth->execute();
1249
-			} catch(PDOException $e) {
1249
+			} catch (PDOException $e) {
1250 1250
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1251 1251
 			}
1252 1252
                 }
1253
-		if (!$Connection->indexExists('accidents','registration_idx')) {
1253
+		if (!$Connection->indexExists('accidents', 'registration_idx')) {
1254 1254
 			// Add index key
1255 1255
 			$query = "create index registration_idx on accidents (registration)";
1256 1256
 			try {
1257 1257
 				$sth = $Connection->db->prepare($query);
1258 1258
 				$sth->execute();
1259
-			} catch(PDOException $e) {
1259
+			} catch (PDOException $e) {
1260 1260
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1261 1261
 			}
1262 1262
                 }
1263
-		if (!$Connection->indexExists('accidents','rdts')) {
1263
+		if (!$Connection->indexExists('accidents', 'rdts')) {
1264 1264
 			// Add index key
1265 1265
 			$query = "create index rdts on accidents (registration,date,type,source)";
1266 1266
 			try {
1267 1267
 				$sth = $Connection->db->prepare($query);
1268 1268
 				$sth->execute();
1269
-			} catch(PDOException $e) {
1269
+			} catch (PDOException $e) {
1270 1270
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1271 1271
 			}
1272 1272
                 }
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
 		try {
1276 1276
 			$sth = $Connection->db->prepare($query);
1277 1277
 			$sth->execute();
1278
-		} catch(PDOException $e) {
1278
+		} catch (PDOException $e) {
1279 1279
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1280 1280
 		}
1281 1281
 		return $error;
@@ -1285,23 +1285,23 @@  discard block
 block discarded – undo
1285 1285
 		global $globalDBdriver;
1286 1286
 		$Connection = new Connection();
1287 1287
 		$error = '';
1288
-		if (!$Connection->checkColumnName('accidents','airline_name')) {
1288
+		if (!$Connection->checkColumnName('accidents', 'airline_name')) {
1289 1289
 			// Add airline_name to accidents
1290 1290
 			$query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL";
1291 1291
 			try {
1292 1292
 				$sth = $Connection->db->prepare($query);
1293 1293
 				$sth->execute();
1294
-			} catch(PDOException $e) {
1294
+			} catch (PDOException $e) {
1295 1295
 				return "error (add airline_name column in accidents) : ".$e->getMessage()."\n";
1296 1296
 			}
1297 1297
 		}
1298
-		if (!$Connection->checkColumnName('accidents','airline_icao')) {
1298
+		if (!$Connection->checkColumnName('accidents', 'airline_icao')) {
1299 1299
 			// Add airline_icao to accidents
1300 1300
 			$query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL";
1301 1301
 			try {
1302 1302
 				$sth = $Connection->db->prepare($query);
1303 1303
 				$sth->execute();
1304
-			} catch(PDOException $e) {
1304
+			} catch (PDOException $e) {
1305 1305
 				return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n";
1306 1306
 			}
1307 1307
 		}
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
 		try {
1310 1310
 			$sth = $Connection->db->prepare($query);
1311 1311
 			$sth->execute();
1312
-		} catch(PDOException $e) {
1312
+		} catch (PDOException $e) {
1313 1313
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1314 1314
 		}
1315 1315
 		return $error;
@@ -1319,13 +1319,13 @@  discard block
 block discarded – undo
1319 1319
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1320 1320
 		$Connection = new Connection();
1321 1321
 		$error = '';
1322
-		if (!$Connection->checkColumnName('airlines','alliance')) {
1322
+		if (!$Connection->checkColumnName('airlines', 'alliance')) {
1323 1323
 			// Add alliance to airlines
1324 1324
 			$query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL";
1325 1325
 			try {
1326 1326
 				$sth = $Connection->db->prepare($query);
1327 1327
 				$sth->execute();
1328
-			} catch(PDOException $e) {
1328
+			} catch (PDOException $e) {
1329 1329
 				return "error (add alliance column in airlines) : ".$e->getMessage()."\n";
1330 1330
 			}
1331 1331
 		}
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
 		try {
1353 1353
 			$sth = $Connection->db->prepare($query);
1354 1354
 			$sth->execute();
1355
-		} catch(PDOException $e) {
1355
+		} catch (PDOException $e) {
1356 1356
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1357 1357
 		}
1358 1358
 		return $error;
@@ -1362,13 +1362,13 @@  discard block
 block discarded – undo
1362 1362
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1363 1363
 		$Connection = new Connection();
1364 1364
 		$error = '';
1365
-		if (!$Connection->checkColumnName('airlines','ban_eu')) {
1365
+		if (!$Connection->checkColumnName('airlines', 'ban_eu')) {
1366 1366
 			// Add ban_eu to airlines
1367 1367
 			$query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'";
1368 1368
 			try {
1369 1369
 				$sth = $Connection->db->prepare($query);
1370 1370
 				$sth->execute();
1371
-			} catch(PDOException $e) {
1371
+			} catch (PDOException $e) {
1372 1372
 				return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n";
1373 1373
 			}
1374 1374
 		}
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 		try {
1377 1377
 			$sth = $Connection->db->prepare($query);
1378 1378
 			$sth->execute();
1379
-		} catch(PDOException $e) {
1379
+		} catch (PDOException $e) {
1380 1380
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1381 1381
 		}
1382 1382
 		return $error;
@@ -1387,19 +1387,19 @@  discard block
 block discarded – undo
1387 1387
 		$Connection = new Connection();
1388 1388
 		$error = '';
1389 1389
 		if ($globalDBdriver == 'mysql') {
1390
-			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') {
1390
+			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') {
1391 1391
 				$query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL";
1392 1392
 				try {
1393 1393
 					$sth = $Connection->db->prepare($query);
1394 1394
 					$sth->execute();
1395
-				} catch(PDOException $e) {
1395
+				} catch (PDOException $e) {
1396 1396
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1397 1397
 				}
1398 1398
 				$query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1399 1399
 				try {
1400 1400
 					$sth = $Connection->db->prepare($query);
1401 1401
 					$sth->execute();
1402
-				} catch(PDOException $e) {
1402
+				} catch (PDOException $e) {
1403 1403
 					return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1404 1404
 				}
1405 1405
 				
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 				try {
1408 1408
 					$sth = $Connection->db->prepare($query);
1409 1409
 					$sth->execute();
1410
-				} catch(PDOException $e) {
1410
+				} catch (PDOException $e) {
1411 1411
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1412 1412
 				}
1413 1413
 				/*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150";
@@ -1458,7 +1458,7 @@  discard block
 block discarded – undo
1458 1458
 				try {
1459 1459
 					$sth = $Connection->db->prepare($query);
1460 1460
 					$sth->execute();
1461
-				} catch(PDOException $e) {
1461
+				} catch (PDOException $e) {
1462 1462
 					return "error (fix date) : ".$e->getMessage()."\n";
1463 1463
 				}
1464 1464
 			}
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
 		try {
1544 1544
 			$sth = $Connection->db->prepare($query);
1545 1545
 			$sth->execute();
1546
-		} catch(PDOException $e) {
1546
+		} catch (PDOException $e) {
1547 1547
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1548 1548
 		}
1549 1549
 		return $error;
@@ -1552,13 +1552,13 @@  discard block
 block discarded – undo
1552 1552
 		global $globalDBdriver;
1553 1553
 		$Connection = new Connection();
1554 1554
 		$error = '';
1555
-		if (!$Connection->indexExists('accidents','type')) {
1555
+		if (!$Connection->indexExists('accidents', 'type')) {
1556 1556
 			// Add index key
1557 1557
 			$query = "create index type on accidents (type,date)";
1558 1558
 			try {
1559 1559
 				$sth = $Connection->db->prepare($query);
1560 1560
 				$sth->execute();
1561
-			} catch(PDOException $e) {
1561
+			} catch (PDOException $e) {
1562 1562
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1563 1563
 			}
1564 1564
                 }
@@ -1566,7 +1566,7 @@  discard block
 block discarded – undo
1566 1566
 		try {
1567 1567
 			$sth = $Connection->db->prepare($query);
1568 1568
 			$sth->execute();
1569
-		} catch(PDOException $e) {
1569
+		} catch (PDOException $e) {
1570 1570
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1571 1571
 		}
1572 1572
 		return $error;
@@ -1576,12 +1576,12 @@  discard block
 block discarded – undo
1576 1576
 		global $globalDBdriver;
1577 1577
 		$Connection = new Connection();
1578 1578
 		$error = '';
1579
-		if (!$Connection->checkColumnName('aircraft_modes','source_type')) {
1579
+		if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) {
1580 1580
 			$query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'";
1581 1581
 			try {
1582 1582
 				$sth = $Connection->db->prepare($query);
1583 1583
 				$sth->execute();
1584
-			} catch(PDOException $e) {
1584
+			} catch (PDOException $e) {
1585 1585
 				return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n";
1586 1586
 			}
1587 1587
 		}
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
 		try {
1648 1648
 			$sth = $Connection->db->prepare($query);
1649 1649
 			$sth->execute();
1650
-		} catch(PDOException $e) {
1650
+		} catch (PDOException $e) {
1651 1651
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1652 1652
 		}
1653 1653
 		return $error;
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 			try {
1700 1700
 				$sth = $Connection->db->prepare($query);
1701 1701
 				$sth->execute();
1702
-			} catch(PDOException $e) {
1702
+			} catch (PDOException $e) {
1703 1703
 				return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
1704 1704
 			}
1705 1705
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1708,18 +1708,18 @@  discard block
 block discarded – undo
1708 1708
 				try {
1709 1709
 					$sth = $Connection->db->prepare($query);
1710 1710
 					$sth->execute();
1711
-				} catch(PDOException $e) {
1711
+				} catch (PDOException $e) {
1712 1712
 					return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n";
1713 1713
 				}
1714 1714
 			}
1715 1715
 		}
1716
-		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) {
1716
+		if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) {
1717 1717
 			// Add index key
1718 1718
 			$query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)";
1719 1719
 			try {
1720 1720
 				$sth = $Connection->db->prepare($query);
1721 1721
 				$sth->execute();
1722
-			} catch(PDOException $e) {
1722
+			} catch (PDOException $e) {
1723 1723
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1724 1724
 			}
1725 1725
                 }
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
 		try {
1728 1728
 			$sth = $Connection->db->prepare($query);
1729 1729
 			$sth->execute();
1730
-		} catch(PDOException $e) {
1730
+		} catch (PDOException $e) {
1731 1731
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1732 1732
 		}
1733 1733
 		return $error;
@@ -1738,148 +1738,148 @@  discard block
 block discarded – undo
1738 1738
 		$Connection = new Connection();
1739 1739
 		$error = '';
1740 1740
 		if ($globalDBdriver == 'mysql') {
1741
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1741
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1742 1742
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL";
1743 1743
 				try {
1744 1744
 					$sth = $Connection->db->prepare($query);
1745 1745
 					$sth->execute();
1746
-				} catch(PDOException $e) {
1746
+				} catch (PDOException $e) {
1747 1747
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1748 1748
 				}
1749 1749
 			}
1750
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1750
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1751 1751
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL";
1752 1752
 				try {
1753 1753
 					$sth = $Connection->db->prepare($query);
1754 1754
 					$sth->execute();
1755
-				} catch(PDOException $e) {
1755
+				} catch (PDOException $e) {
1756 1756
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1757 1757
 				}
1758 1758
 			}
1759
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1759
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1760 1760
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL";
1761 1761
 				try {
1762 1762
 					$sth = $Connection->db->prepare($query);
1763 1763
 					$sth->execute();
1764
-				} catch(PDOException $e) {
1764
+				} catch (PDOException $e) {
1765 1765
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1766 1766
 				}
1767 1767
 			}
1768
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1768
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1769 1769
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL";
1770 1770
 				try {
1771 1771
 					$sth = $Connection->db->prepare($query);
1772 1772
 					$sth->execute();
1773
-				} catch(PDOException $e) {
1773
+				} catch (PDOException $e) {
1774 1774
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1775 1775
 				}
1776 1776
 			}
1777
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1777
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1778 1778
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL";
1779 1779
 				try {
1780 1780
 					$sth = $Connection->db->prepare($query);
1781 1781
 					$sth->execute();
1782
-				} catch(PDOException $e) {
1782
+				} catch (PDOException $e) {
1783 1783
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1784 1784
 				}
1785 1785
 			}
1786
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1786
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1787 1787
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL";
1788 1788
 				try {
1789 1789
 					$sth = $Connection->db->prepare($query);
1790 1790
 					$sth->execute();
1791
-				} catch(PDOException $e) {
1791
+				} catch (PDOException $e) {
1792 1792
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1793 1793
 				}
1794 1794
 			}
1795
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1795
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1796 1796
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL";
1797 1797
 				try {
1798 1798
 					$sth = $Connection->db->prepare($query);
1799 1799
 					$sth->execute();
1800
-				} catch(PDOException $e) {
1800
+				} catch (PDOException $e) {
1801 1801
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1802 1802
 				}
1803 1803
 			}
1804
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1804
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1805 1805
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL";
1806 1806
 				try {
1807 1807
 					$sth = $Connection->db->prepare($query);
1808 1808
 					$sth->execute();
1809
-				} catch(PDOException $e) {
1809
+				} catch (PDOException $e) {
1810 1810
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1811 1811
 				}
1812 1812
 			}
1813 1813
 		} else {
1814
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1814
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1815 1815
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL";
1816 1816
 				try {
1817 1817
 					$sth = $Connection->db->prepare($query);
1818 1818
 					$sth->execute();
1819
-				} catch(PDOException $e) {
1819
+				} catch (PDOException $e) {
1820 1820
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1821 1821
 				}
1822 1822
 			}
1823
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1823
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1824 1824
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL";
1825 1825
 				try {
1826 1826
 					$sth = $Connection->db->prepare($query);
1827 1827
 					$sth->execute();
1828
-				} catch(PDOException $e) {
1828
+				} catch (PDOException $e) {
1829 1829
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1830 1830
 				}
1831 1831
 			}
1832
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1832
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1833 1833
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL";
1834 1834
 				try {
1835 1835
 					$sth = $Connection->db->prepare($query);
1836 1836
 					$sth->execute();
1837
-				} catch(PDOException $e) {
1837
+				} catch (PDOException $e) {
1838 1838
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1839 1839
 				}
1840 1840
 			}
1841
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1841
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1842 1842
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL";
1843 1843
 				try {
1844 1844
 					$sth = $Connection->db->prepare($query);
1845 1845
 					$sth->execute();
1846
-				} catch(PDOException $e) {
1846
+				} catch (PDOException $e) {
1847 1847
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1848 1848
 				}
1849 1849
 			}
1850
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1850
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1851 1851
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL";
1852 1852
 				try {
1853 1853
 					$sth = $Connection->db->prepare($query);
1854 1854
 					$sth->execute();
1855
-				} catch(PDOException $e) {
1855
+				} catch (PDOException $e) {
1856 1856
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1857 1857
 				}
1858 1858
 			}
1859
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1859
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1860 1860
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL";
1861 1861
 				try {
1862 1862
 					$sth = $Connection->db->prepare($query);
1863 1863
 					$sth->execute();
1864
-				} catch(PDOException $e) {
1864
+				} catch (PDOException $e) {
1865 1865
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1866 1866
 				}
1867 1867
 			}
1868
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1868
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1869 1869
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL";
1870 1870
 				try {
1871 1871
 					$sth = $Connection->db->prepare($query);
1872 1872
 					$sth->execute();
1873
-				} catch(PDOException $e) {
1873
+				} catch (PDOException $e) {
1874 1874
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1875 1875
 				}
1876 1876
 			}
1877
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1877
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1878 1878
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL";
1879 1879
 				try {
1880 1880
 					$sth = $Connection->db->prepare($query);
1881 1881
 					$sth->execute();
1882
-				} catch(PDOException $e) {
1882
+				} catch (PDOException $e) {
1883 1883
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1884 1884
 				}
1885 1885
 			}
@@ -1888,7 +1888,7 @@  discard block
 block discarded – undo
1888 1888
 		try {
1889 1889
 			$sth = $Connection->db->prepare($query);
1890 1890
 			$sth->execute();
1891
-		} catch(PDOException $e) {
1891
+		} catch (PDOException $e) {
1892 1892
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1893 1893
 		}
1894 1894
 		return $error;
@@ -1903,14 +1903,14 @@  discard block
 block discarded – undo
1903 1903
 			try {
1904 1904
 				$sth = $Connection->db->prepare($query);
1905 1905
 				$sth->execute();
1906
-			} catch(PDOException $e) {
1906
+			} catch (PDOException $e) {
1907 1907
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1908 1908
 			}
1909 1909
 			$query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL";
1910 1910
 			try {
1911 1911
 				$sth = $Connection->db->prepare($query);
1912 1912
 				$sth->execute();
1913
-			} catch(PDOException $e) {
1913
+			} catch (PDOException $e) {
1914 1914
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1915 1915
 			}
1916 1916
 		} else {
@@ -1918,14 +1918,14 @@  discard block
 block discarded – undo
1918 1918
 			try {
1919 1919
 				$sth = $Connection->db->prepare($query);
1920 1920
 				$sth->execute();
1921
-			} catch(PDOException $e) {
1921
+			} catch (PDOException $e) {
1922 1922
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1923 1923
 			}
1924 1924
 			$query = "alter table marine_identity alter column mmsi type varchar(255)";
1925 1925
 			try {
1926 1926
 				$sth = $Connection->db->prepare($query);
1927 1927
 				$sth->execute();
1928
-			} catch(PDOException $e) {
1928
+			} catch (PDOException $e) {
1929 1929
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1930 1930
 			}
1931 1931
 		}
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
 		try {
1934 1934
 			$sth = $Connection->db->prepare($query);
1935 1935
 			$sth->execute();
1936
-		} catch(PDOException $e) {
1936
+		} catch (PDOException $e) {
1937 1937
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1938 1938
 		}
1939 1939
 		return $error;
@@ -1943,32 +1943,32 @@  discard block
 block discarded – undo
1943 1943
 		global $globalDBdriver;
1944 1944
 		$Connection = new Connection();
1945 1945
 		$error = '';
1946
-		if (!$Connection->checkColumnName('source_location','last_seen')) {
1946
+		if (!$Connection->checkColumnName('source_location', 'last_seen')) {
1947 1947
 			$query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL";
1948 1948
 			try {
1949 1949
 				$sth = $Connection->db->prepare($query);
1950 1950
 				$sth->execute();
1951
-			} catch(PDOException $e) {
1951
+			} catch (PDOException $e) {
1952 1952
 				return "error (add column last_seen in source_location) : ".$e->getMessage()."\n";
1953 1953
 			}
1954 1954
 		}
1955 1955
 		if ($globalDBdriver == 'mysql') {
1956
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1956
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1957 1957
 				$query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL";
1958 1958
 				try {
1959 1959
 					$sth = $Connection->db->prepare($query);
1960 1960
 					$sth->execute();
1961
-				} catch(PDOException $e) {
1961
+				} catch (PDOException $e) {
1962 1962
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1963 1963
 				}
1964 1964
 			}
1965 1965
 		} else {
1966
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1966
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1967 1967
 				$query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL";
1968 1968
 				try {
1969 1969
 					$sth = $Connection->db->prepare($query);
1970 1970
 					$sth->execute();
1971
-				} catch(PDOException $e) {
1971
+				} catch (PDOException $e) {
1972 1972
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1973 1973
 				}
1974 1974
 			}
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
 		try {
1978 1978
 			$sth = $Connection->db->prepare($query);
1979 1979
 			$sth->execute();
1980
-		} catch(PDOException $e) {
1980
+		} catch (PDOException $e) {
1981 1981
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1982 1982
 		}
1983 1983
 		return $error;
@@ -1987,12 +1987,12 @@  discard block
 block discarded – undo
1987 1987
 		global $globalDBdriver;
1988 1988
 		$Connection = new Connection();
1989 1989
 		$error = '';
1990
-		if (!$Connection->checkColumnName('source_location','description')) {
1990
+		if (!$Connection->checkColumnName('source_location', 'description')) {
1991 1991
 			$query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL";
1992 1992
 			try {
1993 1993
 				$sth = $Connection->db->prepare($query);
1994 1994
 				$sth->execute();
1995
-			} catch(PDOException $e) {
1995
+			} catch (PDOException $e) {
1996 1996
 				return "error (add column description in source_location) : ".$e->getMessage()."\n";
1997 1997
 			}
1998 1998
 		}
@@ -2000,7 +2000,7 @@  discard block
 block discarded – undo
2000 2000
 		try {
2001 2001
 			$sth = $Connection->db->prepare($query);
2002 2002
 			$sth->execute();
2003
-		} catch(PDOException $e) {
2003
+		} catch (PDOException $e) {
2004 2004
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2005 2005
 		}
2006 2006
 		return $error;
@@ -2010,39 +2010,39 @@  discard block
 block discarded – undo
2010 2010
 		global $globalDBdriver;
2011 2011
 		$Connection = new Connection();
2012 2012
 		$error = '';
2013
-		if (!$Connection->checkColumnName('spotter_live','real_altitude')) {
2013
+		if (!$Connection->checkColumnName('spotter_live', 'real_altitude')) {
2014 2014
 			$query = "ALTER TABLE spotter_live ADD COLUMN real_altitude float DEFAULT NULL";
2015 2015
 			try {
2016 2016
 				$sth = $Connection->db->prepare($query);
2017 2017
 				$sth->execute();
2018
-			} catch(PDOException $e) {
2018
+			} catch (PDOException $e) {
2019 2019
 				return "error (add column real_altitude in spotter_live) : ".$e->getMessage()."\n";
2020 2020
 			}
2021 2021
 		}
2022
-		if (!$Connection->checkColumnName('spotter_output','real_altitude')) {
2022
+		if (!$Connection->checkColumnName('spotter_output', 'real_altitude')) {
2023 2023
 			$query = "ALTER TABLE spotter_output ADD COLUMN real_altitude float DEFAULT NULL";
2024 2024
 			try {
2025 2025
 				$sth = $Connection->db->prepare($query);
2026 2026
 				$sth->execute();
2027
-			} catch(PDOException $e) {
2027
+			} catch (PDOException $e) {
2028 2028
 				return "error (add column real_altitude in spotter_output) : ".$e->getMessage()."\n";
2029 2029
 			}
2030 2030
 		}
2031
-		if (!$Connection->checkColumnName('spotter_archive_output','real_altitude')) {
2031
+		if (!$Connection->checkColumnName('spotter_archive_output', 'real_altitude')) {
2032 2032
 			$query = "ALTER TABLE spotter_archive_output ADD COLUMN real_altitude float DEFAULT NULL";
2033 2033
 			try {
2034 2034
 				$sth = $Connection->db->prepare($query);
2035 2035
 				$sth->execute();
2036
-			} catch(PDOException $e) {
2036
+			} catch (PDOException $e) {
2037 2037
 				return "error (add column real_altitude in spotter_archive_output) : ".$e->getMessage()."\n";
2038 2038
 			}
2039 2039
 		}
2040
-		if (!$Connection->checkColumnName('spotter_archive','real_altitude')) {
2040
+		if (!$Connection->checkColumnName('spotter_archive', 'real_altitude')) {
2041 2041
 			$query = "ALTER TABLE spotter_archive ADD COLUMN real_altitude float DEFAULT NULL";
2042 2042
 			try {
2043 2043
 				$sth = $Connection->db->prepare($query);
2044 2044
 				$sth->execute();
2045
-			} catch(PDOException $e) {
2045
+			} catch (PDOException $e) {
2046 2046
 				return "error (add column real_altitude in spotter_archive) : ".$e->getMessage()."\n";
2047 2047
 			}
2048 2048
 		}
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
 		try {
2051 2051
 			$sth = $Connection->db->prepare($query);
2052 2052
 			$sth->execute();
2053
-		} catch(PDOException $e) {
2053
+		} catch (PDOException $e) {
2054 2054
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2055 2055
 		}
2056 2056
 		return $error;
@@ -2072,14 +2072,14 @@  discard block
 block discarded – undo
2072 2072
 		try {
2073 2073
 			$sth = $Connection->db->prepare($query);
2074 2074
 			$sth->execute();
2075
-		} catch(PDOException $e) {
2075
+		} catch (PDOException $e) {
2076 2076
 			return "error (modify column altitude in tracker_*) : ".$e->getMessage()."\n";
2077 2077
 		}
2078 2078
 		$query = "UPDATE config SET value = '44' WHERE name = 'schema_version'";
2079 2079
 		try {
2080 2080
 			$sth = $Connection->db->prepare($query);
2081 2081
 			$sth->execute();
2082
-		} catch(PDOException $e) {
2082
+		} catch (PDOException $e) {
2083 2083
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2084 2084
 		}
2085 2085
 		return $error;
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
 		try {
2121 2121
 			$sth = $Connection->db->prepare($query);
2122 2122
 			$sth->execute();
2123
-		} catch(PDOException $e) {
2123
+		} catch (PDOException $e) {
2124 2124
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2125 2125
 		}
2126 2126
 		return $error;
@@ -2143,7 +2143,7 @@  discard block
 block discarded – undo
2143 2143
 		try {
2144 2144
 			$sth = $Connection->db->prepare($query);
2145 2145
 			$sth->execute();
2146
-		} catch(PDOException $e) {
2146
+		} catch (PDOException $e) {
2147 2147
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2148 2148
 		}
2149 2149
 		return $error;
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
 		try {
2194 2194
 			$sth = $Connection->db->prepare($query);
2195 2195
 			$sth->execute();
2196
-		} catch(PDOException $e) {
2196
+		} catch (PDOException $e) {
2197 2197
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2198 2198
 		}
2199 2199
 		return $error;
@@ -2216,7 +2216,7 @@  discard block
 block discarded – undo
2216 2216
 		try {
2217 2217
 			$sth = $Connection->db->prepare($query);
2218 2218
 			$sth->execute();
2219
-		} catch(PDOException $e) {
2219
+		} catch (PDOException $e) {
2220 2220
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2221 2221
 		}
2222 2222
 		return $error;
@@ -2239,7 +2239,7 @@  discard block
 block discarded – undo
2239 2239
 					try {
2240 2240
 						$sth = $Connection->db->prepare($query);
2241 2241
 						$sth->execute();
2242
-					} catch(PDOException $e) {
2242
+					} catch (PDOException $e) {
2243 2243
 						return "error (check_version): ".$e->getMessage()."\n";
2244 2244
 					}
2245 2245
 					$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +468 added lines, -172 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 {
@@ -803,12 +855,16 @@  discard block
 block discarded – undo
803 855
 		if ($globalDBdriver == 'mysql') {
804 856
 			if (!$Connection->tableExists('tle')) {
805 857
 				$error .= create_db::import_file('../db/tle.sql');
806
-				if ($error != '') return $error;
858
+				if ($error != '') {
859
+					return $error;
860
+				}
807 861
 			}
808 862
 		} else {
809 863
 			if (!$Connection->tableExists('tle')) {
810 864
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
811
-				if ($error != '') return $error;
865
+				if ($error != '') {
866
+					return $error;
867
+				}
812 868
 			}
813 869
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
814 870
 			try {
@@ -848,7 +904,9 @@  discard block
 block discarded – undo
848 904
 		} else {
849 905
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 906
 		}
851
-		if ($error != '') return 'Import airlines.sql : '.$error;
907
+		if ($error != '') {
908
+			return 'Import airlines.sql : '.$error;
909
+		}
852 910
 		if (!$Connection->checkColumnName('airlines','forsource')) {
853 911
 			// Add forsource to airlines
854 912
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1331,20 +1389,28 @@  discard block
 block discarded – undo
1331 1389
 		}
1332 1390
 		if ($globalDBdriver == 'mysql') {
1333 1391
 			$error .= create_db::import_file('../db/airlines.sql');
1334
-			if ($error != '') return $error;
1392
+			if ($error != '') {
1393
+				return $error;
1394
+			}
1335 1395
 		} else {
1336 1396
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1337
-			if ($error != '') return $error;
1397
+			if ($error != '') {
1398
+				return $error;
1399
+			}
1338 1400
 		}
1339 1401
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1340 1402
 			include_once(dirname(__FILE__).'/class.update_db.php');
1341 1403
 			if (isset($globalVATSIM) && $globalVATSIM) {
1342 1404
 				$error .= update_db::update_vatsim();
1343
-				if ($error != '') return $error;
1405
+				if ($error != '') {
1406
+					return $error;
1407
+				}
1344 1408
 			}
1345 1409
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1346 1410
 				$error .= update_db::update_IVAO();
1347
-				if ($error != '') return $error;
1411
+				if ($error != '') {
1412
+					return $error;
1413
+				}
1348 1414
 			}
1349 1415
 		}
1350 1416
 
@@ -1607,41 +1673,65 @@  discard block
 block discarded – undo
1607 1673
 		if ($globalDBdriver == 'mysql') {
1608 1674
 			if (!$Connection->tableExists('tracker_output')) {
1609 1675
 				$error .= create_db::import_file('../db/tracker_output.sql');
1610
-				if ($error != '') return $error;
1676
+				if ($error != '') {
1677
+					return $error;
1678
+				}
1611 1679
 			}
1612 1680
 			if (!$Connection->tableExists('tracker_live')) {
1613 1681
 				$error .= create_db::import_file('../db/tracker_live.sql');
1614
-				if ($error != '') return $error;
1682
+				if ($error != '') {
1683
+					return $error;
1684
+				}
1615 1685
 			}
1616 1686
 			if (!$Connection->tableExists('marine_output')) {
1617 1687
 				$error .= create_db::import_file('../db/marine_output.sql');
1618
-				if ($error != '') return $error;
1688
+				if ($error != '') {
1689
+					return $error;
1690
+				}
1619 1691
 			}
1620 1692
 			if (!$Connection->tableExists('marine_live')) {
1621 1693
 				$error .= create_db::import_file('../db/marine_live.sql');
1622
-				if ($error != '') return $error;
1694
+				if ($error != '') {
1695
+					return $error;
1696
+				}
1623 1697
 			}
1624 1698
 			if (!$Connection->tableExists('marine_identity')) {
1625 1699
 				$error .= create_db::import_file('../db/marine_identity.sql');
1626
-				if ($error != '') return $error;
1700
+				if ($error != '') {
1701
+					return $error;
1702
+				}
1627 1703
 			}
1628 1704
 			if (!$Connection->tableExists('marine_mid')) {
1629 1705
 				$error .= create_db::import_file('../db/marine_mid.sql');
1630
-				if ($error != '') return $error;
1706
+				if ($error != '') {
1707
+					return $error;
1708
+				}
1631 1709
 			}
1632 1710
 		} else {
1633 1711
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1634
-			if ($error != '') return $error;
1712
+			if ($error != '') {
1713
+				return $error;
1714
+			}
1635 1715
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1636
-			if ($error != '') return $error;
1716
+			if ($error != '') {
1717
+				return $error;
1718
+			}
1637 1719
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1638
-			if ($error != '') return $error;
1720
+			if ($error != '') {
1721
+				return $error;
1722
+			}
1639 1723
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1640
-			if ($error != '') return $error;
1724
+			if ($error != '') {
1725
+				return $error;
1726
+			}
1641 1727
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1642
-			if ($error != '') return $error;
1728
+			if ($error != '') {
1729
+				return $error;
1730
+			}
1643 1731
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1644
-			if ($error != '') return $error;
1732
+			if ($error != '') {
1733
+				return $error;
1734
+			}
1645 1735
 		}
1646 1736
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1647 1737
 		try {
@@ -1660,39 +1750,61 @@  discard block
 block discarded – undo
1660 1750
 		if ($globalDBdriver == 'mysql') {
1661 1751
 			if (!$Connection->tableExists('marine_image')) {
1662 1752
 				$error .= create_db::import_file('../db/marine_image.sql');
1663
-				if ($error != '') return $error;
1753
+				if ($error != '') {
1754
+					return $error;
1755
+				}
1664 1756
 			}
1665 1757
 			if (!$Connection->tableExists('marine_archive')) {
1666 1758
 				$error .= create_db::import_file('../db/marine_archive.sql');
1667
-				if ($error != '') return $error;
1759
+				if ($error != '') {
1760
+					return $error;
1761
+				}
1668 1762
 			}
1669 1763
 			if (!$Connection->tableExists('marine_archive_output')) {
1670 1764
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1671
-				if ($error != '') return $error;
1765
+				if ($error != '') {
1766
+					return $error;
1767
+				}
1672 1768
 			}
1673 1769
 			if (!$Connection->tableExists('tracker_archive')) {
1674 1770
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1675
-				if ($error != '') return $error;
1771
+				if ($error != '') {
1772
+					return $error;
1773
+				}
1676 1774
 			}
1677 1775
 			if (!$Connection->tableExists('tracker_archive_output')) {
1678 1776
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1679
-				if ($error != '') return $error;
1777
+				if ($error != '') {
1778
+					return $error;
1779
+				}
1680 1780
 			}
1681 1781
 			if (!$Connection->tableExists('marine_archive_output')) {
1682 1782
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1683
-				if ($error != '') return $error;
1783
+				if ($error != '') {
1784
+					return $error;
1785
+				}
1684 1786
 			}
1685 1787
 		} else {
1686 1788
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1687
-			if ($error != '') return $error;
1789
+			if ($error != '') {
1790
+				return $error;
1791
+			}
1688 1792
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1689
-			if ($error != '') return $error;
1793
+			if ($error != '') {
1794
+				return $error;
1795
+			}
1690 1796
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1691
-			if ($error != '') return $error;
1797
+			if ($error != '') {
1798
+				return $error;
1799
+			}
1692 1800
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1693
-			if ($error != '') return $error;
1801
+			if ($error != '') {
1802
+				return $error;
1803
+			}
1694 1804
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1695
-			if ($error != '') return $error;
1805
+			if ($error != '') {
1806
+				return $error;
1807
+			}
1696 1808
 		}
1697 1809
 		if ($globalDBdriver == 'mysql') {
1698 1810
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2063,7 +2175,9 @@  discard block
 block discarded – undo
2063 2175
 		if ($globalDBdriver == 'mysql') {
2064 2176
 			if (!$Connection->tableExists('tracker_archive_output')) {
2065 2177
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2066
-				if ($error != '') return $error;
2178
+				if ($error != '') {
2179
+					return $error;
2180
+				}
2067 2181
 			}
2068 2182
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2069 2183
 		} else {
@@ -2091,14 +2205,22 @@  discard block
 block discarded – undo
2091 2205
 		$error = '';
2092 2206
 		if ($globalDBdriver == 'mysql') {
2093 2207
 			$error .= create_db::import_file('../db/airport.sql');
2094
-			if ($error != '') return $error;
2208
+			if ($error != '') {
2209
+				return $error;
2210
+			}
2095 2211
 			$error .= create_db::import_file('../db/airlines.sql');
2096
-			if ($error != '') return $error;
2212
+			if ($error != '') {
2213
+				return $error;
2214
+			}
2097 2215
 		} else {
2098 2216
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2099
-			if ($error != '') return $error;
2217
+			if ($error != '') {
2218
+				return $error;
2219
+			}
2100 2220
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2101
-			if ($error != '') return $error;
2221
+			if ($error != '') {
2222
+				return $error;
2223
+			}
2102 2224
 		}
2103 2225
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2104 2226
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2115,7 +2237,9 @@  discard block
 block discarded – undo
2115 2237
 				$error .= update_db::update_vatsim();
2116 2238
 			}
2117 2239
 		}
2118
-		if ($error != '') return $error;
2240
+		if ($error != '') {
2241
+			return $error;
2242
+		}
2119 2243
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2120 2244
 		try {
2121 2245
 			$sth = $Connection->db->prepare($query);
@@ -2133,10 +2257,14 @@  discard block
 block discarded – undo
2133 2257
 		if (!$Connection->tableExists('satellite')) {
2134 2258
 			if ($globalDBdriver == 'mysql') {
2135 2259
 				$error .= create_db::import_file('../db/satellite.sql');
2136
-				if ($error != '') return $error;
2260
+				if ($error != '') {
2261
+					return $error;
2262
+				}
2137 2263
 			} else {
2138 2264
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2139
-				if ($error != '') return $error;
2265
+				if ($error != '') {
2266
+					return $error;
2267
+				}
2140 2268
 			}
2141 2269
 		}
2142 2270
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2156,37 +2284,53 @@  discard block
 block discarded – undo
2156 2284
 		if (!$Connection->tableExists('stats_marine')) {
2157 2285
 			if ($globalDBdriver == 'mysql') {
2158 2286
 				$error .= create_db::import_file('../db/stats_marine.sql');
2159
-				if ($error != '') return $error;
2287
+				if ($error != '') {
2288
+					return $error;
2289
+				}
2160 2290
 			} else {
2161 2291
 				$error .= create_db::import_file('../db/pgsql/stats_marine.sql');
2162
-				if ($error != '') return $error;
2292
+				if ($error != '') {
2293
+					return $error;
2294
+				}
2163 2295
 			}
2164 2296
 		}
2165 2297
 		if (!$Connection->tableExists('stats_marine_country')) {
2166 2298
 			if ($globalDBdriver == 'mysql') {
2167 2299
 				$error .= create_db::import_file('../db/stats_marine_country.sql');
2168
-				if ($error != '') return $error;
2300
+				if ($error != '') {
2301
+					return $error;
2302
+				}
2169 2303
 			} else {
2170 2304
 				$error .= create_db::import_file('../db/pgsql/stats_marine_country.sql');
2171
-				if ($error != '') return $error;
2305
+				if ($error != '') {
2306
+					return $error;
2307
+				}
2172 2308
 			}
2173 2309
 		}
2174 2310
 		if (!$Connection->tableExists('stats_tracker')) {
2175 2311
 			if ($globalDBdriver == 'mysql') {
2176 2312
 				$error .= create_db::import_file('../db/stats_tracker.sql');
2177
-				if ($error != '') return $error;
2313
+				if ($error != '') {
2314
+					return $error;
2315
+				}
2178 2316
 			} else {
2179 2317
 				$error .= create_db::import_file('../db/pgsql/stats_tracker.sql');
2180
-				if ($error != '') return $error;
2318
+				if ($error != '') {
2319
+					return $error;
2320
+				}
2181 2321
 			}
2182 2322
 		}
2183 2323
 		if (!$Connection->tableExists('stats_tracker_country')) {
2184 2324
 			if ($globalDBdriver == 'mysql') {
2185 2325
 				$error .= create_db::import_file('../db/stats_tracker_country.sql');
2186
-				if ($error != '') return $error;
2326
+				if ($error != '') {
2327
+					return $error;
2328
+				}
2187 2329
 			} else {
2188 2330
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql');
2189
-				if ($error != '') return $error;
2331
+				if ($error != '') {
2332
+					return $error;
2333
+				}
2190 2334
 			}
2191 2335
 		}
2192 2336
 		$query = "UPDATE config SET value = '47' WHERE name = 'schema_version'";
@@ -2206,10 +2350,14 @@  discard block
 block discarded – undo
2206 2350
 		if (!$Connection->tableExists('stats_marine_type')) {
2207 2351
 			if ($globalDBdriver == 'mysql') {
2208 2352
 				$error .= create_db::import_file('../db/stats_marine_type.sql');
2209
-				if ($error != '') return $error;
2353
+				if ($error != '') {
2354
+					return $error;
2355
+				}
2210 2356
 			} else {
2211 2357
 				$error .= create_db::import_file('../db/pgsql/stats_marine_type.sql');
2212
-				if ($error != '') return $error;
2358
+				if ($error != '') {
2359
+					return $error;
2360
+				}
2213 2361
 			}
2214 2362
 		}
2215 2363
 		$query = "UPDATE config SET value = '48' WHERE name = 'schema_version'";
@@ -2232,8 +2380,11 @@  discard block
 block discarded – undo
2232 2380
 			if ($Connection->tableExists('aircraft')) {
2233 2381
 				if (!$Connection->tableExists('config')) {
2234 2382
 					$version = '1';
2235
-					if ($update) return self::update_from_1();
2236
-					else return $version;
2383
+					if ($update) {
2384
+						return self::update_from_1();
2385
+					} else {
2386
+						return $version;
2387
+					}
2237 2388
 				} else {
2238 2389
 					$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2239 2390
 					try {
@@ -2246,195 +2397,340 @@  discard block
 block discarded – undo
2246 2397
 					if ($update) {
2247 2398
 						if ($result['value'] == '2') {
2248 2399
 							$error = self::update_from_2();
2249
-							if ($error != '') return $error;
2250
-							else return self::check_version(true);
2400
+							if ($error != '') {
2401
+								return $error;
2402
+							} else {
2403
+								return self::check_version(true);
2404
+							}
2251 2405
 						} elseif ($result['value'] == '3') {
2252 2406
 							$error = self::update_from_3();
2253
-							if ($error != '') return $error;
2254
-							else return self::check_version(true);
2407
+							if ($error != '') {
2408
+								return $error;
2409
+							} else {
2410
+								return self::check_version(true);
2411
+							}
2255 2412
 						} elseif ($result['value'] == '4') {
2256 2413
 							$error = self::update_from_4();
2257
-							if ($error != '') return $error;
2258
-							else return self::check_version(true);
2414
+							if ($error != '') {
2415
+								return $error;
2416
+							} else {
2417
+								return self::check_version(true);
2418
+							}
2259 2419
 						} elseif ($result['value'] == '5') {
2260 2420
 							$error = self::update_from_5();
2261
-							if ($error != '') return $error;
2262
-							else return self::check_version(true);
2421
+							if ($error != '') {
2422
+								return $error;
2423
+							} else {
2424
+								return self::check_version(true);
2425
+							}
2263 2426
 						} elseif ($result['value'] == '6') {
2264 2427
 							$error = self::update_from_6();
2265
-							if ($error != '') return $error;
2266
-							else return self::check_version(true);
2428
+							if ($error != '') {
2429
+								return $error;
2430
+							} else {
2431
+								return self::check_version(true);
2432
+							}
2267 2433
 						} elseif ($result['value'] == '7') {
2268 2434
 							$error = self::update_from_7();
2269
-							if ($error != '') return $error;
2270
-							else return self::check_version(true);
2435
+							if ($error != '') {
2436
+								return $error;
2437
+							} else {
2438
+								return self::check_version(true);
2439
+							}
2271 2440
 						} elseif ($result['value'] == '8') {
2272 2441
 							$error = self::update_from_8();
2273
-							if ($error != '') return $error;
2274
-							else return self::check_version(true);
2442
+							if ($error != '') {
2443
+								return $error;
2444
+							} else {
2445
+								return self::check_version(true);
2446
+							}
2275 2447
 						} elseif ($result['value'] == '9') {
2276 2448
 							$error = self::update_from_9();
2277
-							if ($error != '') return $error;
2278
-							else return self::check_version(true);
2449
+							if ($error != '') {
2450
+								return $error;
2451
+							} else {
2452
+								return self::check_version(true);
2453
+							}
2279 2454
 						} elseif ($result['value'] == '10') {
2280 2455
 							$error = self::update_from_10();
2281
-							if ($error != '') return $error;
2282
-							else return self::check_version(true);
2456
+							if ($error != '') {
2457
+								return $error;
2458
+							} else {
2459
+								return self::check_version(true);
2460
+							}
2283 2461
 						} elseif ($result['value'] == '11') {
2284 2462
 							$error = self::update_from_11();
2285
-							if ($error != '') return $error;
2286
-							else return self::check_version(true);
2463
+							if ($error != '') {
2464
+								return $error;
2465
+							} else {
2466
+								return self::check_version(true);
2467
+							}
2287 2468
 						} elseif ($result['value'] == '12') {
2288 2469
 							$error = self::update_from_12();
2289
-							if ($error != '') return $error;
2290
-							else return self::check_version(true);
2470
+							if ($error != '') {
2471
+								return $error;
2472
+							} else {
2473
+								return self::check_version(true);
2474
+							}
2291 2475
 						} elseif ($result['value'] == '13') {
2292 2476
 							$error = self::update_from_13();
2293
-							if ($error != '') return $error;
2294
-							else return self::check_version(true);
2477
+							if ($error != '') {
2478
+								return $error;
2479
+							} else {
2480
+								return self::check_version(true);
2481
+							}
2295 2482
 						} elseif ($result['value'] == '14') {
2296 2483
 							$error = self::update_from_14();
2297
-							if ($error != '') return $error;
2298
-							else return self::check_version(true);
2484
+							if ($error != '') {
2485
+								return $error;
2486
+							} else {
2487
+								return self::check_version(true);
2488
+							}
2299 2489
 						} elseif ($result['value'] == '15') {
2300 2490
 							$error = self::update_from_15();
2301
-							if ($error != '') return $error;
2302
-							else return self::check_version(true);
2491
+							if ($error != '') {
2492
+								return $error;
2493
+							} else {
2494
+								return self::check_version(true);
2495
+							}
2303 2496
 						} elseif ($result['value'] == '16') {
2304 2497
 							$error = self::update_from_16();
2305
-							if ($error != '') return $error;
2306
-							else return self::check_version(true);
2498
+							if ($error != '') {
2499
+								return $error;
2500
+							} else {
2501
+								return self::check_version(true);
2502
+							}
2307 2503
 						} elseif ($result['value'] == '17') {
2308 2504
 							$error = self::update_from_17();
2309
-							if ($error != '') return $error;
2310
-							else return self::check_version(true);
2505
+							if ($error != '') {
2506
+								return $error;
2507
+							} else {
2508
+								return self::check_version(true);
2509
+							}
2311 2510
 						} elseif ($result['value'] == '18') {
2312 2511
 							$error = self::update_from_18();
2313
-							if ($error != '') return $error;
2314
-							else return self::check_version(true);
2512
+							if ($error != '') {
2513
+								return $error;
2514
+							} else {
2515
+								return self::check_version(true);
2516
+							}
2315 2517
 						} elseif ($result['value'] == '19') {
2316 2518
 							$error = self::update_from_19();
2317
-							if ($error != '') return $error;
2318
-							else return self::check_version(true);
2519
+							if ($error != '') {
2520
+								return $error;
2521
+							} else {
2522
+								return self::check_version(true);
2523
+							}
2319 2524
 						} elseif ($result['value'] == '20') {
2320 2525
 							$error = self::update_from_20();
2321
-							if ($error != '') return $error;
2322
-							else return self::check_version(true);
2526
+							if ($error != '') {
2527
+								return $error;
2528
+							} else {
2529
+								return self::check_version(true);
2530
+							}
2323 2531
 						} elseif ($result['value'] == '21') {
2324 2532
 							$error = self::update_from_21();
2325
-							if ($error != '') return $error;
2326
-							else return self::check_version(true);
2533
+							if ($error != '') {
2534
+								return $error;
2535
+							} else {
2536
+								return self::check_version(true);
2537
+							}
2327 2538
 						} elseif ($result['value'] == '22') {
2328 2539
 							$error = self::update_from_22();
2329
-							if ($error != '') return $error;
2330
-							else return self::check_version(true);
2540
+							if ($error != '') {
2541
+								return $error;
2542
+							} else {
2543
+								return self::check_version(true);
2544
+							}
2331 2545
 						} elseif ($result['value'] == '23') {
2332 2546
 							$error = self::update_from_23();
2333
-							if ($error != '') return $error;
2334
-							else return self::check_version(true);
2547
+							if ($error != '') {
2548
+								return $error;
2549
+							} else {
2550
+								return self::check_version(true);
2551
+							}
2335 2552
 						} elseif ($result['value'] == '24') {
2336 2553
 							$error = self::update_from_24();
2337
-							if ($error != '') return $error;
2338
-							else return self::check_version(true);
2554
+							if ($error != '') {
2555
+								return $error;
2556
+							} else {
2557
+								return self::check_version(true);
2558
+							}
2339 2559
 						} elseif ($result['value'] == '25') {
2340 2560
 							$error = self::update_from_25();
2341
-							if ($error != '') return $error;
2342
-							else return self::check_version(true);
2561
+							if ($error != '') {
2562
+								return $error;
2563
+							} else {
2564
+								return self::check_version(true);
2565
+							}
2343 2566
 						} elseif ($result['value'] == '26') {
2344 2567
 							$error = self::update_from_26();
2345
-							if ($error != '') return $error;
2346
-							else return self::check_version(true);
2568
+							if ($error != '') {
2569
+								return $error;
2570
+							} else {
2571
+								return self::check_version(true);
2572
+							}
2347 2573
 						} elseif ($result['value'] == '27') {
2348 2574
 							$error = self::update_from_27();
2349
-							if ($error != '') return $error;
2350
-							else return self::check_version(true);
2575
+							if ($error != '') {
2576
+								return $error;
2577
+							} else {
2578
+								return self::check_version(true);
2579
+							}
2351 2580
 						} elseif ($result['value'] == '28') {
2352 2581
 							$error = self::update_from_28();
2353
-							if ($error != '') return $error;
2354
-							else return self::check_version(true);
2582
+							if ($error != '') {
2583
+								return $error;
2584
+							} else {
2585
+								return self::check_version(true);
2586
+							}
2355 2587
 						} elseif ($result['value'] == '29') {
2356 2588
 							$error = self::update_from_29();
2357
-							if ($error != '') return $error;
2358
-							else return self::check_version(true);
2589
+							if ($error != '') {
2590
+								return $error;
2591
+							} else {
2592
+								return self::check_version(true);
2593
+							}
2359 2594
 						} elseif ($result['value'] == '30') {
2360 2595
 							$error = self::update_from_30();
2361
-							if ($error != '') return $error;
2362
-							else return self::check_version(true);
2596
+							if ($error != '') {
2597
+								return $error;
2598
+							} else {
2599
+								return self::check_version(true);
2600
+							}
2363 2601
 						} elseif ($result['value'] == '31') {
2364 2602
 							$error = self::update_from_31();
2365
-							if ($error != '') return $error;
2366
-							else return self::check_version(true);
2603
+							if ($error != '') {
2604
+								return $error;
2605
+							} else {
2606
+								return self::check_version(true);
2607
+							}
2367 2608
 						} elseif ($result['value'] == '32') {
2368 2609
 							$error = self::update_from_32();
2369
-							if ($error != '') return $error;
2370
-							else return self::check_version(true);
2610
+							if ($error != '') {
2611
+								return $error;
2612
+							} else {
2613
+								return self::check_version(true);
2614
+							}
2371 2615
 						} elseif ($result['value'] == '33') {
2372 2616
 							$error = self::update_from_33();
2373
-							if ($error != '') return $error;
2374
-							else return self::check_version(true);
2617
+							if ($error != '') {
2618
+								return $error;
2619
+							} else {
2620
+								return self::check_version(true);
2621
+							}
2375 2622
 						} elseif ($result['value'] == '34') {
2376 2623
 							$error = self::update_from_34();
2377
-							if ($error != '') return $error;
2378
-							else return self::check_version(true);
2624
+							if ($error != '') {
2625
+								return $error;
2626
+							} else {
2627
+								return self::check_version(true);
2628
+							}
2379 2629
 						} elseif ($result['value'] == '35') {
2380 2630
 							$error = self::update_from_35();
2381
-							if ($error != '') return $error;
2382
-							else return self::check_version(true);
2631
+							if ($error != '') {
2632
+								return $error;
2633
+							} else {
2634
+								return self::check_version(true);
2635
+							}
2383 2636
 						} elseif ($result['value'] == '36') {
2384 2637
 							$error = self::update_from_36();
2385
-							if ($error != '') return $error;
2386
-							else return self::check_version(true);
2638
+							if ($error != '') {
2639
+								return $error;
2640
+							} else {
2641
+								return self::check_version(true);
2642
+							}
2387 2643
 						} elseif ($result['value'] == '37') {
2388 2644
 							$error = self::update_from_37();
2389
-							if ($error != '') return $error;
2390
-							else return self::check_version(true);
2645
+							if ($error != '') {
2646
+								return $error;
2647
+							} else {
2648
+								return self::check_version(true);
2649
+							}
2391 2650
 						} elseif ($result['value'] == '38') {
2392 2651
 							$error = self::update_from_38();
2393
-							if ($error != '') return $error;
2394
-							else return self::check_version(true);
2652
+							if ($error != '') {
2653
+								return $error;
2654
+							} else {
2655
+								return self::check_version(true);
2656
+							}
2395 2657
 						} elseif ($result['value'] == '39') {
2396 2658
 							$error = self::update_from_39();
2397
-							if ($error != '') return $error;
2398
-							else return self::check_version(true);
2659
+							if ($error != '') {
2660
+								return $error;
2661
+							} else {
2662
+								return self::check_version(true);
2663
+							}
2399 2664
 						} elseif ($result['value'] == '40') {
2400 2665
 							$error = self::update_from_40();
2401
-							if ($error != '') return $error;
2402
-							else return self::check_version(true);
2666
+							if ($error != '') {
2667
+								return $error;
2668
+							} else {
2669
+								return self::check_version(true);
2670
+							}
2403 2671
 						} elseif ($result['value'] == '41') {
2404 2672
 							$error = self::update_from_41();
2405
-							if ($error != '') return $error;
2406
-							else return self::check_version(true);
2673
+							if ($error != '') {
2674
+								return $error;
2675
+							} else {
2676
+								return self::check_version(true);
2677
+							}
2407 2678
 						} elseif ($result['value'] == '42') {
2408 2679
 							$error = self::update_from_42();
2409
-							if ($error != '') return $error;
2410
-							else return self::check_version(true);
2680
+							if ($error != '') {
2681
+								return $error;
2682
+							} else {
2683
+								return self::check_version(true);
2684
+							}
2411 2685
 						} elseif ($result['value'] == '43') {
2412 2686
 							$error = self::update_from_43();
2413
-							if ($error != '') return $error;
2414
-							else return self::check_version(true);
2687
+							if ($error != '') {
2688
+								return $error;
2689
+							} else {
2690
+								return self::check_version(true);
2691
+							}
2415 2692
 						} elseif ($result['value'] == '44') {
2416 2693
 							$error = self::update_from_44();
2417
-							if ($error != '') return $error;
2418
-							else return self::check_version(true);
2694
+							if ($error != '') {
2695
+								return $error;
2696
+							} else {
2697
+								return self::check_version(true);
2698
+							}
2419 2699
 						} elseif ($result['value'] == '45') {
2420 2700
 							$error = self::update_from_45();
2421
-							if ($error != '') return $error;
2422
-							else return self::check_version(true);
2701
+							if ($error != '') {
2702
+								return $error;
2703
+							} else {
2704
+								return self::check_version(true);
2705
+							}
2423 2706
 						} elseif ($result['value'] == '46') {
2424 2707
 							$error = self::update_from_46();
2425
-							if ($error != '') return $error;
2426
-							else return self::check_version(true);
2708
+							if ($error != '') {
2709
+								return $error;
2710
+							} else {
2711
+								return self::check_version(true);
2712
+							}
2427 2713
 						} elseif ($result['value'] == '47') {
2428 2714
 							$error = self::update_from_47();
2429
-							if ($error != '') return $error;
2430
-							else return self::check_version(true);
2431
-						} else return '';
2715
+							if ($error != '') {
2716
+								return $error;
2717
+							} else {
2718
+								return self::check_version(true);
2719
+							}
2720
+						} else {
2721
+							return '';
2722
+						}
2432 2723
 					} else {
2433
-						if (isset($result['value']) && $result['value'] != '') return $result['value'];
2434
-						else return 0;
2724
+						if (isset($result['value']) && $result['value'] != '') {
2725
+							return $result['value'];
2726
+						} else {
2727
+							return 0;
2728
+						}
2435 2729
 					}
2436 2730
 				}
2437
-			} else return $version;
2731
+			} else {
2732
+				return $version;
2733
+			}
2438 2734
 		}
2439 2735
 	}
2440 2736
 }
Please login to merge, or discard this patch.