Completed
Push — master ( 134c31...3567d1 )
by Yannick
12:14
created
require/class.MarineLive.php 4 patches
Braces   +59 added lines, -20 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -76,8 +78,11 @@  discard block
 block discarded – undo
76 78
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77 79
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 		}
79
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
81 86
 		if ($filter_query_where != '') {
82 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83 88
 		}
@@ -119,7 +124,9 @@  discard block
 block discarded – undo
119 124
 			}
120 125
 		}
121 126
 
122
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
127
+		if (!isset($globalLiveInterval)) {
128
+			$globalLiveInterval = '200';
129
+		}
123 130
 		if ($globalDBdriver == 'mysql') {
124 131
 			//$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
125 132
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -144,7 +151,9 @@  discard block
 block discarded – undo
144 151
 
145 152
 		$filter_query = $this->getFilter($filter,true,true);
146 153
 
147
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
148 157
 		if ($globalDBdriver == 'mysql') {
149 158
 			$query  = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
150 159
 			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";
@@ -178,7 +187,9 @@  discard block
 block discarded – undo
178 187
 
179 188
 		$filter_query = $this->getFilter($filter,true,true);
180 189
 
181
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
190
+		if (!isset($globalLiveInterval)) {
191
+			$globalLiveInterval = '200';
192
+		}
182 193
 		if ($globalDBdriver == 'mysql') {
183 194
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184 195
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
@@ -211,7 +222,9 @@  discard block
 block discarded – undo
211 222
 		global $globalDBdriver, $globalLiveInterval;
212 223
 		$filter_query = $this->getFilter($filter,true,true);
213 224
 
214
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
225
+		if (!isset($globalLiveInterval)) {
226
+			$globalLiveInterval = '200';
227
+		}
215 228
 		if ($globalDBdriver == 'mysql') {
216 229
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
217 230
 		} else {
@@ -239,7 +252,9 @@  discard block
 block discarded – undo
239 252
 	{
240 253
 		global $globalDBdriver, $globalLiveInterval;
241 254
 		$Spotter = new Spotter($this->db);
242
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
255
+		if (!isset($globalLiveInterval)) {
256
+			$globalLiveInterval = '200';
257
+		}
243 258
 		$filter_query = $this->getFilter($filter);
244 259
 
245 260
 		if (is_array($coord)) {
@@ -247,7 +262,9 @@  discard block
 block discarded – undo
247 262
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
248 263
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249 264
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250
-		} else return array();
265
+		} else {
266
+			return array();
267
+		}
251 268
 		if ($globalDBdriver == 'mysql') {
252 269
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
253 270
 		} else {
@@ -411,11 +428,15 @@  discard block
 block discarded – undo
411 428
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
412 429
 		if ($globalDBdriver == 'mysql') {
413 430
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
414
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
431
+			if ($liveinterval) {
432
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
433
+			}
415 434
 			$query .= ' ORDER BY date';
416 435
 		} else {
417 436
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
418
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
437
+			if ($liveinterval) {
438
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
439
+			}
419 440
 			$query .= ' ORDER BY date';
420 441
 		}
421 442
 
@@ -510,7 +531,9 @@  discard block
 block discarded – undo
510 531
 				$i++;
511 532
 				$j++;
512 533
 				if ($j == 30) {
513
-					if ($globalDebug) echo ".";
534
+					if ($globalDebug) {
535
+						echo ".";
536
+					}
514 537
 				    	try {
515 538
 						
516 539
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -790,7 +813,9 @@  discard block
 block discarded – undo
790 813
 			{
791 814
 				return false;
792 815
 			}
793
-		} else return '';
816
+		} else {
817
+			return '';
818
+		}
794 819
 
795 820
 		if ($longitude != '')
796 821
 		{
@@ -798,7 +823,9 @@  discard block
 block discarded – undo
798 823
 			{
799 824
 				return false;
800 825
 			}
801
-		} else return '';
826
+		} else {
827
+			return '';
828
+		}
802 829
 
803 830
 
804 831
 		if ($heading != '')
@@ -807,7 +834,9 @@  discard block
 block discarded – undo
807 834
 			{
808 835
 				return false;
809 836
 			}
810
-		} else $heading = 0;
837
+		} else {
838
+			$heading = 0;
839
+		}
811 840
 
812 841
 		if ($groundspeed != '')
813 842
 		{
@@ -815,9 +844,13 @@  discard block
 block discarded – undo
815 844
 			{
816 845
 				return false;
817 846
 			}
818
-		} else $groundspeed = 0;
847
+		} else {
848
+			$groundspeed = 0;
849
+		}
819 850
 		date_default_timezone_set('UTC');
820
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
851
+		if ($date == '') {
852
+			$date = date("Y-m-d H:i:s", time());
853
+		}
821 854
 
822 855
         
823 856
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -838,9 +871,15 @@  discard block
 block discarded – undo
838 871
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
839 872
 		
840 873
 
841
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
842
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
843
-            	if ($arrival_date == '') $arrival_date = NULL;
874
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
875
+            		$groundspeed = 0;
876
+            	}
877
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
878
+            		$heading = 0;
879
+            	}
880
+            	if ($arrival_date == '') {
881
+            		$arrival_date = NULL;
882
+            	}
844 883
 		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
845 884
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
846 885
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -762,10 +762,6 @@  discard block
 block discarded – undo
762 762
 	*
763 763
 	* @param String $fammarine_id the ID from flightaware
764 764
 	* @param String $ident the flight ident
765
-	* @param String $aircraft_icao the aircraft type
766
-	* @param String $departure_airport_icao the departure airport
767
-	* @param String $arrival_airport_icao the arrival airport
768
-	* @return String success or false
769 765
 	*
770 766
 	*/
771 767
 	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
Please login to merge, or discard this patch.
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	/**
89
-	* Gets all the spotter information based on the latest data entry
90
-	*
91
-	* @return Array the spotter information
92
-	*
93
-	*/
89
+	 * Gets all the spotter information based on the latest data entry
90
+	 *
91
+	 * @return Array the spotter information
92
+	 *
93
+	 */
94 94
 	public function getLiveMarineData($limit = '', $sort = '', $filter = array())
95 95
 	{
96 96
 		global $globalDBdriver, $globalLiveInterval;
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	}
133 133
 
134 134
 	/**
135
-	* Gets Minimal Live Spotter data
136
-	*
137
-	* @return Array the spotter information
138
-	*
139
-	*/
135
+	 * Gets Minimal Live Spotter data
136
+	 *
137
+	 * @return Array the spotter information
138
+	 *
139
+	 */
140 140
 	public function getMinLiveMarineData($filter = array())
141 141
 	{
142 142
 		global $globalDBdriver, $globalLiveInterval;
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	/**
169
-	* Gets Minimal Live Spotter data since xx seconds
170
-	*
171
-	* @return Array the spotter information
172
-	*
173
-	*/
169
+	 * Gets Minimal Live Spotter data since xx seconds
170
+	 *
171
+	 * @return Array the spotter information
172
+	 *
173
+	 */
174 174
 	public function getMinLastLiveMarineData($filter = array())
175 175
 	{
176 176
 		global $globalDBdriver, $globalLiveInterval;
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184 184
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
185 185
 			ORDER BY marine_live.fammarine_id, marine_live.date";
186
-                } else {
186
+				} else {
187 187
 			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
188 188
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
189 189
 			ORDER BY marine_live.fammarine_id, marine_live.date";
190 190
 		}
191 191
 
192
-    		try {
192
+			try {
193 193
 			$sth = $this->db->prepare($query);
194 194
 			$sth->execute();
195 195
 		} catch(PDOException $e) {
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	}
202 202
 
203 203
 	/**
204
-	* Gets number of latest data entry
205
-	*
206
-	* @return String number of entry
207
-	*
208
-	*/
204
+	 * Gets number of latest data entry
205
+	 *
206
+	 * @return String number of entry
207
+	 *
208
+	 */
209 209
 	public function getLiveMarineCount($filter = array())
210 210
 	{
211 211
 		global $globalDBdriver, $globalLiveInterval;
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	/**
233
-	* Gets all the spotter information based on the latest data entry and coord
234
-	*
235
-	* @return Array the spotter information
236
-	*
237
-	*/
233
+	 * Gets all the spotter information based on the latest data entry and coord
234
+	 *
235
+	 * @return Array the spotter information
236
+	 *
237
+	 */
238 238
 	public function getLiveMarineDatabyCoord($coord, $filter = array())
239 239
 	{
240 240
 		global $globalDBdriver, $globalLiveInterval;
@@ -258,11 +258,11 @@  discard block
 block discarded – undo
258 258
 	}
259 259
 
260 260
 	/**
261
-	* Gets all the spotter information based on a user's latitude and longitude
262
-	*
263
-	* @return Array the spotter information
264
-	*
265
-	*/
261
+	 * Gets all the spotter information based on a user's latitude and longitude
262
+	 *
263
+	 * @return Array the spotter information
264
+	 *
265
+	 */
266 266
 	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
267 267
 	{
268 268
 		$Marine = new Marine($this->db);
@@ -275,134 +275,134 @@  discard block
 block discarded – undo
275 275
 		if ($lng != '')
276 276
 		{
277 277
 			if (!is_numeric($lng))
278
-                        {
279
-                                return false;
280
-                        }
281
-                }
282
-
283
-                if ($radius != '')
284
-                {
285
-                        if (!is_numeric($radius))
286
-                        {
287
-                                return false;
288
-                        }
289
-                }
278
+						{
279
+								return false;
280
+						}
281
+				}
282
+
283
+				if ($radius != '')
284
+				{
285
+						if (!is_numeric($radius))
286
+						{
287
+								return false;
288
+						}
289
+				}
290 290
 		$additional_query = '';
291 291
 		if ($interval != '')
292
-                {
293
-                        if (!is_string($interval))
294
-                        {
295
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
296
-			        return false;
297
-                        } else {
298
-                if ($interval == '1m')
299
-                {
300
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
301
-                } else if ($interval == '15m'){
302
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
303
-                } 
304
-            }
305
-                } else {
306
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
307
-        }
308
-
309
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
292
+				{
293
+						if (!is_string($interval))
294
+						{
295
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
296
+					return false;
297
+						} else {
298
+				if ($interval == '1m')
299
+				{
300
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
301
+				} else if ($interval == '15m'){
302
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
303
+				} 
304
+			}
305
+				} else {
306
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
307
+		}
308
+
309
+				$query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
310 310
                    WHERE marine_live.latitude <> '' 
311 311
                                    AND marine_live.longitude <> '' 
312 312
                    ".$additional_query."
313 313
                    HAVING distance < :radius  
314 314
                                    ORDER BY distance";
315 315
 
316
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
316
+				$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
317 317
 
318
-                return $spotter_array;
319
-        }
318
+				return $spotter_array;
319
+		}
320 320
 
321 321
     
322
-        /**
323
-	* Gets all the spotter information based on a particular callsign
324
-	*
325
-	* @return Array the spotter information
326
-	*
327
-	*/
322
+		/**
323
+		 * Gets all the spotter information based on a particular callsign
324
+		 *
325
+		 * @return Array the spotter information
326
+		 *
327
+		 */
328 328
 	public function getLastLiveMarineDataByIdent($ident)
329 329
 	{
330 330
 		$Marine = new Marine($this->db);
331 331
 		date_default_timezone_set('UTC');
332 332
 
333 333
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
334
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
334
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
335 335
 
336 336
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
337 337
 
338 338
 		return $spotter_array;
339 339
 	}
340 340
 
341
-        /**
342
-	* Gets all the spotter information based on a particular callsign
343
-	*
344
-	* @return Array the spotter information
345
-	*
346
-	*/
341
+		/**
342
+		 * Gets all the spotter information based on a particular callsign
343
+		 *
344
+		 * @return Array the spotter information
345
+		 *
346
+		 */
347 347
 	public function getDateLiveMarineDataByIdent($ident,$date)
348 348
 	{
349 349
 		$Marine = new Marine($this->db);
350 350
 		date_default_timezone_set('UTC');
351 351
 
352 352
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
353
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
353
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
354 354
 
355
-                $date = date('c',$date);
355
+				$date = date('c',$date);
356 356
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
357 357
 
358 358
 		return $spotter_array;
359 359
 	}
360 360
 
361
-        /**
362
-	* Gets last spotter information based on a particular callsign
363
-	*
364
-	* @return Array the spotter information
365
-	*
366
-	*/
361
+		/**
362
+		 * Gets last spotter information based on a particular callsign
363
+		 *
364
+		 * @return Array the spotter information
365
+		 *
366
+		 */
367 367
 	public function getLastLiveMarineDataById($id)
368 368
 	{
369 369
 		$Marine = new Marine($this->db);
370 370
 		date_default_timezone_set('UTC');
371 371
 
372 372
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
373
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
373
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
374 374
 
375 375
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
376 376
 
377 377
 		return $spotter_array;
378 378
 	}
379 379
 
380
-        /**
381
-	* Gets last spotter information based on a particular callsign
382
-	*
383
-	* @return Array the spotter information
384
-	*
385
-	*/
380
+		/**
381
+		 * Gets last spotter information based on a particular callsign
382
+		 *
383
+		 * @return Array the spotter information
384
+		 *
385
+		 */
386 386
 	public function getDateLiveMarineDataById($id,$date)
387 387
 	{
388 388
 		$Marine = new Marine($this->db);
389 389
 		date_default_timezone_set('UTC');
390 390
 
391 391
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
392
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
393
-                $date = date('c',$date);
392
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
393
+				$date = date('c',$date);
394 394
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
395 395
 
396 396
 		return $spotter_array;
397 397
 	}
398 398
 
399 399
 
400
-        /**
401
-	* Gets all the spotter information based on a particular id
402
-	*
403
-	* @return Array the spotter information
404
-	*
405
-	*/
400
+		/**
401
+		 * Gets all the spotter information based on a particular id
402
+		 *
403
+		 * @return Array the spotter information
404
+		 *
405
+		 */
406 406
 	public function getAllLiveMarineDataById($id,$liveinterval = false)
407 407
 	{
408 408
 		global $globalDBdriver, $globalLiveInterval;
@@ -430,18 +430,18 @@  discard block
 block discarded – undo
430 430
 		return $spotter_array;
431 431
 	}
432 432
 
433
-        /**
434
-	* Gets all the spotter information based on a particular ident
435
-	*
436
-	* @return Array the spotter information
437
-	*
438
-	*/
433
+		/**
434
+		 * Gets all the spotter information based on a particular ident
435
+		 *
436
+		 * @return Array the spotter information
437
+		 *
438
+		 */
439 439
 	public function getAllLiveMarineDataByIdent($ident)
440 440
 	{
441 441
 		date_default_timezone_set('UTC');
442 442
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
443 443
 		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
444
-    		try {
444
+			try {
445 445
 			
446 446
 			$sth = $this->db->prepare($query);
447 447
 			$sth->execute(array(':ident' => $ident));
@@ -455,23 +455,23 @@  discard block
 block discarded – undo
455 455
 
456 456
 
457 457
 	/**
458
-	* Deletes all info in the table
459
-	*
460
-	* @return String success or false
461
-	*
462
-	*/
458
+	 * Deletes all info in the table
459
+	 *
460
+	 * @return String success or false
461
+	 *
462
+	 */
463 463
 	public function deleteLiveMarineData()
464 464
 	{
465 465
 		global $globalDBdriver;
466 466
 		if ($globalDBdriver == 'mysql') {
467 467
 			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
468 468
 			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';
469
-            		//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
469
+					//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
470 470
 		} else {
471 471
 			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";
472 472
 		}
473 473
         
474
-    		try {
474
+			try {
475 475
 			
476 476
 			$sth = $this->db->prepare($query);
477 477
 			$sth->execute();
@@ -483,18 +483,18 @@  discard block
 block discarded – undo
483 483
 	}
484 484
 
485 485
 	/**
486
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
487
-	*
488
-	* @return String success or false
489
-	*
490
-	*/
486
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
487
+	 *
488
+	 * @return String success or false
489
+	 *
490
+	 */
491 491
 	public function deleteLiveMarineDataNotUpdated()
492 492
 	{
493 493
 		global $globalDBdriver, $globalDebug;
494 494
 		if ($globalDBdriver == 'mysql') {
495 495
 			//$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0';
496
-    			$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
497
-    			try {
496
+				$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
497
+				try {
498 498
 				
499 499
 				$sth = $this->db->prepare($query);
500 500
 				$sth->execute();
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 				return "error";
503 503
 			}
504 504
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
505
-                        $i = 0;
506
-                        $j =0;
505
+						$i = 0;
506
+						$j =0;
507 507
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
508 508
 			foreach($all as $row)
509 509
 			{
@@ -511,20 +511,20 @@  discard block
 block discarded – undo
511 511
 				$j++;
512 512
 				if ($j == 30) {
513 513
 					if ($globalDebug) echo ".";
514
-				    	try {
514
+						try {
515 515
 						
516 516
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
517 517
 						$sth->execute();
518 518
 					} catch(PDOException $e) {
519 519
 						return "error";
520 520
 					}
521
-                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
522
-                                	$j = 0;
521
+									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
522
+									$j = 0;
523 523
 				}
524 524
 				$query_delete .= "'".$row['fammarine_id']."',";
525 525
 			}
526 526
 			if ($i > 0) {
527
-    				try {
527
+					try {
528 528
 					
529 529
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
530 530
 					$sth->execute();
@@ -535,9 +535,9 @@  discard block
 block discarded – undo
535 535
 			return "success";
536 536
 		} elseif ($globalDBdriver == 'pgsql') {
537 537
 			//$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0";
538
-    			//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
539
-    			$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
540
-    			try {
538
+				//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
539
+				$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
540
+				try {
541 541
 				
542 542
 				$sth = $this->db->prepare($query);
543 543
 				$sth->execute();
@@ -581,17 +581,17 @@  discard block
 block discarded – undo
581 581
 	}
582 582
 
583 583
 	/**
584
-	* Deletes all info in the table for an ident
585
-	*
586
-	* @return String success or false
587
-	*
588
-	*/
584
+	 * Deletes all info in the table for an ident
585
+	 *
586
+	 * @return String success or false
587
+	 *
588
+	 */
589 589
 	public function deleteLiveMarineDataByIdent($ident)
590 590
 	{
591 591
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
592 592
 		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
593 593
         
594
-    		try {
594
+			try {
595 595
 			
596 596
 			$sth = $this->db->prepare($query);
597 597
 			$sth->execute(array(':ident' => $ident));
@@ -603,17 +603,17 @@  discard block
 block discarded – undo
603 603
 	}
604 604
 
605 605
 	/**
606
-	* Deletes all info in the table for an id
607
-	*
608
-	* @return String success or false
609
-	*
610
-	*/
606
+	 * Deletes all info in the table for an id
607
+	 *
608
+	 * @return String success or false
609
+	 *
610
+	 */
611 611
 	public function deleteLiveMarineDataById($id)
612 612
 	{
613 613
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
614 614
 		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
615 615
         
616
-    		try {
616
+			try {
617 617
 			
618 618
 			$sth = $this->db->prepare($query);
619 619
 			$sth->execute(array(':id' => $id));
@@ -626,11 +626,11 @@  discard block
 block discarded – undo
626 626
 
627 627
 
628 628
 	/**
629
-	* Gets the aircraft ident within the last hour
630
-	*
631
-	* @return String the ident
632
-	*
633
-	*/
629
+	 * Gets the aircraft ident within the last hour
630
+	 *
631
+	 * @return String the ident
632
+	 *
633
+	 */
634 634
 	public function getIdentFromLastHour($ident)
635 635
 	{
636 636
 		global $globalDBdriver, $globalTimezone;
@@ -656,14 +656,14 @@  discard block
 block discarded – undo
656 656
 			$ident_result = $row['ident'];
657 657
 		}
658 658
 		return $ident_result;
659
-        }
659
+		}
660 660
 
661 661
 	/**
662
-	* Check recent aircraft
663
-	*
664
-	* @return String the ident
665
-	*
666
-	*/
662
+	 * Check recent aircraft
663
+	 *
664
+	 * @return String the ident
665
+	 *
666
+	 */
667 667
 	public function checkIdentRecent($ident)
668 668
 	{
669 669
 		global $globalDBdriver, $globalTimezone;
@@ -689,14 +689,14 @@  discard block
 block discarded – undo
689 689
 			$ident_result = $row['fammarine_id'];
690 690
 		}
691 691
 		return $ident_result;
692
-        }
692
+		}
693 693
 
694 694
 	/**
695
-	* Check recent aircraft by id
696
-	*
697
-	* @return String the ident
698
-	*
699
-	*/
695
+	 * Check recent aircraft by id
696
+	 *
697
+	 * @return String the ident
698
+	 *
699
+	 */
700 700
 	public function checkIdRecent($id)
701 701
 	{
702 702
 		global $globalDBdriver, $globalTimezone;
@@ -722,14 +722,14 @@  discard block
 block discarded – undo
722 722
 			$ident_result = $row['fammarine_id'];
723 723
 		}
724 724
 		return $ident_result;
725
-        }
725
+		}
726 726
 
727 727
 	/**
728
-	* Check recent aircraft by mmsi
729
-	*
730
-	* @return String the ident
731
-	*
732
-	*/
728
+	 * Check recent aircraft by mmsi
729
+	 *
730
+	 * @return String the ident
731
+	 *
732
+	 */
733 733
 	public function checkMMSIRecent($mmsi)
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
@@ -755,19 +755,19 @@  discard block
 block discarded – undo
755 755
 			$ident_result = $row['fammarine_id'];
756 756
 		}
757 757
 		return $ident_result;
758
-        }
758
+		}
759 759
 
760 760
 	/**
761
-	* Adds a new spotter data
762
-	*
763
-	* @param String $fammarine_id the ID from flightaware
764
-	* @param String $ident the flight ident
765
-	* @param String $aircraft_icao the aircraft type
766
-	* @param String $departure_airport_icao the departure airport
767
-	* @param String $arrival_airport_icao the arrival airport
768
-	* @return String success or false
769
-	*
770
-	*/
761
+	 * Adds a new spotter data
762
+	 *
763
+	 * @param String $fammarine_id the ID from flightaware
764
+	 * @param String $ident the flight ident
765
+	 * @param String $aircraft_icao the aircraft type
766
+	 * @param String $departure_airport_icao the departure airport
767
+	 * @param String $arrival_airport_icao the arrival airport
768
+	 * @return String success or false
769
+	 *
770
+	 */
771 771
 	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
772 772
 	{
773 773
 		global $globalURL, $globalArchive, $globalDebug;
@@ -838,9 +838,9 @@  discard block
 block discarded – undo
838 838
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
839 839
 		
840 840
 
841
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
842
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
843
-            	if ($arrival_date == '') $arrival_date = NULL;
841
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
842
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
843
+				if ($arrival_date == '') $arrival_date = NULL;
844 844
 		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
845 845
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
846 846
 
@@ -849,9 +849,9 @@  discard block
 block discarded – undo
849 849
 			
850 850
 			$sth = $this->db->prepare($query);
851 851
 			$sth->execute($query_values);
852
-                } catch(PDOException $e) {
853
-                	return "error : ".$e->getMessage();
854
-                }
852
+				} catch(PDOException $e) {
853
+					return "error : ".$e->getMessage();
854
+				}
855 855
 		/*
856 856
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
857 857
 		    if ($globalDebug) echo '(Add to SBS archive : ';
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
72 72
 				}
73 73
 			}
74
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
74
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
75 75
 		}
76 76
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
77
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
78 78
 		}
79 79
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80 80
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81 81
 		if ($filter_query_where != '') {
82
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
82
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
83 83
 		}
84 84
 		$filter_query = $filter_query_join.$filter_query_where;
85 85
 		return $filter_query;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		if ($limit != '')
103 103
 		{
104 104
 			$limit_array = explode(',', $limit);
105
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
106
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
105
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
107 107
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
108 108
 			{
109 109
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		} else {
127 127
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
128 128
 		}
129
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
129
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
130 130
 
131 131
 		return $spotter_array;
132 132
 	}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		global $globalDBdriver, $globalLiveInterval;
143 143
 		date_default_timezone_set('UTC');
144 144
 
145
-		$filter_query = $this->getFilter($filter,true,true);
145
+		$filter_query = $this->getFilter($filter, true, true);
146 146
 
147 147
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
148 148
 		if ($globalDBdriver == 'mysql') {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 		try {
157 157
 			$sth = $this->db->prepare($query);
158 158
 			$sth->execute();
159
-		} catch(PDOException $e) {
159
+		} catch (PDOException $e) {
160 160
 			echo $e->getMessage();
161 161
 			die;
162 162
 		}
@@ -176,15 +176,15 @@  discard block
 block discarded – undo
176 176
 		global $globalDBdriver, $globalLiveInterval;
177 177
 		date_default_timezone_set('UTC');
178 178
 
179
-		$filter_query = $this->getFilter($filter,true,true);
179
+		$filter_query = $this->getFilter($filter, true, true);
180 180
 
181 181
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
182 182
 		if ($globalDBdriver == 'mysql') {
183
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
183
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184 184
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
185 185
 			ORDER BY marine_live.fammarine_id, marine_live.date";
186 186
                 } else {
187
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
187
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
188 188
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
189 189
 			ORDER BY marine_live.fammarine_id, marine_live.date";
190 190
 		}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     		try {
193 193
 			$sth = $this->db->prepare($query);
194 194
 			$sth->execute();
195
-		} catch(PDOException $e) {
195
+		} catch (PDOException $e) {
196 196
 			echo $e->getMessage();
197 197
 			die;
198 198
 		}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	public function getLiveMarineCount($filter = array())
210 210
 	{
211 211
 		global $globalDBdriver, $globalLiveInterval;
212
-		$filter_query = $this->getFilter($filter,true,true);
212
+		$filter_query = $this->getFilter($filter, true, true);
213 213
 
214 214
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
215 215
 		if ($globalDBdriver == 'mysql') {
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		try {
221 221
 			$sth = $this->db->prepare($query);
222 222
 			$sth->execute();
223
-		} catch(PDOException $e) {
223
+		} catch (PDOException $e) {
224 224
 			echo $e->getMessage();
225 225
 			die;
226 226
 		}
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 		$filter_query = $this->getFilter($filter);
244 244
 
245 245
 		if (is_array($coord)) {
246
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
247
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
248
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
246
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
247
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
248
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
249
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
250 250
 		} else return array();
251 251
 		if ($globalDBdriver == 'mysql') {
252 252
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
                 if ($interval == '1m')
299 299
                 {
300 300
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
301
-                } else if ($interval == '15m'){
301
+                } else if ($interval == '15m') {
302 302
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
303 303
                 } 
304 304
             }
@@ -306,14 +306,14 @@  discard block
 block discarded – undo
306 306
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
307 307
         }
308 308
 
309
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
309
+                $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
310 310
                    WHERE marine_live.latitude <> '' 
311 311
                                    AND marine_live.longitude <> '' 
312 312
                    ".$additional_query."
313 313
                    HAVING distance < :radius  
314 314
                                    ORDER BY distance";
315 315
 
316
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
316
+                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
317 317
 
318 318
                 return $spotter_array;
319 319
         }
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 		date_default_timezone_set('UTC');
332 332
 
333 333
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
334
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
334
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
335 335
 
336
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
336
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
337 337
 
338 338
 		return $spotter_array;
339 339
 	}
@@ -344,16 +344,16 @@  discard block
 block discarded – undo
344 344
 	* @return Array the spotter information
345 345
 	*
346 346
 	*/
347
-	public function getDateLiveMarineDataByIdent($ident,$date)
347
+	public function getDateLiveMarineDataByIdent($ident, $date)
348 348
 	{
349 349
 		$Marine = new Marine($this->db);
350 350
 		date_default_timezone_set('UTC');
351 351
 
352 352
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
353
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
353
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
354 354
 
355
-                $date = date('c',$date);
356
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
355
+                $date = date('c', $date);
356
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
357 357
 
358 358
 		return $spotter_array;
359 359
 	}
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
 		date_default_timezone_set('UTC');
371 371
 
372 372
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
373
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
373
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
374 374
 
375
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
375
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
376 376
 
377 377
 		return $spotter_array;
378 378
 	}
@@ -383,15 +383,15 @@  discard block
 block discarded – undo
383 383
 	* @return Array the spotter information
384 384
 	*
385 385
 	*/
386
-	public function getDateLiveMarineDataById($id,$date)
386
+	public function getDateLiveMarineDataById($id, $date)
387 387
 	{
388 388
 		$Marine = new Marine($this->db);
389 389
 		date_default_timezone_set('UTC');
390 390
 
391 391
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
392
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
393
-                $date = date('c',$date);
394
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
392
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
393
+                $date = date('c', $date);
394
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
395 395
 
396 396
 		return $spotter_array;
397 397
 	}
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	* @return Array the spotter information
404 404
 	*
405 405
 	*/
406
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
406
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
407 407
 	{
408 408
 		global $globalDBdriver, $globalLiveInterval;
409 409
 		date_default_timezone_set('UTC');
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 		try {
423 423
 			$sth = $this->db->prepare($query);
424 424
 			$sth->execute(array(':id' => $id));
425
-		} catch(PDOException $e) {
425
+		} catch (PDOException $e) {
426 426
 			echo $e->getMessage();
427 427
 			die;
428 428
 		}
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
 	{
441 441
 		date_default_timezone_set('UTC');
442 442
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
443
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
443
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
444 444
     		try {
445 445
 			
446 446
 			$sth = $this->db->prepare($query);
447 447
 			$sth->execute(array(':ident' => $ident));
448
-		} catch(PDOException $e) {
448
+		} catch (PDOException $e) {
449 449
 			echo $e->getMessage();
450 450
 			die;
451 451
 		}
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 			
476 476
 			$sth = $this->db->prepare($query);
477 477
 			$sth->execute();
478
-		} catch(PDOException $e) {
478
+		} catch (PDOException $e) {
479 479
 			return "error";
480 480
 		}
481 481
 
@@ -498,14 +498,14 @@  discard block
 block discarded – undo
498 498
 				
499 499
 				$sth = $this->db->prepare($query);
500 500
 				$sth->execute();
501
-			} catch(PDOException $e) {
501
+			} catch (PDOException $e) {
502 502
 				return "error";
503 503
 			}
504 504
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
505 505
                         $i = 0;
506
-                        $j =0;
506
+                        $j = 0;
507 507
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
508
-			foreach($all as $row)
508
+			foreach ($all as $row)
509 509
 			{
510 510
 				$i++;
511 511
 				$j++;
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
 					if ($globalDebug) echo ".";
514 514
 				    	try {
515 515
 						
516
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
516
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
517 517
 						$sth->execute();
518
-					} catch(PDOException $e) {
518
+					} catch (PDOException $e) {
519 519
 						return "error";
520 520
 					}
521 521
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
 			if ($i > 0) {
527 527
     				try {
528 528
 					
529
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
529
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
530 530
 					$sth->execute();
531
-				} catch(PDOException $e) {
531
+				} catch (PDOException $e) {
532 532
 					return "error";
533 533
 				}
534 534
 			}
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 				
542 542
 				$sth = $this->db->prepare($query);
543 543
 				$sth->execute();
544
-			} catch(PDOException $e) {
544
+			} catch (PDOException $e) {
545 545
 				return "error";
546 546
 			}
547 547
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -589,13 +589,13 @@  discard block
 block discarded – undo
589 589
 	public function deleteLiveMarineDataByIdent($ident)
590 590
 	{
591 591
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
592
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
592
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
593 593
         
594 594
     		try {
595 595
 			
596 596
 			$sth = $this->db->prepare($query);
597 597
 			$sth->execute(array(':ident' => $ident));
598
-		} catch(PDOException $e) {
598
+		} catch (PDOException $e) {
599 599
 			return "error";
600 600
 		}
601 601
 
@@ -611,13 +611,13 @@  discard block
 block discarded – undo
611 611
 	public function deleteLiveMarineDataById($id)
612 612
 	{
613 613
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
614
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
614
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
615 615
         
616 616
     		try {
617 617
 			
618 618
 			$sth = $this->db->prepare($query);
619 619
 			$sth->execute(array(':id' => $id));
620
-		} catch(PDOException $e) {
620
+		} catch (PDOException $e) {
621 621
 			return "error";
622 622
 		}
623 623
 
@@ -635,13 +635,13 @@  discard block
 block discarded – undo
635 635
 	{
636 636
 		global $globalDBdriver, $globalTimezone;
637 637
 		if ($globalDBdriver == 'mysql') {
638
-			$query  = 'SELECT marine_live.ident FROM marine_live 
638
+			$query = 'SELECT marine_live.ident FROM marine_live 
639 639
 				WHERE marine_live.ident = :ident 
640 640
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
641 641
 				AND marine_live.date < UTC_TIMESTAMP()';
642 642
 			$query_data = array(':ident' => $ident);
643 643
 		} else {
644
-			$query  = "SELECT marine_live.ident FROM marine_live 
644
+			$query = "SELECT marine_live.ident FROM marine_live 
645 645
 				WHERE marine_live.ident = :ident 
646 646
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
647 647
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -650,8 +650,8 @@  discard block
 block discarded – undo
650 650
 		
651 651
 		$sth = $this->db->prepare($query);
652 652
 		$sth->execute($query_data);
653
-		$ident_result='';
654
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
653
+		$ident_result = '';
654
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
655 655
 		{
656 656
 			$ident_result = $row['ident'];
657 657
 		}
@@ -668,13 +668,13 @@  discard block
 block discarded – undo
668 668
 	{
669 669
 		global $globalDBdriver, $globalTimezone;
670 670
 		if ($globalDBdriver == 'mysql') {
671
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
671
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
672 672
 				WHERE marine_live.ident = :ident 
673 673
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
674 674
 //				AND marine_live.date < UTC_TIMESTAMP()";
675 675
 			$query_data = array(':ident' => $ident);
676 676
 		} else {
677
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
677
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
678 678
 				WHERE marine_live.ident = :ident 
679 679
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
680 680
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
 		
684 684
 		$sth = $this->db->prepare($query);
685 685
 		$sth->execute($query_data);
686
-		$ident_result='';
687
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
686
+		$ident_result = '';
687
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
688 688
 		{
689 689
 			$ident_result = $row['fammarine_id'];
690 690
 		}
@@ -701,13 +701,13 @@  discard block
 block discarded – undo
701 701
 	{
702 702
 		global $globalDBdriver, $globalTimezone;
703 703
 		if ($globalDBdriver == 'mysql') {
704
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
704
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
705 705
 				WHERE marine_live.fammarine_id = :id 
706 706
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
707 707
 //				AND marine_live.date < UTC_TIMESTAMP()";
708 708
 			$query_data = array(':id' => $id);
709 709
 		} else {
710
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
710
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
711 711
 				WHERE marine_live.fammarine_id = :id 
712 712
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
713 713
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
 		
717 717
 		$sth = $this->db->prepare($query);
718 718
 		$sth->execute($query_data);
719
-		$ident_result='';
720
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
719
+		$ident_result = '';
720
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
721 721
 		{
722 722
 			$ident_result = $row['fammarine_id'];
723 723
 		}
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
736 736
 		if ($globalDBdriver == 'mysql') {
737
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
737
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
738 738
 				WHERE marine_live.mmsi = :mmsi 
739 739
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
740 740
 //				AND marine_live.date < UTC_TIMESTAMP()";
741 741
 			$query_data = array(':mmsi' => $mmsi);
742 742
 		} else {
743
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
743
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
744 744
 				WHERE marine_live.mmsi = :mmsi 
745 745
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
746 746
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-		$ident_result='';
753
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
752
+		$ident_result = '';
753
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['fammarine_id'];
756 756
 		}
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 	* @return String success or false
769 769
 	*
770 770
 	*/
771
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
771
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
772 772
 	{
773 773
 		global $globalURL, $globalArchive, $globalDebug;
774 774
 		$Common = new Common();
@@ -820,36 +820,36 @@  discard block
 block discarded – undo
820 820
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
821 821
 
822 822
         
823
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
824
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
825
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
826
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
827
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
828
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
829
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
830
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
831
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
832
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
833
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
834
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
835
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
836
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
837
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
838
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
823
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
824
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
825
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
826
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
827
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
828
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
829
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
830
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
831
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
832
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
833
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
834
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
835
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
836
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
837
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
838
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
839 839
 		
840 840
 
841
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
842
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
841
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
842
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
843 843
             	if ($arrival_date == '') $arrival_date = NULL;
844
-		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
844
+		$query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
845 845
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
846 846
 
847
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
847
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
848 848
 		try {
849 849
 			
850 850
 			$sth = $this->db->prepare($query);
851 851
 			$sth->execute($query_values);
852
-                } catch(PDOException $e) {
852
+                } catch (PDOException $e) {
853 853
                 	return "error : ".$e->getMessage();
854 854
                 }
855 855
 		/*
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 
867 867
 	public function getOrderBy()
868 868
 	{
869
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
869
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
870 870
 		return $orderby;
871 871
 	}
872 872
 
Please login to merge, or discard this patch.
require/class.Marine.php 4 patches
Braces   +145 added lines, -52 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
 		if (isset($filter[0]['source'])) {
32 32
 			$filters = array_merge($filters,$filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) {
35
+			$filter = array_merge($filter,$globalFilter);
36
+		}
35 37
 		$filter_query_join = '';
36 38
 		$filter_query_where = '';
37 39
 		foreach($filters as $flt) {
@@ -70,8 +72,11 @@  discard block
 block discarded – undo
70 72
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
71 73
 			}
72 74
 		}
73
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75
+		if ($filter_query_where == '' && $where) {
76
+			$filter_query_where = ' WHERE';
77
+		} elseif ($filter_query_where != '' && $and) {
78
+			$filter_query_where .= ' AND';
79
+		}
75 80
 		if ($filter_query_where != '') {
76 81
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
77 82
 		}
@@ -125,25 +130,40 @@  discard block
 block discarded – undo
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
126 131
 			} elseif (isset($row['spotter_archive_output_id'])) {
127 132
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
128
-			*/} 
129
-			elseif (isset($row['marineid'])) {
133
+			*/} elseif (isset($row['marineid'])) {
130 134
 				$temp_array['marineid'] = $row['marineid'];
131 135
 			} else {
132 136
 				$temp_array['marineid'] = '';
133 137
 			}
134
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
135
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
136
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
138
+			if (isset($row['fammarine_id'])) {
139
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
140
+			}
141
+			if (isset($row['mmsi'])) {
142
+				$temp_array['mmsi'] = $row['mmsi'];
143
+			}
144
+			if (isset($row['type'])) {
145
+				$temp_array['type'] = $row['type'];
146
+			}
137 147
 			$temp_array['ident'] = $row['ident'];
138
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
139
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
140
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
148
+			if (isset($row['latitude'])) {
149
+				$temp_array['latitude'] = $row['latitude'];
150
+			}
151
+			if (isset($row['longitude'])) {
152
+				$temp_array['longitude'] = $row['longitude'];
153
+			}
154
+			if (isset($row['format_source'])) {
155
+				$temp_array['format_source'] = $row['format_source'];
156
+			}
141 157
 			if (isset($row['heading'])) {
142 158
 				$temp_array['heading'] = $row['heading'];
143 159
 				$heading_direction = $this->parseDirection($row['heading']);
144
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
160
+				if (isset($heading_direction[0]['direction_fullname'])) {
161
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
162
+				}
163
+			}
164
+			if (isset($row['ground_speed'])) {
165
+				$temp_array['ground_speed'] = $row['ground_speed'];
145 166
 			}
146
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
147 167
 			
148 168
 			if (isset($row['date'])) {
149 169
 				$dateArray = $this->parseDateString($row['date']);
@@ -186,13 +206,21 @@  discard block
 block discarded – undo
186 206
 			}
187 207
 			
188 208
 			$fromsource = NULL;
189
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
190
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
191
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
209
+			if (isset($row['source_name']) && $row['source_name'] != '') {
210
+				$temp_array['source_name'] = $row['source_name'];
211
+			}
212
+			if (isset($row['over_country']) && $row['over_country'] != '') {
213
+				$temp_array['over_country'] = $row['over_country'];
214
+			}
215
+			if (isset($row['distance']) && $row['distance'] != '') {
216
+				$temp_array['distance'] = $row['distance'];
217
+			}
192 218
 			$temp_array['query_number_rows'] = $num_rows;
193 219
 			$spotter_array[] = $temp_array;
194 220
 		}
195
-		if ($num_rows == 0) return array();
221
+		if ($num_rows == 0) {
222
+			return array();
223
+		}
196 224
 		$spotter_array[0]['query_number_rows'] = $num_rows;
197 225
 		return $spotter_array;
198 226
 	}	
@@ -223,8 +251,12 @@  discard block
 block discarded – undo
223 251
 			{
224 252
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
225 253
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
226
-			} else $limit_query = "";
227
-		} else $limit_query = "";
254
+			} else {
255
+				$limit_query = "";
256
+			}
257
+		} else {
258
+			$limit_query = "";
259
+		}
228 260
 		
229 261
 		if ($sort != "")
230 262
 		{
@@ -252,7 +284,9 @@  discard block
 block discarded – undo
252 284
 		global $global_query;
253 285
 		
254 286
 		date_default_timezone_set('UTC');
255
-		if ($id == '') return array();
287
+		if ($id == '') {
288
+			return array();
289
+		}
256 290
 		$additional_query = "marine_output.fammarine_id = :id";
257 291
 		$query_values = array(':id' => $id);
258 292
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -395,8 +429,11 @@  discard block
 block discarded – undo
395 429
 		$query .= " ORDER BY marine_output.source_name ASC";
396 430
 
397 431
 		$sth = $this->db->prepare($query);
398
-		if (!empty($query_values)) $sth->execute($query_values);
399
-		else $sth->execute();
432
+		if (!empty($query_values)) {
433
+			$sth->execute($query_values);
434
+		} else {
435
+			$sth->execute();
436
+		}
400 437
 
401 438
 		$source_array = array();
402 439
 		$temp_array = array();
@@ -451,8 +488,11 @@  discard block
 block discarded – undo
451 488
 		$sth = $this->db->prepare($query);
452 489
 		$sth->execute(array(':mmsi' => $mmsi));
453 490
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
454
-		if (isset($result[0])) return $result[0];
455
-		else return array();
491
+		if (isset($result[0])) {
492
+			return $result[0];
493
+		} else {
494
+			return array();
495
+		}
456 496
 	}
457 497
 
458 498
 	/*
@@ -468,7 +508,9 @@  discard block
 block discarded – undo
468 508
 			date_default_timezone_set($globalTimezone);
469 509
 			$datetime = new DateTime();
470 510
 			$offset = $datetime->format('P');
471
-		} else $offset = '+00:00';
511
+		} else {
512
+			$offset = '+00:00';
513
+		}
472 514
 
473 515
 		if ($globalDBdriver == 'mysql') {
474 516
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -663,9 +705,15 @@  discard block
 block discarded – undo
663 705
             		$latitude = 0;
664 706
             		$longitude = 0;
665 707
             	}
666
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
667
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
668
-                if ($arrival_date == '') $arrival_date = NULL;
708
+                if ($heading == '' || $Common->isInteger($heading) === false) {
709
+                	$heading = 0;
710
+                }
711
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
712
+                	$groundspeed = 0;
713
+                }
714
+                if ($arrival_date == '') {
715
+                	$arrival_date = NULL;
716
+                }
669 717
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
670 718
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
671 719
 
@@ -829,12 +877,18 @@  discard block
 block discarded – undo
829 877
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
830 878
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
831 879
 		 if ($olderthanmonths > 0) {
832
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
833
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
880
+			if ($globalDBdriver == 'mysql') {
881
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
882
+			} else {
883
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
884
+			}
834 885
 		}
835 886
 		if ($sincedate != '') {
836
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
837
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
887
+			if ($globalDBdriver == 'mysql') {
888
+				$query .= " AND marine_output.date > '".$sincedate."'";
889
+			} else {
890
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
891
+			}
838 892
 		}
839 893
 		$query_values = array();
840 894
 		if ($year != '') {
@@ -865,7 +919,9 @@  discard block
 block discarded – undo
865 919
 			}
866 920
 		}
867 921
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
868
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
922
+		if ($limit) {
923
+			$query .= " LIMIT 10 OFFSET 0";
924
+		}
869 925
       		
870 926
 		$sth = $this->db->prepare($query);
871 927
 		$sth->execute($query_values);
@@ -900,7 +956,9 @@  discard block
 block discarded – undo
900 956
 			date_default_timezone_set($globalTimezone);
901 957
 			$datetime = new DateTime();
902 958
 			$offset = $datetime->format('P');
903
-		} else $offset = '+00:00';
959
+		} else {
960
+			$offset = '+00:00';
961
+		}
904 962
 
905 963
 		if ($globalDBdriver == 'mysql') {
906 964
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -950,7 +1008,9 @@  discard block
 block discarded – undo
950 1008
 			date_default_timezone_set($globalTimezone);
951 1009
 			$datetime = new DateTime();
952 1010
 			$offset = $datetime->format('P');
953
-		} else $offset = '+00:00';
1011
+		} else {
1012
+			$offset = '+00:00';
1013
+		}
954 1014
 		$filter_query = $this->getFilter($filters,true,true);
955 1015
 		if ($globalDBdriver == 'mysql') {
956 1016
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -996,7 +1056,9 @@  discard block
 block discarded – undo
996 1056
 			date_default_timezone_set($globalTimezone);
997 1057
 			$datetime = new DateTime();
998 1058
 			$offset = $datetime->format('P');
999
-		} else $offset = '+00:00';
1059
+		} else {
1060
+			$offset = '+00:00';
1061
+		}
1000 1062
 		$filter_query = $this->getFilter($filters,true,true);
1001 1063
 		if ($globalDBdriver == 'mysql') {
1002 1064
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1044,7 +1106,9 @@  discard block
 block discarded – undo
1044 1106
 			date_default_timezone_set($globalTimezone);
1045 1107
 			$datetime = new DateTime();
1046 1108
 			$offset = $datetime->format('P');
1047
-		} else $offset = '+00:00';
1109
+		} else {
1110
+			$offset = '+00:00';
1111
+		}
1048 1112
 
1049 1113
 		if ($globalDBdriver == 'mysql') {
1050 1114
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1093,7 +1157,9 @@  discard block
 block discarded – undo
1093 1157
 			date_default_timezone_set($globalTimezone);
1094 1158
 			$datetime = new DateTime();
1095 1159
 			$offset = $datetime->format('P');
1096
-		} else $offset = '+00:00';
1160
+		} else {
1161
+			$offset = '+00:00';
1162
+		}
1097 1163
 		$filter_query = $this->getFilter($filters,true,true);
1098 1164
 		if ($globalDBdriver == 'mysql') {
1099 1165
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1142,7 +1208,9 @@  discard block
 block discarded – undo
1142 1208
 			date_default_timezone_set($globalTimezone);
1143 1209
 			$datetime = new DateTime();
1144 1210
 			$offset = $datetime->format('P');
1145
-		} else $offset = '+00:00';
1211
+		} else {
1212
+			$offset = '+00:00';
1213
+		}
1146 1214
 
1147 1215
 		$orderby_sql = '';
1148 1216
 		if ($orderby == "hour")
@@ -1211,7 +1279,9 @@  discard block
 block discarded – undo
1211 1279
 			date_default_timezone_set($globalTimezone);
1212 1280
 			$datetime = new DateTime($date);
1213 1281
 			$offset = $datetime->format('P');
1214
-		} else $offset = '+00:00';
1282
+		} else {
1283
+			$offset = '+00:00';
1284
+		}
1215 1285
 
1216 1286
 		if ($globalDBdriver == 'mysql') {
1217 1287
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1259,7 +1329,9 @@  discard block
 block discarded – undo
1259 1329
 			date_default_timezone_set($globalTimezone);
1260 1330
 			$datetime = new DateTime();
1261 1331
 			$offset = $datetime->format('P');
1262
-		} else $offset = '+00:00';
1332
+		} else {
1333
+			$offset = '+00:00';
1334
+		}
1263 1335
 
1264 1336
 		if ($globalDBdriver == 'mysql') {
1265 1337
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1323,8 +1395,11 @@  discard block
 block discarded – undo
1323 1395
 				$query_values = array_merge($query_values,array(':month' => $month));
1324 1396
 			}
1325 1397
 		}
1326
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1327
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1398
+		if (empty($query_values)) {
1399
+			$queryi .= $this->getFilter($filters);
1400
+		} else {
1401
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1402
+		}
1328 1403
 		
1329 1404
 		$sth = $this->db->prepare($queryi);
1330 1405
 		$sth->execute($query_values);
@@ -1346,7 +1421,9 @@  discard block
 block discarded – undo
1346 1421
 			date_default_timezone_set($globalTimezone);
1347 1422
 			$datetime = new DateTime();
1348 1423
 			$offset = $datetime->format('P');
1349
-		} else $offset = '+00:00';
1424
+		} else {
1425
+			$offset = '+00:00';
1426
+		}
1350 1427
 
1351 1428
 		if ($globalDBdriver == 'mysql') {
1352 1429
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1450,7 +1527,9 @@  discard block
 block discarded – undo
1450 1527
 	*/
1451 1528
 	public function parseDirection($direction = 0)
1452 1529
 	{
1453
-		if ($direction == '') $direction = 0;
1530
+		if ($direction == '') {
1531
+			$direction = 0;
1532
+		}
1454 1533
 		$direction_array = array();
1455 1534
 		$temp_array = array();
1456 1535
 
@@ -1539,7 +1618,9 @@  discard block
 block discarded – undo
1539 1618
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1540 1619
 	
1541 1620
 		$Connection = new Connection($this->db);
1542
-		if (!$Connection->tableExists('countries')) return '';
1621
+		if (!$Connection->tableExists('countries')) {
1622
+			return '';
1623
+		}
1543 1624
 	
1544 1625
 		try {
1545 1626
 			/*
@@ -1559,9 +1640,13 @@  discard block
 block discarded – undo
1559 1640
 			$sth->closeCursor();
1560 1641
 			if (count($row) > 0) {
1561 1642
 				return $row;
1562
-			} else return '';
1643
+			} else {
1644
+				return '';
1645
+			}
1563 1646
 		} catch (PDOException $e) {
1564
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1647
+			if (isset($globalDebug) && $globalDebug) {
1648
+				echo 'Error : '.$e->getMessage()."\n";
1649
+			}
1565 1650
 			return '';
1566 1651
 		}
1567 1652
 	
@@ -1579,7 +1664,9 @@  discard block
 block discarded – undo
1579 1664
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1580 1665
 	
1581 1666
 		$Connection = new Connection($this->db);
1582
-		if (!$Connection->tableExists('countries')) return '';
1667
+		if (!$Connection->tableExists('countries')) {
1668
+			return '';
1669
+		}
1583 1670
 	
1584 1671
 		try {
1585 1672
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1591,9 +1678,13 @@  discard block
 block discarded – undo
1591 1678
 			$sth->closeCursor();
1592 1679
 			if (count($row) > 0) {
1593 1680
 				return $row;
1594
-			} else return '';
1681
+			} else {
1682
+				return '';
1683
+			}
1595 1684
 		} catch (PDOException $e) {
1596
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1685
+			if (isset($globalDebug) && $globalDebug) {
1686
+				echo 'Error : '.$e->getMessage()."\n";
1687
+			}
1597 1688
 			return '';
1598 1689
 		}
1599 1690
 	
@@ -1611,7 +1702,9 @@  discard block
 block discarded – undo
1611 1702
 	{
1612 1703
 		global $globalBitlyAccessToken;
1613 1704
 		
1614
-		if ($globalBitlyAccessToken == '') return $url;
1705
+		if ($globalBitlyAccessToken == '') {
1706
+			return $url;
1707
+		}
1615 1708
         
1616 1709
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1617 1710
 		
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -21 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	* Get SQL query part for filter used
17 17
 	* @param Array $filter the filter
18
-	* @return Array the SQL part
18
+	* @return string the SQL part
19 19
 	*/
20 20
 	
21 21
 	public function getFilter($filter = array(),$where = false,$and = false) {
@@ -552,25 +552,6 @@  discard block
 block discarded – undo
552 552
 	*
553 553
 	* @param String $fammarine_id the ID
554 554
 	* @param String $ident the marine ident
555
-	* @param String $departure_airport_icao the departure airport
556
-	* @param String $arrival_airport_icao the arrival airport
557
-	* @param String $latitude latitude of flight
558
-	* @param String $longitude latitude of flight
559
-	* @param String $waypoints waypoints of flight
560
-	* @param String $heading heading of flight
561
-	* @param String $groundspeed speed of flight
562
-	* @param String $date date of flight
563
-	* @param String $departure_airport_time departure time of flight
564
-	* @param String $arrival_airport_time arrival time of flight
565
-	* @param String $squawk squawk code of flight
566
-	* @param String $route_stop route stop of flight
567
-	* @param String $highlight highlight or not
568
-	* @param String $ModeS ModesS code of flight
569
-	* @param String $registration registration code of flight
570
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
571
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
572
-	* @param String $verticalrate vertival rate of flight
573
-	* @return String success or false
574 555
 	*/
575 556
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '')
576 557
 	{
@@ -1444,7 +1425,7 @@  discard block
 block discarded – undo
1444 1425
 	/**
1445 1426
 	* Parses the direction degrees to working
1446 1427
 	*
1447
-	* @param Float $direction the direction in degrees
1428
+	* @param integer $direction the direction in degrees
1448 1429
 	* @return Array the direction information
1449 1430
 	*
1450 1431
 	*/
Please login to merge, or discard this patch.
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	
21 21
 	public function getFilter($filter = array(),$where = false,$and = false) {
22 22
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 
82 82
 	/**
83
-	* Executes the SQL statements to get the spotter information
84
-	*
85
-	* @param String $query the SQL query
86
-	* @param Array $params parameter of the query
87
-	* @param String $limitQuery the limit query
88
-	* @return Array the spotter information
89
-	*
90
-	*/
83
+	 * Executes the SQL statements to get the spotter information
84
+	 *
85
+	 * @param String $query the SQL query
86
+	 * @param Array $params parameter of the query
87
+	 * @param String $limitQuery the limit query
88
+	 * @return Array the spotter information
89
+	 *
90
+	 */
91 91
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
92 92
 	{
93 93
 		date_default_timezone_set('UTC');
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	
200 200
 	
201 201
 	/**
202
-	* Gets all the spotter information based on the latest data entry
203
-	*
204
-	* @return Array the spotter information
205
-	*
206
-	*/
202
+	 * Gets all the spotter information based on the latest data entry
203
+	 *
204
+	 * @return Array the spotter information
205
+	 *
206
+	 */
207 207
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
208 208
 	{
209 209
 		global $global_query;
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
 	}
262 262
 
263 263
 	/**
264
-	* Gets all the spotter information based on the callsign
265
-	*
266
-	* @return Array the spotter information
267
-	*
268
-	*/
264
+	 * Gets all the spotter information based on the callsign
265
+	 *
266
+	 * @return Array the spotter information
267
+	 *
268
+	 */
269 269
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
270 270
 	{
271 271
 		global $global_query;
@@ -376,12 +376,12 @@  discard block
 block discarded – undo
376 376
 
377 377
 
378 378
 	/**
379
-	* Gets all source name
380
-	*
381
-	* @param String type format of source
382
-	* @return Array list of source name
383
-	*
384
-	*/
379
+	 * Gets all source name
380
+	 *
381
+	 * @param String type format of source
382
+	 * @return Array list of source name
383
+	 *
384
+	 */
385 385
 	public function getAllSourceName($type = '',$filters = array())
386 386
 	{
387 387
 		$filter_query = $this->getFilter($filters,true,true);
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
 
412 412
 
413 413
 	/**
414
-	* Gets a list of all idents/callsigns
415
-	*
416
-	* @return Array list of ident/callsign names
417
-	*
418
-	*/
414
+	 * Gets a list of all idents/callsigns
415
+	 *
416
+	 * @return Array list of ident/callsign names
417
+	 *
418
+	 */
419 419
 	public function getAllIdents($filters = array())
420 420
 	{
421 421
 		$filter_query = $this->getFilter($filters,true,true);
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
 	}
440 440
 
441 441
 	/**
442
-	* Gets all info from a mmsi
443
-	*
444
-	* @return Array list of mmsi info
445
-	*
446
-	*/
442
+	 * Gets all info from a mmsi
443
+	 *
444
+	 * @return Array list of mmsi info
445
+	 *
446
+	 */
447 447
 	public function getIdentity($mmsi)
448 448
 	{
449 449
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -500,18 +500,18 @@  discard block
 block discarded – undo
500 500
 	
501 501
 	
502 502
 	/**
503
-	* Update ident tracker data
504
-	*
505
-	* @param String $fammarine_id the ID
506
-	* @param String $ident the marine ident
507
-	* @return String success or false
508
-	*
509
-	*/	
503
+	 * Update ident tracker data
504
+	 *
505
+	 * @param String $fammarine_id the ID
506
+	 * @param String $ident the marine ident
507
+	 * @return String success or false
508
+	 *
509
+	 */	
510 510
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
511 511
 	{
512 512
 
513 513
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
514
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
514
+				$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
515 515
 
516 516
 		try {
517 517
 			$sth = $this->db->prepare($query);
@@ -524,17 +524,17 @@  discard block
 block discarded – undo
524 524
 
525 525
 	}
526 526
 	/**
527
-	* Update latest marine data
528
-	*
529
-	* @param String $fammarine_id the ID
530
-	* @param String $ident the marine ident
531
-	* @return String success or false
532
-	*
533
-	*/	
527
+	 * Update latest marine data
528
+	 *
529
+	 * @param String $fammarine_id the ID
530
+	 * @param String $ident the marine ident
531
+	 * @return String success or false
532
+	 *
533
+	 */	
534 534
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
535 535
 	{
536 536
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
537
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
537
+				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
538 538
 
539 539
 		try {
540 540
 			$sth = $this->db->prepare($query);
@@ -548,30 +548,30 @@  discard block
 block discarded – undo
548 548
 	}
549 549
 
550 550
 	/**
551
-	* Adds a new spotter data
552
-	*
553
-	* @param String $fammarine_id the ID
554
-	* @param String $ident the marine ident
555
-	* @param String $departure_airport_icao the departure airport
556
-	* @param String $arrival_airport_icao the arrival airport
557
-	* @param String $latitude latitude of flight
558
-	* @param String $longitude latitude of flight
559
-	* @param String $waypoints waypoints of flight
560
-	* @param String $heading heading of flight
561
-	* @param String $groundspeed speed of flight
562
-	* @param String $date date of flight
563
-	* @param String $departure_airport_time departure time of flight
564
-	* @param String $arrival_airport_time arrival time of flight
565
-	* @param String $squawk squawk code of flight
566
-	* @param String $route_stop route stop of flight
567
-	* @param String $highlight highlight or not
568
-	* @param String $ModeS ModesS code of flight
569
-	* @param String $registration registration code of flight
570
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
571
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
572
-	* @param String $verticalrate vertival rate of flight
573
-	* @return String success or false
574
-	*/
551
+	 * Adds a new spotter data
552
+	 *
553
+	 * @param String $fammarine_id the ID
554
+	 * @param String $ident the marine ident
555
+	 * @param String $departure_airport_icao the departure airport
556
+	 * @param String $arrival_airport_icao the arrival airport
557
+	 * @param String $latitude latitude of flight
558
+	 * @param String $longitude latitude of flight
559
+	 * @param String $waypoints waypoints of flight
560
+	 * @param String $heading heading of flight
561
+	 * @param String $groundspeed speed of flight
562
+	 * @param String $date date of flight
563
+	 * @param String $departure_airport_time departure time of flight
564
+	 * @param String $arrival_airport_time arrival time of flight
565
+	 * @param String $squawk squawk code of flight
566
+	 * @param String $route_stop route stop of flight
567
+	 * @param String $highlight highlight or not
568
+	 * @param String $ModeS ModesS code of flight
569
+	 * @param String $registration registration code of flight
570
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
571
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
572
+	 * @param String $verticalrate vertival rate of flight
573
+	 * @return String success or false
574
+	 */
575 575
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '')
576 576
 	{
577 577
 		global $globalURL;
@@ -659,13 +659,13 @@  discard block
 block discarded – undo
659 659
 		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
660 660
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
661 661
 	
662
-                if ($latitude == '' && $longitude == '') {
663
-            		$latitude = 0;
664
-            		$longitude = 0;
665
-            	}
666
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
667
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
668
-                if ($arrival_date == '') $arrival_date = NULL;
662
+				if ($latitude == '' && $longitude == '') {
663
+					$latitude = 0;
664
+					$longitude = 0;
665
+				}
666
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
667
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
668
+				if ($arrival_date == '') $arrival_date = NULL;
669 669
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
670 670
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
671 671
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			$sth->execute($query_values);
677 677
 			$this->db = null;
678 678
 		} catch (PDOException $e) {
679
-		    return "error : ".$e->getMessage();
679
+			return "error : ".$e->getMessage();
680 680
 		}
681 681
 		
682 682
 		return "success";
@@ -685,11 +685,11 @@  discard block
 block discarded – undo
685 685
 	
686 686
   
687 687
 	/**
688
-	* Gets the aircraft ident within the last hour
689
-	*
690
-	* @return String the ident
691
-	*
692
-	*/
688
+	 * Gets the aircraft ident within the last hour
689
+	 *
690
+	 * @return String the ident
691
+	 *
692
+	 */
693 693
 	public function getIdentFromLastHour($ident)
694 694
 	{
695 695
 		global $globalDBdriver, $globalTimezone;
@@ -705,11 +705,11 @@  discard block
 block discarded – undo
705 705
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
706 706
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
707 707
 			$query_data = array(':ident' => $ident);
708
-    		}
708
+			}
709 709
 		
710 710
 		$sth = $this->db->prepare($query);
711 711
 		$sth->execute($query_data);
712
-    		$ident_result='';
712
+			$ident_result='';
713 713
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
714 714
 		{
715 715
 			$ident_result = $row['ident'];
@@ -720,11 +720,11 @@  discard block
 block discarded – undo
720 720
 	
721 721
 	
722 722
 	/**
723
-	* Gets the aircraft data from the last 20 seconds
724
-	*
725
-	* @return Array the spotter data
726
-	*
727
-	*/
723
+	 * Gets the aircraft data from the last 20 seconds
724
+	 *
725
+	 * @return Array the spotter data
726
+	 *
727
+	 */
728 728
 	public function getRealTimeData($q = '')
729 729
 	{
730 730
 		global $globalDBdriver;
@@ -762,11 +762,11 @@  discard block
 block discarded – undo
762 762
 	
763 763
 
764 764
 	/**
765
-	* Gets all number of flight over countries
766
-	*
767
-	* @return Array the airline country list
768
-	*
769
-	*/
765
+	 * Gets all number of flight over countries
766
+	 *
767
+	 * @return Array the airline country list
768
+	 *
769
+	 */
770 770
 /*
771 771
 	public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
772 772
 	{
@@ -817,11 +817,11 @@  discard block
 block discarded – undo
817 817
 	
818 818
 	
819 819
 	/**
820
-	* Gets all callsigns that have flown over
821
-	*
822
-	* @return Array the callsign list
823
-	*
824
-	*/
820
+	 * Gets all callsigns that have flown over
821
+	 *
822
+	 * @return Array the callsign list
823
+	 *
824
+	 */
825 825
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
826 826
 	{
827 827
 		global $globalDBdriver;
@@ -888,11 +888,11 @@  discard block
 block discarded – undo
888 888
 
889 889
 
890 890
 	/**
891
-	* Counts all dates
892
-	*
893
-	* @return Array the date list
894
-	*
895
-	*/
891
+	 * Counts all dates
892
+	 *
893
+	 * @return Array the date list
894
+	 *
895
+	 */
896 896
 	public function countAllDates($filters = array())
897 897
 	{
898 898
 		global $globalTimezone, $globalDBdriver;
@@ -938,11 +938,11 @@  discard block
 block discarded – undo
938 938
 	
939 939
 	
940 940
 	/**
941
-	* Counts all dates during the last 7 days
942
-	*
943
-	* @return Array the date list
944
-	*
945
-	*/
941
+	 * Counts all dates during the last 7 days
942
+	 *
943
+	 * @return Array the date list
944
+	 *
945
+	 */
946 946
 	public function countAllDatesLast7Days($filters = array())
947 947
 	{
948 948
 		global $globalTimezone, $globalDBdriver;
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 			$query .= " GROUP BY date_name 
965 965
 								ORDER BY date_name ASC";
966 966
 			$query_data = array(':offset' => $offset);
967
-    		}
967
+			}
968 968
 		
969 969
 		$sth = $this->db->prepare($query);
970 970
 		$sth->execute($query_data);
@@ -984,11 +984,11 @@  discard block
 block discarded – undo
984 984
 	}
985 985
 
986 986
 	/**
987
-	* Counts all dates during the last month
988
-	*
989
-	* @return Array the date list
990
-	*
991
-	*/
987
+	 * Counts all dates during the last month
988
+	 *
989
+	 * @return Array the date list
990
+	 *
991
+	 */
992 992
 	public function countAllDatesLastMonth($filters = array())
993 993
 	{
994 994
 		global $globalTimezone, $globalDBdriver;
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 			$query .= " GROUP BY date_name 
1011 1011
 								ORDER BY date_name ASC";
1012 1012
 			$query_data = array(':offset' => $offset);
1013
-    		}
1013
+			}
1014 1014
 		
1015 1015
 		$sth = $this->db->prepare($query);
1016 1016
 		$sth->execute($query_data);
@@ -1032,11 +1032,11 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
 
1034 1034
 	/**
1035
-	* Counts all month
1036
-	*
1037
-	* @return Array the month list
1038
-	*
1039
-	*/
1035
+	 * Counts all month
1036
+	 *
1037
+	 * @return Array the month list
1038
+	 *
1039
+	 */
1040 1040
 	public function countAllMonths($filters = array())
1041 1041
 	{
1042 1042
 		global $globalTimezone, $globalDBdriver;
@@ -1081,11 +1081,11 @@  discard block
 block discarded – undo
1081 1081
 	
1082 1082
 
1083 1083
 	/**
1084
-	* Counts all dates during the last year
1085
-	*
1086
-	* @return Array the date list
1087
-	*
1088
-	*/
1084
+	 * Counts all dates during the last year
1085
+	 *
1086
+	 * @return Array the date list
1087
+	 *
1088
+	 */
1089 1089
 	public function countAllMonthsLastYear($filters)
1090 1090
 	{
1091 1091
 		global $globalTimezone, $globalDBdriver;
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 			$query .= " GROUP BY year_name, month_name
1108 1108
 								ORDER BY year_name, month_name ASC";
1109 1109
 			$query_data = array(':offset' => $offset);
1110
-    		}
1110
+			}
1111 1111
 		
1112 1112
 		$sth = $this->db->prepare($query);
1113 1113
 		$sth->execute($query_data);
@@ -1130,11 +1130,11 @@  discard block
 block discarded – undo
1130 1130
 	
1131 1131
 	
1132 1132
 	/**
1133
-	* Counts all hours
1134
-	*
1135
-	* @return Array the hour list
1136
-	*
1137
-	*/
1133
+	 * Counts all hours
1134
+	 *
1135
+	 * @return Array the hour list
1136
+	 *
1137
+	 */
1138 1138
 	public function countAllHours($orderby,$filters = array())
1139 1139
 	{
1140 1140
 		global $globalTimezone, $globalDBdriver;
@@ -1197,11 +1197,11 @@  discard block
 block discarded – undo
1197 1197
 	
1198 1198
 	
1199 1199
 	/**
1200
-	* Counts all hours by date
1201
-	*
1202
-	* @return Array the hour list
1203
-	*
1204
-	*/
1200
+	 * Counts all hours by date
1201
+	 *
1202
+	 * @return Array the hour list
1203
+	 *
1204
+	 */
1205 1205
 	public function countAllHoursByDate($date, $filters = array())
1206 1206
 	{
1207 1207
 		global $globalTimezone, $globalDBdriver;
@@ -1245,11 +1245,11 @@  discard block
 block discarded – undo
1245 1245
 	
1246 1246
 	
1247 1247
 	/**
1248
-	* Counts all hours by a ident/callsign
1249
-	*
1250
-	* @return Array the hour list
1251
-	*
1252
-	*/
1248
+	 * Counts all hours by a ident/callsign
1249
+	 *
1250
+	 * @return Array the hour list
1251
+	 *
1252
+	 */
1253 1253
 	public function countAllHoursByIdent($ident, $filters = array())
1254 1254
 	{
1255 1255
 		global $globalTimezone, $globalDBdriver;
@@ -1294,11 +1294,11 @@  discard block
 block discarded – undo
1294 1294
 	
1295 1295
 	
1296 1296
 	/**
1297
-	* Counts all flights that have flown over
1298
-	*
1299
-	* @return Integer the number of flights
1300
-	*
1301
-	*/
1297
+	 * Counts all flights that have flown over
1298
+	 *
1299
+	 * @return Integer the number of flights
1300
+	 *
1301
+	 */
1302 1302
 	public function countOverallTracked($filters = array(),$year = '',$month = '')
1303 1303
 	{
1304 1304
 		global $globalDBdriver;
@@ -1333,11 +1333,11 @@  discard block
 block discarded – undo
1333 1333
 	
1334 1334
   
1335 1335
 	/**
1336
-	* Counts all hours of today
1337
-	*
1338
-	* @return Array the hour list
1339
-	*
1340
-	*/
1336
+	 * Counts all hours of today
1337
+	 *
1338
+	 * @return Array the hour list
1339
+	 *
1340
+	 */
1341 1341
 	public function countAllHoursFromToday($filters = array())
1342 1342
 	{
1343 1343
 		global $globalTimezone, $globalDBdriver;
@@ -1377,12 +1377,12 @@  discard block
 block discarded – undo
1377 1377
 	}
1378 1378
     
1379 1379
     
1380
-     /**
1381
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1382
-	*
1383
-	* @return Integer the Barrie Spotter ID
1380
+	 /**
1381
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1382
+	  *
1383
+	  * @return Integer the Barrie Spotter ID
1384 1384
 q	*
1385
-	*/
1385
+	  */
1386 1386
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1387 1387
 	{
1388 1388
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1403,13 +1403,13 @@  discard block
 block discarded – undo
1403 1403
   
1404 1404
  
1405 1405
 	/**
1406
-	* Parses a date string
1407
-	*
1408
-	* @param String $dateString the date string
1409
-	* @param String $timezone the timezone of a user
1410
-	* @return Array the time information
1411
-	*
1412
-	*/
1406
+	 * Parses a date string
1407
+	 *
1408
+	 * @param String $dateString the date string
1409
+	 * @param String $timezone the timezone of a user
1410
+	 * @return Array the time information
1411
+	 *
1412
+	 */
1413 1413
 	public function parseDateString($dateString, $timezone = '')
1414 1414
 	{
1415 1415
 		$time_array = array();
@@ -1442,12 +1442,12 @@  discard block
 block discarded – undo
1442 1442
 	}
1443 1443
 	
1444 1444
 	/**
1445
-	* Parses the direction degrees to working
1446
-	*
1447
-	* @param Float $direction the direction in degrees
1448
-	* @return Array the direction information
1449
-	*
1450
-	*/
1445
+	 * Parses the direction degrees to working
1446
+	 *
1447
+	 * @param Float $direction the direction in degrees
1448
+	 * @return Array the direction information
1449
+	 *
1450
+	 */
1451 1451
 	public function parseDirection($direction = 0)
1452 1452
 	{
1453 1453
 		if ($direction == '') $direction = 0;
@@ -1526,12 +1526,12 @@  discard block
 block discarded – undo
1526 1526
 	
1527 1527
 	
1528 1528
 	/**
1529
-	* Gets Country from latitude/longitude
1530
-	*
1531
-	* @param Float $latitude latitute of the flight
1532
-	* @param Float $longitude longitute of the flight
1533
-	* @return String the countrie
1534
-	*/
1529
+	 * Gets Country from latitude/longitude
1530
+	 *
1531
+	 * @param Float $latitude latitute of the flight
1532
+	 * @param Float $longitude longitute of the flight
1533
+	 * @return String the countrie
1534
+	 */
1535 1535
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1536 1536
 	{
1537 1537
 		global $globalDBdriver, $globalDebug;
@@ -1568,11 +1568,11 @@  discard block
 block discarded – undo
1568 1568
 	}
1569 1569
 
1570 1570
 	/**
1571
-	* Gets Country from iso2
1572
-	*
1573
-	* @param String $iso2 ISO2 country code
1574
-	* @return String the countrie
1575
-	*/
1571
+	 * Gets Country from iso2
1572
+	 *
1573
+	 * @param String $iso2 ISO2 country code
1574
+	 * @return String the countrie
1575
+	 */
1576 1576
 	public function getCountryFromISO2($iso2)
1577 1577
 	{
1578 1578
 		global $globalDBdriver, $globalDebug;
@@ -1601,12 +1601,12 @@  discard block
 block discarded – undo
1601 1601
 
1602 1602
 	
1603 1603
 	/**
1604
-	* Gets the short url from bit.ly
1605
-	*
1606
-	* @param String $url the full url
1607
-	* @return String the bit.ly url
1608
-	*
1609
-	*/
1604
+	 * Gets the short url from bit.ly
1605
+	 *
1606
+	 * @param String $url the full url
1607
+	 * @return String the bit.ly url
1608
+	 *
1609
+	 */
1610 1610
 	public function getBitlyURL($url)
1611 1611
 	{
1612 1612
 		global $globalBitlyAccessToken;
Please login to merge, or discard this patch.
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT marine_output.* FROM marine_output";
6 6
 
7
-class Marine{
7
+class Marine {
8 8
 	public $db;
9 9
 	
10 10
 	public function __construct($dbc = null) {
@@ -18,33 +18,33 @@  discard block
 block discarded – undo
18 18
 	* @return Array the SQL part
19 19
 	*/
20 20
 	
21
-	public function getFilter($filter = array(),$where = false,$and = false) {
21
+	public function getFilter($filter = array(), $where = false, $and = false) {
22 22
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
23 23
 		$filters = array();
24 24
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
25 25
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
26 26
 				$filters = $globalStatsFilters[$globalFilterName];
27 27
 			} else {
28
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
28
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
29 29
 			}
30 30
 		}
31 31
 		if (isset($filter[0]['source'])) {
32
-			$filters = array_merge($filters,$filter);
32
+			$filters = array_merge($filters, $filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
35 35
 		$filter_query_join = '';
36 36
 		$filter_query_where = '';
37
-		foreach($filters as $flt) {
37
+		foreach ($filters as $flt) {
38 38
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
39 39
 				if (isset($flt['source'])) {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
41 41
 				} else {
42
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
42
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
43 43
 				}
44 44
 			}
45 45
 		}
46 46
 		if (isset($filter['source']) && !empty($filter['source'])) {
47
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
47
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
48 48
 		}
49 49
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
50 50
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74 74
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75 75
 		if ($filter_query_where != '') {
76
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
76
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
77 77
 		}
78 78
 		$filter_query = $filter_query_join.$filter_query_where;
79 79
 		return $filter_query;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	* @return Array the spotter information
89 89
 	*
90 90
 	*/
91
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
91
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
92 92
 	{
93 93
 		date_default_timezone_set('UTC');
94 94
 		if (!is_string($query))
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 			$sth = $this->db->prepare($query.$limitQuery);
109 109
 			$sth->execute($params);
110 110
 		} catch (PDOException $e) {
111
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
111
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
112 112
 			exit();
113 113
 		}
114 114
 		
115 115
 		$num_rows = 0;
116 116
 		$spotter_array = array();
117
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
117
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
118 118
 		{
119 119
 			$num_rows++;
120 120
 			$temp_array = array();
@@ -169,17 +169,17 @@  discard block
 block discarded – undo
169 169
 				{
170 170
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
171 171
 				} else {
172
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
172
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
173 173
 				}
174 174
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
175
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
176
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
175
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
176
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
177 177
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
178 178
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
179 179
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
180 180
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
181
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
182
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
181
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
182
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
183 183
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
184 184
 					}
185 185
 				}
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
 		{
217 217
 			$limit_array = explode(",", $limit);
218 218
 			
219
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
220
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
219
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
220
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
221 221
 			
222 222
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
223 223
 			{
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 			$orderby_query = " ORDER BY marine_output.date DESC";
235 235
 		}
236 236
 
237
-		$query  = $global_query.$filter_query." ".$orderby_query;
237
+		$query = $global_query.$filter_query." ".$orderby_query;
238 238
 
239
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
239
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
240 240
 
241 241
 		return $spotter_array;
242 242
 	}
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 		if ($id == '') return array();
256 256
 		$additional_query = "marine_output.fammarine_id = :id";
257 257
 		$query_values = array(':id' => $id);
258
-		$query  = $global_query." WHERE ".$additional_query." ";
259
-		$spotter_array = $this->getDataFromDB($query,$query_values);
258
+		$query = $global_query." WHERE ".$additional_query." ";
259
+		$spotter_array = $this->getDataFromDB($query, $query_values);
260 260
 		return $spotter_array;
261 261
 	}
262 262
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 		$query_values = array();
276 276
 		$limit_query = '';
277 277
 		$additional_query = '';
278
-		$filter_query = $this->getFilter($filter,true,true);
278
+		$filter_query = $this->getFilter($filter, true, true);
279 279
 		if ($ident != "")
280 280
 		{
281 281
 			if (!is_string($ident))
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 		{
292 292
 			$limit_array = explode(",", $limit);
293 293
 			
294
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
295
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
294
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
295
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
296 296
 			
297 297
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
298 298
 			{
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 		return $spotter_array;
317 317
 	}
318 318
 	
319
-	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
319
+	public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array())
320 320
 	{
321 321
 		global $global_query, $globalTimezone, $globalDBdriver;
322 322
 		
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		$limit_query = '';
325 325
 		$additional_query = '';
326 326
 
327
-		$filter_query = $this->getFilter($filter,true,true);
327
+		$filter_query = $this->getFilter($filter, true, true);
328 328
 		
329 329
 		if ($date != "")
330 330
 		{
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
 		{
351 351
 			$limit_array = explode(",", $limit);
352 352
 			
353
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
354
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
353
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
354
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
355 355
 			
356 356
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
357 357
 			{
@@ -382,11 +382,11 @@  discard block
 block discarded – undo
382 382
 	* @return Array list of source name
383 383
 	*
384 384
 	*/
385
-	public function getAllSourceName($type = '',$filters = array())
385
+	public function getAllSourceName($type = '', $filters = array())
386 386
 	{
387
-		$filter_query = $this->getFilter($filters,true,true);
387
+		$filter_query = $this->getFilter($filters, true, true);
388 388
 		$query_values = array();
389
-		$query  = "SELECT DISTINCT marine_output.source_name 
389
+		$query = "SELECT DISTINCT marine_output.source_name 
390 390
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
391 391
 		if ($type != '') {
392 392
 			$query_values = array(':type' => $type);
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 		$source_array = array();
402 402
 		$temp_array = array();
403 403
 		
404
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
404
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
405 405
 		{
406 406
 			$temp_array['source_name'] = $row['source_name'];
407 407
 			$source_array[] = $temp_array;
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	*/
419 419
 	public function getAllIdents($filters = array())
420 420
 	{
421
-		$filter_query = $this->getFilter($filters,true,true);
422
-		$query  = "SELECT DISTINCT marine_output.ident
421
+		$filter_query = $this->getFilter($filters, true, true);
422
+		$query = "SELECT DISTINCT marine_output.ident
423 423
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
424 424
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
425 425
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		$ident_array = array();
430 430
 		$temp_array = array();
431 431
 		
432
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
432
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
433 433
 		{
434 434
 			$temp_array['ident'] = $row['ident'];
435 435
 			$ident_array[] = $temp_array;
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 	*/
447 447
 	public function getIdentity($mmsi)
448 448
 	{
449
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
449
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
450 450
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
451 451
 		$sth = $this->db->prepare($query);
452 452
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -471,12 +471,12 @@  discard block
 block discarded – undo
471 471
 		} else $offset = '+00:00';
472 472
 
473 473
 		if ($globalDBdriver == 'mysql') {
474
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
474
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
475 475
 								FROM marine_output
476 476
 								WHERE marine_output.date <> '' 
477 477
 								ORDER BY marine_output.date ASC LIMIT 0,200";
478 478
 		} else {
479
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
479
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
480 480
 								FROM marine_output
481 481
 								WHERE marine_output.date <> '' 
482 482
 								ORDER BY marine_output.date ASC LIMIT 0,200";
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 		$date_array = array();
489 489
 		$temp_array = array();
490 490
 		
491
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
491
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
492 492
 		{
493 493
 			$temp_array['date'] = $row['date'];
494 494
 
@@ -507,11 +507,11 @@  discard block
 block discarded – undo
507 507
 	* @return String success or false
508 508
 	*
509 509
 	*/	
510
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
510
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
511 511
 	{
512 512
 
513 513
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
514
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
514
+                $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
515 515
 
516 516
 		try {
517 517
 			$sth = $this->db->prepare($query);
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
535 535
 	{
536 536
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
537
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
537
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
538 538
 
539 539
 		try {
540 540
 			$sth = $this->db->prepare($query);
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 	* @param String $verticalrate vertival rate of flight
573 573
 	* @return String success or false
574 574
 	*/
575
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '')
575
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $format_source = '', $source_name = '')
576 576
 	{
577 577
 		global $globalURL;
578 578
 		
@@ -639,25 +639,25 @@  discard block
 block discarded – undo
639 639
 		}
640 640
 
641 641
     
642
-		if ($date == "" || strtotime($date) < time()-20*60)
642
+		if ($date == "" || strtotime($date) < time() - 20*60)
643 643
 		{
644 644
 			$date = date("Y-m-d H:i:s", time());
645 645
 		}
646 646
 
647
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
648
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
649
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
650
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
651
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
652
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
653
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
654
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
655
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
656
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
657
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
658
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
659
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
660
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
647
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
648
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
649
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
650
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
651
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
652
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
653
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
654
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
655
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
656
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
657
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
658
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
659
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
660
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
661 661
 	
662 662
                 if ($latitude == '' && $longitude == '') {
663 663
             		$latitude = 0;
@@ -666,10 +666,10 @@  discard block
 block discarded – undo
666 666
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
667 667
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
668 668
                 if ($arrival_date == '') $arrival_date = NULL;
669
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
669
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
670 670
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
671 671
 
672
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
672
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
673 673
 		try {
674 674
 		        
675 675
 			$sth = $this->db->prepare($query);
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
 	{
695 695
 		global $globalDBdriver, $globalTimezone;
696 696
 		if ($globalDBdriver == 'mysql') {
697
-			$query  = "SELECT marine_output.ident FROM marine_output 
697
+			$query = "SELECT marine_output.ident FROM marine_output 
698 698
 								WHERE marine_output.ident = :ident 
699 699
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
700 700
 								AND marine_output.date < UTC_TIMESTAMP()";
701 701
 			$query_data = array(':ident' => $ident);
702 702
 		} else {
703
-			$query  = "SELECT marine_output.ident FROM marine_output 
703
+			$query = "SELECT marine_output.ident FROM marine_output 
704 704
 								WHERE marine_output.ident = :ident 
705 705
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
706 706
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -709,8 +709,8 @@  discard block
 block discarded – undo
709 709
 		
710 710
 		$sth = $this->db->prepare($query);
711 711
 		$sth->execute($query_data);
712
-    		$ident_result='';
713
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
712
+    		$ident_result = '';
713
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
714 714
 		{
715 715
 			$ident_result = $row['ident'];
716 716
 		}
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
 				return false;
737 737
 			} else {
738 738
 				$q_array = explode(" ", $q);
739
-				foreach ($q_array as $q_item){
740
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
739
+				foreach ($q_array as $q_item) {
740
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
741 741
 					$additional_query .= " AND (";
742 742
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
743 743
 					$additional_query .= ")";
@@ -745,11 +745,11 @@  discard block
 block discarded – undo
745 745
 			}
746 746
 		}
747 747
 		if ($globalDBdriver == 'mysql') {
748
-			$query  = "SELECT marine_output.* FROM marine_output 
748
+			$query = "SELECT marine_output.* FROM marine_output 
749 749
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
750 750
 				AND marine_output.date < UTC_TIMESTAMP()";
751 751
 		} else {
752
-			$query  = "SELECT marine_output.* FROM marine_output 
752
+			$query = "SELECT marine_output.* FROM marine_output 
753 753
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
754 754
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
755 755
 		}
@@ -822,11 +822,11 @@  discard block
 block discarded – undo
822 822
 	* @return Array the callsign list
823 823
 	*
824 824
 	*/
825
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
825
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
826 826
 	{
827 827
 		global $globalDBdriver;
828
-		$filter_query = $this->getFilter($filters,true,true);
829
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
828
+		$filter_query = $this->getFilter($filters, true, true);
829
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
830 830
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
831 831
 		 if ($olderthanmonths > 0) {
832 832
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -840,28 +840,28 @@  discard block
 block discarded – undo
840 840
 		if ($year != '') {
841 841
 			if ($globalDBdriver == 'mysql') {
842 842
 				$query .= " AND YEAR(marine_output.date) = :year";
843
-				$query_values = array_merge($query_values,array(':year' => $year));
843
+				$query_values = array_merge($query_values, array(':year' => $year));
844 844
 			} else {
845 845
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
846
-				$query_values = array_merge($query_values,array(':year' => $year));
846
+				$query_values = array_merge($query_values, array(':year' => $year));
847 847
 			}
848 848
 		}
849 849
 		if ($month != '') {
850 850
 			if ($globalDBdriver == 'mysql') {
851 851
 				$query .= " AND MONTH(marine_output.date) = :month";
852
-				$query_values = array_merge($query_values,array(':month' => $month));
852
+				$query_values = array_merge($query_values, array(':month' => $month));
853 853
 			} else {
854 854
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
855
-				$query_values = array_merge($query_values,array(':month' => $month));
855
+				$query_values = array_merge($query_values, array(':month' => $month));
856 856
 			}
857 857
 		}
858 858
 		if ($day != '') {
859 859
 			if ($globalDBdriver == 'mysql') {
860 860
 				$query .= " AND DAY(marine_output.date) = :day";
861
-				$query_values = array_merge($query_values,array(':day' => $day));
861
+				$query_values = array_merge($query_values, array(':day' => $day));
862 862
 			} else {
863 863
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
864
-				$query_values = array_merge($query_values,array(':day' => $day));
864
+				$query_values = array_merge($query_values, array(':day' => $day));
865 865
 			}
866 866
 		}
867 867
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 		$callsign_array = array();
874 874
 		$temp_array = array();
875 875
         
876
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
876
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
877 877
 		{
878 878
 			$temp_array['callsign_icao'] = $row['ident'];
879 879
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 		$date_array = array();
926 926
 		$temp_array = array();
927 927
         
928
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
928
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
929 929
 		{
930 930
 			$temp_array['date_name'] = $row['date_name'];
931 931
 			$temp_array['date_count'] = $row['date_count'];
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 			$datetime = new DateTime();
952 952
 			$offset = $datetime->format('P');
953 953
 		} else $offset = '+00:00';
954
-		$filter_query = $this->getFilter($filters,true,true);
954
+		$filter_query = $this->getFilter($filters, true, true);
955 955
 		if ($globalDBdriver == 'mysql') {
956 956
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
957 957
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 		$date_array = array();
973 973
 		$temp_array = array();
974 974
         
975
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
975
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
976 976
 		{
977 977
 			$temp_array['date_name'] = $row['date_name'];
978 978
 			$temp_array['date_count'] = $row['date_count'];
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 			$datetime = new DateTime();
998 998
 			$offset = $datetime->format('P');
999 999
 		} else $offset = '+00:00';
1000
-		$filter_query = $this->getFilter($filters,true,true);
1000
+		$filter_query = $this->getFilter($filters, true, true);
1001 1001
 		if ($globalDBdriver == 'mysql') {
1002 1002
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1003 1003
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
 		$date_array = array();
1019 1019
 		$temp_array = array();
1020 1020
         
1021
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1021
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1022 1022
 		{
1023 1023
 			$temp_array['date_name'] = $row['date_name'];
1024 1024
 			$temp_array['date_count'] = $row['date_count'];
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 		$date_array = array();
1066 1066
 		$temp_array = array();
1067 1067
         
1068
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1068
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1069 1069
 		{
1070 1070
 			$temp_array['month_name'] = $row['month_name'];
1071 1071
 			$temp_array['year_name'] = $row['year_name'];
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 			$datetime = new DateTime();
1095 1095
 			$offset = $datetime->format('P');
1096 1096
 		} else $offset = '+00:00';
1097
-		$filter_query = $this->getFilter($filters,true,true);
1097
+		$filter_query = $this->getFilter($filters, true, true);
1098 1098
 		if ($globalDBdriver == 'mysql') {
1099 1099
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1100 1100
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 		$date_array = array();
1116 1116
 		$temp_array = array();
1117 1117
         
1118
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1118
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1119 1119
 		{
1120 1120
 			$temp_array['year_name'] = $row['year_name'];
1121 1121
 			$temp_array['month_name'] = $row['month_name'];
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
 	* @return Array the hour list
1136 1136
 	*
1137 1137
 	*/
1138
-	public function countAllHours($orderby,$filters = array())
1138
+	public function countAllHours($orderby, $filters = array())
1139 1139
 	{
1140 1140
 		global $globalTimezone, $globalDBdriver;
1141 1141
 		if ($globalTimezone != '') {
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 		$hour_array = array();
1184 1184
 		$temp_array = array();
1185 1185
         
1186
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1186
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1187 1187
 		{
1188 1188
 			$temp_array['hour_name'] = $row['hour_name'];
1189 1189
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1205,8 +1205,8 @@  discard block
 block discarded – undo
1205 1205
 	public function countAllHoursByDate($date, $filters = array())
1206 1206
 	{
1207 1207
 		global $globalTimezone, $globalDBdriver;
1208
-		$filter_query = $this->getFilter($filters,true,true);
1209
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1208
+		$filter_query = $this->getFilter($filters, true, true);
1209
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1210 1210
 		if ($globalTimezone != '') {
1211 1211
 			date_default_timezone_set($globalTimezone);
1212 1212
 			$datetime = new DateTime($date);
@@ -1214,12 +1214,12 @@  discard block
 block discarded – undo
1214 1214
 		} else $offset = '+00:00';
1215 1215
 
1216 1216
 		if ($globalDBdriver == 'mysql') {
1217
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1217
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1218 1218
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1219 1219
 								GROUP BY hour_name 
1220 1220
 								ORDER BY hour_name ASC";
1221 1221
 		} else {
1222
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1222
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1223 1223
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1224 1224
 								GROUP BY hour_name 
1225 1225
 								ORDER BY hour_name ASC";
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 		$hour_array = array();
1232 1232
 		$temp_array = array();
1233 1233
         
1234
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1234
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1235 1235
 		{
1236 1236
 			$temp_array['hour_name'] = $row['hour_name'];
1237 1237
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1253,8 +1253,8 @@  discard block
 block discarded – undo
1253 1253
 	public function countAllHoursByIdent($ident, $filters = array())
1254 1254
 	{
1255 1255
 		global $globalTimezone, $globalDBdriver;
1256
-		$filter_query = $this->getFilter($filters,true,true);
1257
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1256
+		$filter_query = $this->getFilter($filters, true, true);
1257
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1258 1258
 		if ($globalTimezone != '') {
1259 1259
 			date_default_timezone_set($globalTimezone);
1260 1260
 			$datetime = new DateTime();
@@ -1262,12 +1262,12 @@  discard block
 block discarded – undo
1262 1262
 		} else $offset = '+00:00';
1263 1263
 
1264 1264
 		if ($globalDBdriver == 'mysql') {
1265
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1265
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1266 1266
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1267 1267
 								GROUP BY hour_name 
1268 1268
 								ORDER BY hour_name ASC";
1269 1269
 		} else {
1270
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1270
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1271 1271
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1272 1272
 								GROUP BY hour_name 
1273 1273
 								ORDER BY hour_name ASC";
@@ -1275,12 +1275,12 @@  discard block
 block discarded – undo
1275 1275
       
1276 1276
 		
1277 1277
 		$sth = $this->db->prepare($query);
1278
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1278
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1279 1279
       
1280 1280
 		$hour_array = array();
1281 1281
 		$temp_array = array();
1282 1282
         
1283
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1283
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1284 1284
 		{
1285 1285
 			$temp_array['hour_name'] = $row['hour_name'];
1286 1286
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1299,32 +1299,32 @@  discard block
 block discarded – undo
1299 1299
 	* @return Integer the number of flights
1300 1300
 	*
1301 1301
 	*/
1302
-	public function countOverallTracked($filters = array(),$year = '',$month = '')
1302
+	public function countOverallTracked($filters = array(), $year = '', $month = '')
1303 1303
 	{
1304 1304
 		global $globalDBdriver;
1305
-		$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1305
+		$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1306 1306
 		$query_values = array();
1307 1307
 		$query = '';
1308 1308
 		if ($year != '') {
1309 1309
 			if ($globalDBdriver == 'mysql') {
1310 1310
 				$query .= " AND YEAR(marine_output.date) = :year";
1311
-				$query_values = array_merge($query_values,array(':year' => $year));
1311
+				$query_values = array_merge($query_values, array(':year' => $year));
1312 1312
 			} else {
1313 1313
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1314
-				$query_values = array_merge($query_values,array(':year' => $year));
1314
+				$query_values = array_merge($query_values, array(':year' => $year));
1315 1315
 			}
1316 1316
 		}
1317 1317
 		if ($month != '') {
1318 1318
 			if ($globalDBdriver == 'mysql') {
1319 1319
 				$query .= " AND MONTH(marine_output.date) = :month";
1320
-				$query_values = array_merge($query_values,array(':month' => $month));
1320
+				$query_values = array_merge($query_values, array(':month' => $month));
1321 1321
 			} else {
1322 1322
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1323
-				$query_values = array_merge($query_values,array(':month' => $month));
1323
+				$query_values = array_merge($query_values, array(':month' => $month));
1324 1324
 			}
1325 1325
 		}
1326 1326
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1327
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1327
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1328 1328
 		
1329 1329
 		$sth = $this->db->prepare($queryi);
1330 1330
 		$sth->execute($query_values);
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
 	public function countAllHoursFromToday($filters = array())
1342 1342
 	{
1343 1343
 		global $globalTimezone, $globalDBdriver;
1344
-		$filter_query = $this->getFilter($filters,true,true);
1344
+		$filter_query = $this->getFilter($filters, true, true);
1345 1345
 		if ($globalTimezone != '') {
1346 1346
 			date_default_timezone_set($globalTimezone);
1347 1347
 			$datetime = new DateTime();
@@ -1349,12 +1349,12 @@  discard block
 block discarded – undo
1349 1349
 		} else $offset = '+00:00';
1350 1350
 
1351 1351
 		if ($globalDBdriver == 'mysql') {
1352
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1352
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1353 1353
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1354 1354
 								GROUP BY hour_name 
1355 1355
 								ORDER BY hour_name ASC";
1356 1356
 		} else {
1357
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1357
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1358 1358
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1359 1359
 								GROUP BY hour_name 
1360 1360
 								ORDER BY hour_name ASC";
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 		$hour_array = array();
1367 1367
 		$temp_array = array();
1368 1368
         
1369
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1369
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1370 1370
 		{
1371 1371
 			$temp_array['hour_name'] = $row['hour_name'];
1372 1372
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1385,9 +1385,9 @@  discard block
 block discarded – undo
1385 1385
 	*/
1386 1386
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1387 1387
 	{
1388
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1388
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1389 1389
 
1390
-		$query  = "SELECT marine_output.marine_id
1390
+		$query = "SELECT marine_output.marine_id
1391 1391
 				FROM marine_output 
1392 1392
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1393 1393
         
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
 		$sth = $this->db->prepare($query);
1396 1396
 		$sth->execute();
1397 1397
 
1398
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1398
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1399 1399
 		{
1400 1400
 			return $row['marine_id'];
1401 1401
 		}
@@ -1420,23 +1420,23 @@  discard block
 block discarded – undo
1420 1420
 		}
1421 1421
 		
1422 1422
 		$current_date = date("Y-m-d H:i:s");
1423
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1423
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1424 1424
 		
1425 1425
 		$diff = abs(strtotime($current_date) - strtotime($date));
1426 1426
 
1427
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1427
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1428 1428
 		$years = $time_array['years'];
1429 1429
 		
1430
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1430
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1431 1431
 		$months = $time_array['months'];
1432 1432
 		
1433
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1433
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1434 1434
 		$days = $time_array['days'];
1435
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1435
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1436 1436
 		$hours = $time_array['hours'];
1437
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1437
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1438 1438
 		$minutes = $time_array['minutes'];
1439
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1439
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1440 1440
 		
1441 1441
 		return $time_array;
1442 1442
 	}
@@ -1459,63 +1459,63 @@  discard block
 block discarded – undo
1459 1459
 			$temp_array['direction_degree'] = $direction;
1460 1460
 			$temp_array['direction_shortname'] = "N";
1461 1461
 			$temp_array['direction_fullname'] = "North";
1462
-		} elseif ($direction >= 22.5 && $direction < 45){
1462
+		} elseif ($direction >= 22.5 && $direction < 45) {
1463 1463
 			$temp_array['direction_degree'] = $direction;
1464 1464
 			$temp_array['direction_shortname'] = "NNE";
1465 1465
 			$temp_array['direction_fullname'] = "North-Northeast";
1466
-		} elseif ($direction >= 45 && $direction < 67.5){
1466
+		} elseif ($direction >= 45 && $direction < 67.5) {
1467 1467
 			$temp_array['direction_degree'] = $direction;
1468 1468
 			$temp_array['direction_shortname'] = "NE";
1469 1469
 			$temp_array['direction_fullname'] = "Northeast";
1470
-		} elseif ($direction >= 67.5 && $direction < 90){
1470
+		} elseif ($direction >= 67.5 && $direction < 90) {
1471 1471
 			$temp_array['direction_degree'] = $direction;
1472 1472
 			$temp_array['direction_shortname'] = "ENE";
1473 1473
 			$temp_array['direction_fullname'] = "East-Northeast";
1474
-		} elseif ($direction >= 90 && $direction < 112.5){
1474
+		} elseif ($direction >= 90 && $direction < 112.5) {
1475 1475
 			$temp_array['direction_degree'] = $direction;
1476 1476
 			$temp_array['direction_shortname'] = "E";
1477 1477
 			$temp_array['direction_fullname'] = "East";
1478
-		} elseif ($direction >= 112.5 && $direction < 135){
1478
+		} elseif ($direction >= 112.5 && $direction < 135) {
1479 1479
 			$temp_array['direction_degree'] = $direction;
1480 1480
 			$temp_array['direction_shortname'] = "ESE";
1481 1481
 			$temp_array['direction_fullname'] = "East-Southeast";
1482
-		} elseif ($direction >= 135 && $direction < 157.5){
1482
+		} elseif ($direction >= 135 && $direction < 157.5) {
1483 1483
 			$temp_array['direction_degree'] = $direction;
1484 1484
 			$temp_array['direction_shortname'] = "SE";
1485 1485
 			$temp_array['direction_fullname'] = "Southeast";
1486
-		} elseif ($direction >= 157.5 && $direction < 180){
1486
+		} elseif ($direction >= 157.5 && $direction < 180) {
1487 1487
 			$temp_array['direction_degree'] = $direction;
1488 1488
 			$temp_array['direction_shortname'] = "SSE";
1489 1489
 			$temp_array['direction_fullname'] = "South-Southeast";
1490
-		} elseif ($direction >= 180 && $direction < 202.5){
1490
+		} elseif ($direction >= 180 && $direction < 202.5) {
1491 1491
 			$temp_array['direction_degree'] = $direction;
1492 1492
 			$temp_array['direction_shortname'] = "S";
1493 1493
 			$temp_array['direction_fullname'] = "South";
1494
-		} elseif ($direction >= 202.5 && $direction < 225){
1494
+		} elseif ($direction >= 202.5 && $direction < 225) {
1495 1495
 			$temp_array['direction_degree'] = $direction;
1496 1496
 			$temp_array['direction_shortname'] = "SSW";
1497 1497
 			$temp_array['direction_fullname'] = "South-Southwest";
1498
-		} elseif ($direction >= 225 && $direction < 247.5){
1498
+		} elseif ($direction >= 225 && $direction < 247.5) {
1499 1499
 			$temp_array['direction_degree'] = $direction;
1500 1500
 			$temp_array['direction_shortname'] = "SW";
1501 1501
 			$temp_array['direction_fullname'] = "Southwest";
1502
-		} elseif ($direction >= 247.5 && $direction < 270){
1502
+		} elseif ($direction >= 247.5 && $direction < 270) {
1503 1503
 			$temp_array['direction_degree'] = $direction;
1504 1504
 			$temp_array['direction_shortname'] = "WSW";
1505 1505
 			$temp_array['direction_fullname'] = "West-Southwest";
1506
-		} elseif ($direction >= 270 && $direction < 292.5){
1506
+		} elseif ($direction >= 270 && $direction < 292.5) {
1507 1507
 			$temp_array['direction_degree'] = $direction;
1508 1508
 			$temp_array['direction_shortname'] = "W";
1509 1509
 			$temp_array['direction_fullname'] = "West";
1510
-		} elseif ($direction >= 292.5 && $direction < 315){
1510
+		} elseif ($direction >= 292.5 && $direction < 315) {
1511 1511
 			$temp_array['direction_degree'] = $direction;
1512 1512
 			$temp_array['direction_shortname'] = "WNW";
1513 1513
 			$temp_array['direction_fullname'] = "West-Northwest";
1514
-		} elseif ($direction >= 315 && $direction < 337.5){
1514
+		} elseif ($direction >= 315 && $direction < 337.5) {
1515 1515
 			$temp_array['direction_degree'] = $direction;
1516 1516
 			$temp_array['direction_shortname'] = "NW";
1517 1517
 			$temp_array['direction_fullname'] = "Northwest";
1518
-		} elseif ($direction >= 337.5 && $direction < 360){
1518
+		} elseif ($direction >= 337.5 && $direction < 360) {
1519 1519
 			$temp_array['direction_degree'] = $direction;
1520 1520
 			$temp_array['direction_shortname'] = "NNW";
1521 1521
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1532,11 +1532,11 @@  discard block
 block discarded – undo
1532 1532
 	* @param Float $longitude longitute of the flight
1533 1533
 	* @return String the countrie
1534 1534
 	*/
1535
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1535
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1536 1536
 	{
1537 1537
 		global $globalDBdriver, $globalDebug;
1538
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1539
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1538
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1539
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1540 1540
 	
1541 1541
 		$Connection = new Connection($this->db);
1542 1542
 		if (!$Connection->tableExists('countries')) return '';
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
 	public function getCountryFromISO2($iso2)
1577 1577
 	{
1578 1578
 		global $globalDBdriver, $globalDebug;
1579
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1579
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1580 1580
 	
1581 1581
 		$Connection = new Connection($this->db);
1582 1582
 		if (!$Connection->tableExists('countries')) return '';
@@ -1624,7 +1624,7 @@  discard block
 block discarded – undo
1624 1624
 		
1625 1625
 		$bitly_data = json_decode($bitly_data);
1626 1626
 		$bitly_url = '';
1627
-		if ($bitly_data->status_txt = "OK"){
1627
+		if ($bitly_data->status_txt = "OK") {
1628 1628
 			$bitly_url = $bitly_data->data->url;
1629 1629
 		}
1630 1630
 
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 
1635 1635
 	public function getOrderBy()
1636 1636
 	{
1637
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
1637
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
1638 1638
 		
1639 1639
 		return $orderby;
1640 1640
 		
Please login to merge, or discard this patch.
require/class.Common.php 4 patches
Doc Comments   +12 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,6 +90,10 @@  discard block
 block discarded – undo
90 90
 		return strlen($headerLine); // Needed by curl
91 91
 	}
92 92
 
93
+	/**
94
+	 * @param string $url
95
+	 * @param string $file
96
+	 */
93 97
 	public static function download($url, $file, $referer = '') {
94 98
 		global $globalDebug;
95 99
 		$fp = fopen($file, 'w');
@@ -190,7 +194,7 @@  discard block
 block discarded – undo
190 194
 	* Check is distance realistic
191 195
 	* @param int $timeDifference the time between the reception of both messages
192 196
 	* @param float $distance distance covered
193
-	* @return whether distance is realistic
197
+	* @return boolean distance is realistic
194 198
 	*/
195 199
 	public function withinThreshold ($timeDifference, $distance) {
196 200
 		$x = abs($timeDifference);
@@ -213,6 +217,9 @@  discard block
 block discarded – undo
213 217
 	}
214 218
 
215 219
 
220
+	/**
221
+	 * @param string $latlong
222
+	 */
216 223
 	public function convertDec($dms,$latlong) {
217 224
 		if ($latlong == 'latitude') {
218 225
 			$deg = substr($dms, 0, 2);
@@ -224,6 +231,9 @@  discard block
 block discarded – undo
224 231
 		return $deg+(($min*60)/3600);
225 232
 	}
226 233
 	
234
+	/**
235
+	 * @param string $latlong
236
+	 */
227 237
 	public function convertDM($coord,$latlong) {
228 238
 		if ($latlong == 'latitude') {
229 239
 			if ($coord < 0) $NSEW = 'S';
@@ -352,7 +362,7 @@  discard block
 block discarded – undo
352 362
 	/**
353 363
 	* Returns list of available locales
354 364
 	*
355
-	* @return array
365
+	* @return string[]
356 366
 	 */
357 367
 	public function listLocaleDir()
358 368
 	{
Please login to merge, or discard this patch.
Braces   +73 added lines, -30 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
 		} else {
38 38
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
39 39
 		}
40
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
40
+		if ($timeout == '') {
41
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
42
+		} else {
43
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
44
+		}
42 45
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
43 46
 		if ($type == 'post') {
44 47
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
 	private function curlResponseHeaderCallback($ch, $headerLine) {
86 89
 		//global $cookies;
87 90
 		$cookies = array();
88
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
89
-			$cookies[] = $cookie;
91
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
92
+					$cookies[] = $cookie;
93
+		}
90 94
 		return strlen($headerLine); // Needed by curl
91 95
 	}
92 96
 
@@ -97,11 +101,15 @@  discard block
 block discarded – undo
97 101
 		curl_setopt($ch, CURLOPT_URL, $url);
98 102
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
99 103
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
100
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
104
+		if ($referer != '') {
105
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
106
+		}
101 107
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
102 108
 		curl_setopt($ch, CURLOPT_FILE, $fp);
103 109
 		curl_exec($ch);
104
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
110
+		if (curl_errno($ch) && $globalDebug) {
111
+			echo 'Download error: '.curl_error($ch);
112
+		}
105 113
 		curl_close($ch);
106 114
 		fclose($fp);
107 115
 	}
@@ -112,10 +120,16 @@  discard block
 block discarded – undo
112 120
 	* @return Array array of the tables in HTML page
113 121
 	*/
114 122
 	public function table2array($data) {
115
-		if (!is_string($data)) return array();
116
-		if ($data == '') return array();
123
+		if (!is_string($data)) {
124
+			return array();
125
+		}
126
+		if ($data == '') {
127
+			return array();
128
+		}
117 129
 		$html = str_get_html($data);
118
-		if ($html === false) return array();
130
+		if ($html === false) {
131
+			return array();
132
+		}
119 133
 		$tabledata=array();
120 134
 		foreach($html->find('tr') as $element)
121 135
 		{
@@ -150,7 +164,9 @@  discard block
 block discarded – undo
150 164
 	*/
151 165
 	public function text2array($data) {
152 166
 		$html = str_get_html($data);
153
-		if ($html === false) return array();
167
+		if ($html === false) {
168
+			return array();
169
+		}
154 170
 		$tabledata=array();
155 171
 		foreach($html->find('p') as $element)
156 172
 		{
@@ -171,7 +187,9 @@  discard block
 block discarded – undo
171 187
 	* @return Float Distance in $unit
172 188
 	*/
173 189
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
174
-		if ($lat == $latc && $lon == $lonc) return 0;
190
+		if ($lat == $latc && $lon == $lonc) {
191
+			return 0;
192
+		}
175 193
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
176 194
 		if ($unit == "km") {
177 195
 			return round($dist * 1.609344);
@@ -195,10 +213,16 @@  discard block
 block discarded – undo
195 213
 	public function withinThreshold ($timeDifference, $distance) {
196 214
 		$x = abs($timeDifference);
197 215
 		$d = abs($distance);
198
-		if ($x == 0 || $d == 0) return true;
216
+		if ($x == 0 || $d == 0) {
217
+			return true;
218
+		}
199 219
 		// may be due to Internet jitter; distance is realistic
200
-		if ($x < 0.7 && $d < 2000) return true;
201
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
220
+		if ($x < 0.7 && $d < 2000) {
221
+			return true;
222
+		} else {
223
+			return $d/$x < 1500*0.27778;
224
+		}
225
+		// 1500 km/h max
202 226
 	}
203 227
 
204 228
 
@@ -226,11 +250,17 @@  discard block
 block discarded – undo
226 250
 	
227 251
 	public function convertDM($coord,$latlong) {
228 252
 		if ($latlong == 'latitude') {
229
-			if ($coord < 0) $NSEW = 'S';
230
-			else $NSEW = 'N';
253
+			if ($coord < 0) {
254
+				$NSEW = 'S';
255
+			} else {
256
+				$NSEW = 'N';
257
+			}
231 258
 		} elseif ($latlong == 'longitude') {
232
-			if ($coord < 0) $NSEW = 'W';
233
-			else $NSEW = 'E';
259
+			if ($coord < 0) {
260
+				$NSEW = 'W';
261
+			} else {
262
+				$NSEW = 'E';
263
+			}
234 264
 		}
235 265
 		$coord = abs($coord);
236 266
 		$deg = floor($coord);
@@ -273,7 +303,9 @@  discard block
 block discarded – undo
273 303
 	public function hex2str($hex) {
274 304
 		$str = '';
275 305
 		$hexln = strlen($hex);
276
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
306
+		for($i=0;$i<$hexln;$i+=2) {
307
+			$str .= chr(hexdec(substr($hex,$i,2)));
308
+		}
277 309
 		return $str;
278 310
 	}
279 311
 	
@@ -301,8 +333,11 @@  discard block
 block discarded – undo
301 333
 		$b = $lat2 - $lat1;
302 334
 		$c = -($a*$lat1+$b*$lon1);
303 335
 		$d = $a*$lat3+$b*$lon3+$c;
304
-		if ($d > -$approx && $d < $approx) return true;
305
-		else return false;
336
+		if ($d > -$approx && $d < $approx) {
337
+			return true;
338
+		} else {
339
+			return false;
340
+		}
306 341
 	}
307 342
 	
308 343
 	public function array_merge_noappend() {
@@ -361,7 +396,9 @@  discard block
 block discarded – undo
361 396
 			return $result;
362 397
 		}
363 398
 		$handle = @opendir('./locale');
364
-		if ($handle === false) return $result;
399
+		if ($handle === false) {
400
+			return $result;
401
+		}
365 402
 		while (false !== ($file = readdir($handle))) {
366 403
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
367 404
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -428,8 +465,9 @@  discard block
 block discarded – undo
428 465
 		$error = false; 
429 466
 		if ($fp_out = gzopen($dest, $mode)) { 
430 467
 			if ($fp_in = fopen($source,'rb')) { 
431
-				while (!feof($fp_in)) 
432
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
468
+				while (!feof($fp_in)) {
469
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
470
+				}
433 471
 				fclose($fp_in); 
434 472
 			} else {
435 473
 				$error = true; 
@@ -438,14 +476,17 @@  discard block
 block discarded – undo
438 476
 		} else {
439 477
 			$error = true; 
440 478
 		}
441
-		if ($error)
442
-			return false; 
443
-		else
444
-			return $dest; 
479
+		if ($error) {
480
+					return false;
481
+		} else {
482
+					return $dest;
483
+		}
445 484
 	} 
446 485
 	
447 486
 	public function remove_accents($string) {
448
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
487
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
488
+			return $string;
489
+		}
449 490
 		$chars = array(
450 491
 		    // Decompositions for Latin-1 Supplement
451 492
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -569,7 +610,9 @@  discard block
 block discarded – undo
569 610
 		$ip = gethostbyname($host);
570 611
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
571 612
 		$r = @socket_connect($s, $ip, $port);
572
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
613
+		if (!socket_set_nonblock($s)) {
614
+			echo "Unable to set nonblock on socket\n";
615
+		}
573 616
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
574 617
 			return $s;
575 618
 		}
Please login to merge, or discard this patch.
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 	//protected $cookies = array();
8 8
 	
9 9
 	/**
10
-	* Get data from form result
11
-	* @param String $url form URL
12
-	* @param String $type type of submit form method (get or post)
13
-	* @param String|Array $data values form post method
14
-	* @param Array $headers header to submit with the form
15
-	* @return String the result
16
-	*/
10
+	 * Get data from form result
11
+	 * @param String $url form URL
12
+	 * @param String $type type of submit form method (get or post)
13
+	 * @param String|Array $data values form post method
14
+	 * @param Array $headers header to submit with the form
15
+	 * @return String the result
16
+	 */
17 17
 	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 	}
108 108
 	
109 109
 	/**
110
-	* Convert a HTML table to an array
111
-	* @param String $data HTML page
112
-	* @return Array array of the tables in HTML page
113
-	*/
110
+	 * Convert a HTML table to an array
111
+	 * @param String $data HTML page
112
+	 * @return Array array of the tables in HTML page
113
+	 */
114 114
 	public function table2array($data) {
115 115
 		if (!is_string($data)) return array();
116 116
 		if ($data == '') return array();
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 	
146 146
 	/**
147
-	* Convert <p> part of a HTML page to an array
148
-	* @param String $data HTML page
149
-	* @return Array array of the <p> in HTML page
150
-	*/
147
+	 * Convert <p> part of a HTML page to an array
148
+	 * @param String $data HTML page
149
+	 * @return Array array of the <p> in HTML page
150
+	 */
151 151
 	public function text2array($data) {
152 152
 		$html = str_get_html($data);
153 153
 		if ($html === false) return array();
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 	}
163 163
 
164 164
 	/**
165
-	* Give distance between 2 coordonnates
166
-	* @param Float $lat latitude of first point
167
-	* @param Float $lon longitude of first point
168
-	* @param Float $latc latitude of second point
169
-	* @param Float $lonc longitude of second point
170
-	* @param String $unit km else no unit used
171
-	* @return Float Distance in $unit
172
-	*/
165
+	 * Give distance between 2 coordonnates
166
+	 * @param Float $lat latitude of first point
167
+	 * @param Float $lon longitude of first point
168
+	 * @param Float $latc latitude of second point
169
+	 * @param Float $lonc longitude of second point
170
+	 * @param String $unit km else no unit used
171
+	 * @return Float Distance in $unit
172
+	 */
173 173
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
174 174
 		if ($lat == $latc && $lon == $lonc) return 0;
175 175
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 	}
188 188
 
189 189
 	/**
190
-	* Check is distance realistic
191
-	* @param int $timeDifference the time between the reception of both messages
192
-	* @param float $distance distance covered
193
-	* @return whether distance is realistic
194
-	*/
190
+	 * Check is distance realistic
191
+	 * @param int $timeDifference the time between the reception of both messages
192
+	 * @param float $distance distance covered
193
+	 * @return whether distance is realistic
194
+	 */
195 195
 	public function withinThreshold ($timeDifference, $distance) {
196 196
 		$x = abs($timeDifference);
197 197
 		$d = abs($distance);
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	}
210 210
 
211 211
 	public function isInteger($input){
212
-	    return(ctype_digit(strval($input)));
212
+		return(ctype_digit(strval($input)));
213 213
 	}
214 214
 
215 215
 
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 	}
241 241
 	
242 242
 	/**
243
-	* Copy folder contents
244
-	* @param       string   $source    Source path
245
-	* @param       string   $dest      Destination path
246
-	* @return      bool     Returns true on success, false on failure
247
-	*/
243
+	 * Copy folder contents
244
+	 * @param       string   $source    Source path
245
+	 * @param       string   $dest      Destination path
246
+	 * @return      bool     Returns true on success, false on failure
247
+	 */
248 248
 	public function xcopy($source, $dest)
249 249
 	{
250 250
 		$files = glob($source.'*.*');
@@ -256,20 +256,20 @@  discard block
 block discarded – undo
256 256
 	}
257 257
 	
258 258
 	/**
259
-	* Check if an url exist
260
-	* @param	String $url url to check
261
-	* @return	bool Return true on succes false on failure
262
-	*/
259
+	 * Check if an url exist
260
+	 * @param	String $url url to check
261
+	 * @return	bool Return true on succes false on failure
262
+	 */
263 263
 	public function urlexist($url){
264 264
 		$headers=get_headers($url);
265 265
 		return stripos($headers[0],"200 OK")?true:false;
266 266
 	}
267 267
 	
268 268
 	/**
269
-	* Convert hexa to string
270
-	* @param	String $hex data in hexa
271
-	* @return	String Return result
272
-	*/
269
+	 * Convert hexa to string
270
+	 * @param	String $hex data in hexa
271
+	 * @return	String Return result
272
+	 */
273 273
 	public function hex2str($hex) {
274 274
 		$str = '';
275 275
 		$hexln = strlen($hex);
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
 	}
279 279
 	
280 280
 	/**
281
-	* Convert hexa color to rgb
282
-	* @param	String $hex data in hexa
283
-	* @return	String Return result
284
-	*/
281
+	 * Convert hexa color to rgb
282
+	 * @param	String $hex data in hexa
283
+	 * @return	String Return result
284
+	 */
285 285
 	public function hex2rgb($hex) {
286 286
 		$hex = str_replace('#','',$hex);
287 287
 		return sscanf($hex, "%02x%02x%02x"); 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 	}
360 360
 	
361 361
 	/**
362
-	* Returns list of available locales
363
-	*
364
-	* @return array
362
+	 * Returns list of available locales
363
+	 *
364
+	 * @return array
365 365
 	 */
366 366
 	public function listLocaleDir()
367 367
 	{
@@ -456,100 +456,100 @@  discard block
 block discarded – undo
456 456
 	public function remove_accents($string) {
457 457
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
458 458
 		$chars = array(
459
-		    // Decompositions for Latin-1 Supplement
460
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
461
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
462
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
463
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
464
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
465
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
466
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
467
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
468
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
469
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
470
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
471
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
472
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
473
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
474
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
475
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
476
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
477
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
478
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
479
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
480
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
481
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
482
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
483
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
484
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
485
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
486
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
487
-		    chr(195).chr(191) => 'y',
488
-		    // Decompositions for Latin Extended-A
489
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
490
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
491
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
492
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
493
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
494
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
495
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
496
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
497
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
498
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
499
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
500
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
501
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
502
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
503
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
504
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
505
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
506
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
507
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
508
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
509
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
510
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
511
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
512
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
513
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
514
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
515
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
516
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
517
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
518
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
519
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
520
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
521
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
522
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
523
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
524
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
525
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
526
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
527
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
528
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
529
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
530
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
531
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
532
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
533
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
534
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
535
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
536
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
537
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
538
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
539
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
540
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
541
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
542
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
543
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
544
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
545
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
546
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
547
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
548
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
549
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
550
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
551
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
552
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
459
+			// Decompositions for Latin-1 Supplement
460
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
461
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
462
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
463
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
464
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
465
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
466
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
467
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
468
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
469
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
470
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
471
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
472
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
473
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
474
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
475
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
476
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
477
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
478
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
479
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
480
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
481
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
482
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
483
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
484
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
485
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
486
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
487
+			chr(195).chr(191) => 'y',
488
+			// Decompositions for Latin Extended-A
489
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
490
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
491
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
492
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
493
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
494
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
495
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
496
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
497
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
498
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
499
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
500
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
501
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
502
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
503
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
504
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
505
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
506
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
507
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
508
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
509
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
510
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
511
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
512
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
513
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
514
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
515
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
516
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
517
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
518
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
519
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
520
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
521
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
522
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
523
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
524
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
525
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
526
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
527
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
528
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
529
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
530
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
531
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
532
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
533
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
534
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
535
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
536
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
537
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
538
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
539
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
540
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
541
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
542
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
543
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
544
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
545
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
546
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
547
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
548
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
549
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
550
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
551
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
552
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
553 553
 		);
554 554
 		$string = strtr($string, $chars);
555 555
 		return $string;
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	* @param Array $headers header to submit with the form
15 15
 	* @return String the result
16 16
 	*/
17
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
20 20
 		curl_setopt($ch, CURLOPT_URL, $url);
21 21
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
22
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
22
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
23 23
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
24 24
 			}
25 25
 		}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
32
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
33 33
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
34 34
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
35 35
 		if ($useragent == '') {
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41 41
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
42
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
42
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
43 43
 		if ($type == 'post') {
44 44
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
45 45
 			if (is_array($data)) {
46 46
 				curl_setopt($ch, CURLOPT_POST, count($data));
47 47
 				$data_string = '';
48
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
48
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
49 49
 				rtrim($data_string, '&');
50 50
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
51 51
 			} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 		if ($cookie != '') {
59 59
 			if (is_array($cookie)) {
60
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
60
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
61 61
 			} else {
62 62
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
63 63
 			}
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 		$info = curl_getinfo($ch);
70 70
 		//var_dump($info);
71 71
 		curl_close($ch);
72
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
72
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
73 73
 			echo "Cloudflare Detected\n";
74 74
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
75 75
 			$useragent = UAgent::random();
76 76
 			cloudflare::useUserAgent($useragent);
77 77
 			if ($clearanceCookie = cloudflare::bypass($url)) {
78
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
78
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
79 79
 			}
80 80
 		} else {
81 81
 			return $result;
@@ -116,27 +116,27 @@  discard block
 block discarded – undo
116 116
 		if ($data == '') return array();
117 117
 		$html = str_get_html($data);
118 118
 		if ($html === false) return array();
119
-		$tabledata=array();
120
-		foreach($html->find('tr') as $element)
119
+		$tabledata = array();
120
+		foreach ($html->find('tr') as $element)
121 121
 		{
122 122
 			$td = array();
123
-			foreach( $element->find('th') as $row)
123
+			foreach ($element->find('th') as $row)
124 124
 			{
125 125
 				$td [] = trim($row->plaintext);
126 126
 			}
127
-			$td=array_filter($td);
127
+			$td = array_filter($td);
128 128
 			$tabledata[] = $td;
129 129
 
130 130
 			$td = array();
131 131
 			$tdi = array();
132
-			foreach( $element->find('td') as $row)
132
+			foreach ($element->find('td') as $row)
133 133
 			{
134 134
 				$td [] = trim($row->plaintext);
135 135
 				$tdi [] = trim($row->innertext);
136 136
 			}
137
-			$td=array_filter($td);
138
-			$tdi=array_filter($tdi);
139
-			$tabledata[]=array_merge($td,$tdi);
137
+			$td = array_filter($td);
138
+			$tdi = array_filter($tdi);
139
+			$tabledata[] = array_merge($td, $tdi);
140 140
 		}
141 141
 		$html->clear();
142 142
 		unset($html);
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	public function text2array($data) {
152 152
 		$html = str_get_html($data);
153 153
 		if ($html === false) return array();
154
-		$tabledata=array();
155
-		foreach($html->find('p') as $element)
154
+		$tabledata = array();
155
+		foreach ($html->find('p') as $element)
156 156
 		{
157 157
 			$tabledata [] = trim($element->plaintext);
158 158
 		}
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	*/
173 173
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
174 174
 		if ($lat == $latc && $lon == $lonc) return 0;
175
-		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
175
+		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515;
176 176
 		if ($unit == "km") {
177
-			return round($dist * 1.609344);
177
+			return round($dist*1.609344);
178 178
 		} elseif ($unit == "m") {
179
-			return round($dist * 1.609344 * 1000);
179
+			return round($dist*1.609344*1000);
180 180
 		} elseif ($unit == "mile" || $unit == "mi") {
181 181
 			return round($dist);
182 182
 		} elseif ($unit == "nm") {
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	* @param float $distance distance covered
193 193
 	* @return whether distance is realistic
194 194
 	*/
195
-	public function withinThreshold ($timeDifference, $distance) {
195
+	public function withinThreshold($timeDifference, $distance) {
196 196
 		$x = abs($timeDifference);
197 197
 		$d = abs($distance);
198 198
 		if ($x == 0 || $d == 0) return true;
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
 		return ($array !== array_values($array));
209 209
 	}
210 210
 
211
-	public function isInteger($input){
211
+	public function isInteger($input) {
212 212
 	    return(ctype_digit(strval($input)));
213 213
 	}
214 214
 
215 215
 
216
-	public function convertDec($dms,$latlong) {
216
+	public function convertDec($dms, $latlong) {
217 217
 		if ($latlong == 'latitude') {
218 218
 			$deg = substr($dms, 0, 2);
219 219
 			$min = substr($dms, 2, 4);
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 			$deg = substr($dms, 0, 3);
222 222
 			$min = substr($dms, 3, 5);
223 223
 		}
224
-		return $deg+(($min*60)/3600);
224
+		return $deg + (($min*60)/3600);
225 225
 	}
226 226
 	
227
-	public function convertDM($coord,$latlong) {
227
+	public function convertDM($coord, $latlong) {
228 228
 		if ($latlong == 'latitude') {
229 229
 			if ($coord < 0) $NSEW = 'S';
230 230
 			else $NSEW = 'N';
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 		}
235 235
 		$coord = abs($coord);
236 236
 		$deg = floor($coord);
237
-		$coord = ($coord-$deg)*60;
237
+		$coord = ($coord - $deg)*60;
238 238
 		$min = $coord;
239
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
239
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
240 240
 	}
241 241
 	
242 242
 	/**
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	public function xcopy($source, $dest)
249 249
 	{
250 250
 		$files = glob($source.'*.*');
251
-		foreach($files as $file){
252
-			$file_to_go = str_replace($source,$dest,$file);
251
+		foreach ($files as $file) {
252
+			$file_to_go = str_replace($source, $dest, $file);
253 253
 			copy($file, $file_to_go);
254 254
 		}
255 255
 		return true;
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 	* @param	String $url url to check
261 261
 	* @return	bool Return true on succes false on failure
262 262
 	*/
263
-	public function urlexist($url){
264
-		$headers=get_headers($url);
265
-		return stripos($headers[0],"200 OK")?true:false;
263
+	public function urlexist($url) {
264
+		$headers = get_headers($url);
265
+		return stripos($headers[0], "200 OK") ? true : false;
266 266
 	}
267 267
 	
268 268
 	/**
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	public function hex2str($hex) {
274 274
 		$str = '';
275 275
 		$hexln = strlen($hex);
276
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
276
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
277 277
 		return $str;
278 278
 	}
279 279
 	
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	* @return	String Return result
284 284
 	*/
285 285
 	public function hex2rgb($hex) {
286
-		$hex = str_replace('#','',$hex);
286
+		$hex = str_replace('#', '', $hex);
287 287
 		return sscanf($hex, "%02x%02x%02x"); 
288 288
 	}
289 289
 	
@@ -291,33 +291,33 @@  discard block
 block discarded – undo
291 291
 		//difference in longitudinal coordinates
292 292
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
293 293
 		//difference in the phi of latitudinal coordinates
294
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
294
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
295 295
 		//we need to recalculate $dLon if it is greater than pi
296
-		if(abs($dLon) > pi()) {
297
-			if($dLon > 0) {
298
-				$dLon = (2 * pi() - $dLon) * -1;
296
+		if (abs($dLon) > pi()) {
297
+			if ($dLon > 0) {
298
+				$dLon = (2*pi() - $dLon)*-1;
299 299
 			} else {
300
-				$dLon = 2 * pi() + $dLon;
300
+				$dLon = 2*pi() + $dLon;
301 301
 			}
302 302
 		}
303 303
 		//return the angle, normalized
304
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
304
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
305 305
 	}
306 306
 	
307
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) {
307
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) {
308 308
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
309
-		$a = -($lon2-$lon1);
309
+		$a = -($lon2 - $lon1);
310 310
 		$b = $lat2 - $lat1;
311
-		$c = -($a*$lat1+$b*$lon1);
312
-		$d = $a*$lat3+$b*$lon3+$c;
311
+		$c = -($a*$lat1 + $b*$lon1);
312
+		$d = $a*$lat3 + $b*$lon3 + $c;
313 313
 		if ($d > -$approx && $d < $approx) return true;
314 314
 		else return false;
315 315
 	}
316 316
 	
317 317
 	public function array_merge_noappend() {
318 318
 		$output = array();
319
-		foreach(func_get_args() as $array) {
320
-			foreach($array as $key => $value) {
319
+		foreach (func_get_args() as $array) {
320
+			foreach ($array as $key => $value) {
321 321
 				$output[$key] = isset($output[$key]) ?
322 322
 				array_merge($output[$key], $value) : $value;
323 323
 			}
@@ -381,34 +381,34 @@  discard block
 block discarded – undo
381 381
 		return $result;
382 382
 	}
383 383
 
384
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){
384
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) {
385 385
 		global $globalMapRefresh;
386 386
 		$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
387 387
 		$r = 6378;
388 388
 		$latitude = deg2rad($latitude);
389 389
 		$longitude = deg2rad($longitude);
390 390
 		$bearing = deg2rad($heading); 
391
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
392
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
393
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
391
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
392
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
393
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
394 394
 	}
395 395
 	
396
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
396
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
397 397
 		// distance in meter
398 398
 		$R = 6378.14;
399
-		$latitude1 = $latitude * (M_PI/180);
400
-		$longitude1 = $longitude * (M_PI/180);
401
-		$brng = $bearing * (M_PI/180);
399
+		$latitude1 = $latitude*(M_PI/180);
400
+		$longitude1 = $longitude*(M_PI/180);
401
+		$brng = $bearing*(M_PI/180);
402 402
 		$d = $distance;
403 403
 
404 404
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
405
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
405
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
406 406
 
407
-		$latitude2 = $latitude2 * (180/M_PI);
408
-		$longitude2 = $longitude2 * (180/M_PI);
407
+		$latitude2 = $latitude2*(180/M_PI);
408
+		$longitude2 = $longitude2*(180/M_PI);
409 409
 
410
-		$flat = round ($latitude2,6);
411
-		$flong = round ($longitude2,6);
410
+		$flat = round($latitude2, 6);
411
+		$flong = round($longitude2, 6);
412 412
 /*
413 413
 		$dx = $distance*cos($bearing);
414 414
 		$dy = $distance*sin($bearing);
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 		$flong = $longitude + $dlong;
418 418
 		$flat = $latitude + $dlat;
419 419
 */
420
-		return array('latitude' => $flat,'longitude' => $flong);
420
+		return array('latitude' => $flat, 'longitude' => $flong);
421 421
 	}
422 422
 
423 423
 	/**
@@ -431,14 +431,14 @@  discard block
 block discarded – undo
431 431
 	 * @param integer $level GZIP compression level (default: 9)
432 432
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
433 433
 	 */
434
-	public function gzCompressFile($source, $level = 9){ 
435
-		$dest = $source . '.gz'; 
436
-		$mode = 'wb' . $level; 
434
+	public function gzCompressFile($source, $level = 9) { 
435
+		$dest = $source.'.gz'; 
436
+		$mode = 'wb'.$level; 
437 437
 		$error = false; 
438 438
 		if ($fp_out = gzopen($dest, $mode)) { 
439
-			if ($fp_in = fopen($source,'rb')) { 
439
+			if ($fp_in = fopen($source, 'rb')) { 
440 440
 				while (!feof($fp_in)) 
441
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
441
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
442 442
 				fclose($fp_in); 
443 443
 			} else {
444 444
 				$error = true; 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 	} 
455 455
 	
456 456
 	public function remove_accents($string) {
457
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
457
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
458 458
 		$chars = array(
459 459
 		    // Decompositions for Latin-1 Supplement
460 460
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
512 512
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
513 513
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
514
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
514
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
515 515
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
516 516
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
517 517
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -527,13 +527,13 @@  discard block
 block discarded – undo
527 527
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
528 528
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
529 529
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
530
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
531
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
532
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
533
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
534
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
535
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
536
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
530
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
531
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
532
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
533
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
534
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
535
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
536
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
537 537
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
538 538
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
539 539
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
568 568
 			if (is_numeric($string[$i]) && $concat_flag) {
569 569
 				$int .= $string[$i];
570
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
570
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
571 571
 				$concat_flag = false;
572 572
 			}
573 573
 		}
Please login to merge, or discard this patch.
require/class.SpotterImport.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -46,6 +46,10 @@
 block discarded – undo
46 46
 
47 47
     }
48 48
 
49
+    /**
50
+     * @param string $id
51
+     * @param string $ident
52
+     */
49 53
     public function get_Schedule($id,$ident) {
50 54
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
51 55
 	// Get schedule here, so it's done only one time
Please login to merge, or discard this patch.
Braces   +346 added lines, -122 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	$dbc = $this->db;
64 64
 	$this->all_flights[$id]['schedule_check'] = true;
65 65
 	if ($globalSchedulesFetch) {
66
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
66
+	if ($globalDebug) {
67
+		echo 'Getting schedule info...'."\n";
68
+	}
67 69
 	$Spotter = new Spotter($dbc);
68 70
 	$Schedule = new Schedule($dbc);
69 71
 	$Translation = new Translation($dbc);
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	    if ($Schedule->checkSchedule($operator) == 0) {
75 77
 		$schedule = $Schedule->fetchSchedule($operator);
76 78
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
79
+		    if ($globalDebug) {
80
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
81
+		    }
78 82
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79 83
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80 84
 		    // Should also check if route schedule = route from DB
@@ -83,7 +87,9 @@  discard block
 block discarded – undo
83 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84 88
 			    if (trim($airport_icao) != '') {
85 89
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
92
+				}
87 93
 			    }
88 94
 			}
89 95
 		    }
@@ -92,17 +98,25 @@  discard block
 block discarded – undo
92 98
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93 99
 			    if (trim($airport_icao) != '') {
94 100
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
101
+				if ($globalDebug) {
102
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
103
+				}
96 104
 			    }
97 105
 			}
98 106
 		    }
99 107
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
100 108
 		}
101
-	    } else $scheduleexist = true;
102
-	} else $scheduleexist = true;
109
+	    } else {
110
+	    	$scheduleexist = true;
111
+	    }
112
+	} else {
113
+		$scheduleexist = true;
114
+	}
103 115
 	// close connection, at least one way will work ?
104 116
        if ($scheduleexist) {
105
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
117
+		if ($globalDebug) {
118
+			echo "-> get arrival/departure airport info for ".$ident."\n";
119
+		}
106 120
     		$sch = $Schedule->getSchedule($operator);
107 121
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
108 122
        }
@@ -124,14 +138,18 @@  discard block
 block discarded – undo
124 138
 
125 139
     public function checkAll() {
126 140
 	global $globalDebug, $globalNoImport;
127
-	if ($globalDebug) echo "Update last seen flights data...\n";
141
+	if ($globalDebug) {
142
+		echo "Update last seen flights data...\n";
143
+	}
128 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129 145
 	    foreach ($this->all_flights as $key => $flight) {
130 146
 		if (isset($this->all_flights[$key]['id'])) {
131 147
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 148
     		    $Spotter = new Spotter($this->db);
133 149
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
150
+        	    if (isset($this->all_flights[$key]['altitude'])) {
151
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
152
+        	    }
135 153
         	}
136 154
 	    }
137 155
 	}
@@ -139,24 +157,32 @@  discard block
 block discarded – undo
139 157
 
140 158
     public function arrival($key) {
141 159
 	global $globalClosestMinDist, $globalDebug;
142
-	if ($globalDebug) echo 'Update arrival...'."\n";
160
+	if ($globalDebug) {
161
+		echo 'Update arrival...'."\n";
162
+	}
143 163
 	$Spotter = new Spotter($this->db);
144 164
         $airport_icao = '';
145 165
         $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
166
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
167
+        	$globalClosestMinDist = 50;
168
+        }
147 169
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148 170
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149 171
     	    if (isset($closestAirports[0])) {
150 172
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 173
         	    $airport_icao = $closestAirports[0]['icao'];
152 174
         	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
175
+        	    if ($globalDebug) {
176
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        	    }
154 178
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155 179
         	    foreach ($closestAirports as $airport) {
156 180
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157 181
         		    $airport_icao = $airport['icao'];
158 182
         		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
183
+        		    if ($globalDebug) {
184
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        		    }
160 186
         		    break;
161 187
         		}
162 188
         	    }
@@ -164,14 +190,20 @@  discard block
 block discarded – undo
164 190
         		$airport_icao = $closestAirports[0]['icao'];
165 191
         		$airport_time = $this->all_flights[$key]['datetime'];
166 192
         	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
193
+        		if ($globalDebug) {
194
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
195
+        		}
168 196
         	}
169 197
     	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
198
+    		    if ($globalDebug) {
199
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
200
+    		    }
171 201
     	    }
172 202
 
173 203
         } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
204
+        	if ($globalDebug) {
205
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
206
+        	}
175 207
         }
176 208
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177 209
     }
@@ -181,12 +213,16 @@  discard block
 block discarded – undo
181 213
     public function del() {
182 214
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 215
 	// Delete old infos
184
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
216
+	if ($globalDebug) {
217
+		echo 'Delete old values and update latest data...'."\n";
218
+	}
185 219
 	foreach ($this->all_flights as $key => $flight) {
186 220
     	    if (isset($flight['lastupdate'])) {
187 221
         	if ($flight['lastupdate'] < (time()-3000)) {
188 222
             	    if (isset($this->all_flights[$key]['id'])) {
189
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
223
+            		if ($globalDebug) {
224
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
225
+            		}
190 226
 			/*
191 227
 			$SpotterLive = new SpotterLive();
192 228
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -197,7 +233,9 @@  discard block
 block discarded – undo
197 233
             		    $Spotter = new Spotter($this->db);
198 234
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199 235
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
200
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
236
+				if ($globalDebug && $result != 'success') {
237
+					echo '!!! ERROR : '.$result."\n";
238
+				}
201 239
 			    }
202 240
 			// Put in archive
203 241
 //				$Spotter->db = null;
@@ -212,8 +250,10 @@  discard block
 block discarded – undo
212 250
     public function add($line) {
213 251
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB;
214 252
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
215
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
216
-/*
253
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
254
+		$globalCoordMinChange = '0.02';
255
+	}
256
+	/*
217 257
 	$Spotter = new Spotter();
218 258
 	$dbc = $Spotter->db;
219 259
 	$SpotterLive = new SpotterLive($dbc);
@@ -241,11 +281,15 @@  discard block
 block discarded – undo
241 281
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
242 282
 		    $current_date = date('Y-m-d');
243 283
 		    $source = $line['source_name'];
244
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
284
+		    if ($source == '' || $line['format_source'] == 'aprs') {
285
+		    	$source = $line['format_source'];
286
+		    }
245 287
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
246 288
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
247 289
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
290
+		    } else {
291
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
292
+		    }
249 293
 		}
250 294
 		
251 295
 		/*
@@ -261,22 +305,35 @@  discard block
 block discarded – undo
261 305
 		//$this->db = $dbc;
262 306
 
263 307
 		//$hex = trim($line['hex']);
264
-	        if (!isset($line['id'])) $id = trim($line['hex']);
265
-	        else $id = trim($line['id']);
308
+	        if (!isset($line['id'])) {
309
+	        	$id = trim($line['hex']);
310
+	        } else {
311
+	        	$id = trim($line['id']);
312
+	        }
266 313
 		
267 314
 		if (!isset($this->all_flights[$id])) {
268 315
 		    $this->all_flights[$id] = array();
269 316
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270 317
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
318
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
319
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
320
+		    }
272 321
 		    if (!isset($line['id'])) {
273
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
322
+			if (!isset($globalDaemon)) {
323
+				$globalDaemon = TRUE;
324
+			}
325
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
275 326
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
276
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
327
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
328
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
329
+			}
277 330
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
331
+		     } else {
332
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
333
+		     }
334
+		    if ($globalAllFlights !== FALSE) {
335
+		    	$dataFound = true;
336
+		    }
280 337
 		}
281 338
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282 339
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -298,17 +355,27 @@  discard block
 block discarded – undo
298 355
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299 356
 			    }
300 357
 			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
358
+			    if ($globalDebugTimeElapsed) {
359
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+			    }
361
+			    if ($aircraft_icao != '') {
362
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
363
+			    }
303 364
 			}
304 365
 		    }
305
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
306
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
366
+		    if ($globalAllFlights !== FALSE) {
367
+		    	$dataFound = true;
368
+		    }
369
+		    if ($globalDebug) {
370
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
371
+		    }
307 372
 		}
308 373
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309 374
 			$icao = $line['aircraft_icao'];
310 375
 			$Spotter = new Spotter($this->db);
311
-			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
376
+			if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
377
+				$icao = $Spotter->aircraft_correct_icaotype[$icao];
378
+			}
312 379
 			$Spotter->db = null;
313 380
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
314 381
 		}
@@ -318,15 +385,24 @@  discard block
 block discarded – undo
318 385
 				$Spotter = new Spotter($this->db);
319 386
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
320 387
 				$Spotter->db = null;
321
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
388
+				if ($aircraft_icao != '') {
389
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
390
+				}
322 391
 			}
323 392
 		}
324 393
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
325
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
326
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
327
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
328
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
329
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
394
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
395
+				$aircraft_icao = 'GLID';
396
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
397
+				$aircraft_icao = 'UHEL';
398
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
399
+				$aircraft_icao = 'TOWPLANE';
400
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
401
+				$aircraft_icao = 'POWAIRC';
402
+			}
403
+			if (isset($aircraft_icao)) {
404
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
405
+			}
330 406
 		}
331 407
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
332 408
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -336,8 +412,11 @@  discard block
 block discarded – undo
336 412
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
337 413
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
338 414
 		    } else {
339
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
340
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
415
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
416
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
417
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
418
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
419
+				}
341 420
 				/*
342 421
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
343 422
 				print_r($this->all_flights[$id]);
@@ -370,15 +449,25 @@  discard block
 block discarded – undo
370 449
 			    $timeelapsed = microtime(true);
371 450
             		    $Spotter = new Spotter($this->db);
372 451
             		    $fromsource = NULL;
373
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
374
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
375
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
376
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
377
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
452
+            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
453
+            		    	$fromsource = $globalAirlinesSource;
454
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
455
+            		    	$fromsource = 'vatsim';
456
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
457
+			    	$fromsource = 'ivao';
458
+			    } elseif (isset($globalVATSIM) && $globalVATSIM) {
459
+			    	$fromsource = 'vatsim';
460
+			    } elseif (isset($globalIVAO) && $globalIVAO) {
461
+			    	$fromsource = 'ivao';
462
+			    }
378 463
             		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
379
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
464
+			    if ($globalDebug && $result != 'success') {
465
+			    	echo '!!! ERROR : '.$result."\n";
466
+			    }
380 467
 			    $Spotter->db = null;
381
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
468
+			    if ($globalDebugTimeElapsed) {
469
+			    	echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
470
+			    }
382 471
 			}
383 472
 		    }
384 473
 
@@ -390,7 +479,9 @@  discard block
 block discarded – undo
390 479
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
391 480
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
392 481
   */
393
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
482
+		    if (!isset($this->all_flights[$id]['id'])) {
483
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
484
+		    }
394 485
 
395 486
 		    //$putinarchive = true;
396 487
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -408,7 +499,9 @@  discard block
 block discarded – undo
408 499
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
409 500
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
410 501
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
411
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
502
+				if ($globalDebugTimeElapsed) {
503
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
504
+				}
412 505
                         }
413 506
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
414 507
 			$timeelapsed = microtime(true);
@@ -422,7 +515,9 @@  discard block
 block discarded – undo
422 515
 				$Translation->db = null;
423 516
 			    }
424 517
 			    $Spotter->db = null;
425
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
518
+			    if ($globalDebugTimeElapsed) {
519
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
520
+			    }
426 521
                     	}
427 522
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
428 523
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -431,9 +526,13 @@  discard block
 block discarded – undo
431 526
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
432 527
 		    	    }
433 528
 			}
434
-			if (!isset($globalFork)) $globalFork = TRUE;
529
+			if (!isset($globalFork)) {
530
+				$globalFork = TRUE;
531
+			}
435 532
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
436
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
533
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
534
+					$this->get_Schedule($id,trim($line['ident']));
535
+				}
437 536
 			}
438 537
 		    }
439 538
 		}
@@ -449,16 +548,23 @@  discard block
 block discarded – undo
449 548
 		    // use datetime
450 549
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
451 550
 			$speed = $speed*3.6;
452
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
453
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
551
+			if ($speed < 1000) {
552
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
553
+			}
554
+  			if ($globalDebug) {
555
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
556
+  			}
454 557
 		    }
455 558
 		}
456 559
 
457 560
 
458 561
 
459 562
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
460
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
461
-	    	    else unset($timediff);
563
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
564
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
565
+	    	    } else {
566
+	    	    	unset($timediff);
567
+	    	    }
462 568
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
463 569
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
464 570
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -467,15 +573,23 @@  discard block
 block discarded – undo
467 573
 				$this->all_flights[$id]['putinarchive'] = true;
468 574
 				$this->tmd = 0;
469 575
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
470
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
576
+				    if ($globalDebug) {
577
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
578
+				    }
471 579
 				    $timeelapsed = microtime(true);
472 580
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
473 581
 					$Spotter = new Spotter($this->db);
474 582
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
475
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
583
+					if (!empty($all_country)) {
584
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
585
+					}
476 586
 					$Spotter->db = null;
477
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
478
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
587
+					if ($globalDebugTimeElapsed) {
588
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
589
+					}
590
+					if ($globalDebug) {
591
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
592
+					}
479 593
 				    }
480 594
 				}
481 595
 			    }
@@ -483,7 +597,9 @@  discard block
 block discarded – undo
483 597
 
484 598
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
485 599
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
486
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
600
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
601
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
602
+				}
487 603
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
488 604
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
489 605
 				    $dataFound = true;
@@ -505,9 +621,13 @@  discard block
 block discarded – undo
505 621
 			    */
506 622
 			}
507 623
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
508
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
624
+			    if ($line['longitude'] > 180) {
625
+			    	$line['longitude'] = $line['longitude'] - 360;
626
+			    }
509 627
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
510
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
628
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
629
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
630
+				}
511 631
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
512 632
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
513 633
 				    $dataFound = true;
@@ -538,7 +658,9 @@  discard block
 block discarded – undo
538 658
 		    }
539 659
 		}
540 660
 		if (isset($line['last_update']) && $line['last_update'] != '') {
541
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
661
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
662
+		    	$dataFound = true;
663
+		    }
542 664
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
543 665
 		}
544 666
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -560,41 +682,61 @@  discard block
 block discarded – undo
560 682
 			// Here we force archive of flight because after ground it's a new one (or should be)
561 683
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
562 684
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
563
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
564
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
565
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
685
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
686
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
687
+			} elseif (isset($line['id'])) {
688
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
689
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
690
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
691
+			}
692
+		    }
693
+		    if ($line['ground'] != 1) {
694
+		    	$line['ground'] = 0;
566 695
 		    }
567
-		    if ($line['ground'] != 1) $line['ground'] = 0;
568 696
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
569 697
 		    //$dataFound = true;
570 698
 		}
571 699
 		if (isset($line['squawk']) && $line['squawk'] != '') {
572 700
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
573
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
701
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
702
+			    	$this->all_flights[$id]['putinarchive'] = true;
703
+			    }
574 704
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
575 705
 			    $highlight = '';
576
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
577
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
578
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
706
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
707
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
708
+			    }
709
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
710
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
711
+			    }
712
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
713
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
714
+			    }
579 715
 			    if ($highlight != '') {
580 716
 				$timeelapsed = microtime(true);
581 717
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
582 718
 				    $Spotter = new Spotter($this->db);
583 719
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
584 720
 				    $Spotter->db = null;
585
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
721
+				    if ($globalDebugTimeElapsed) {
722
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
723
+				    }
586 724
 				}
587 725
 				//$putinarchive = true;
588 726
 				//$highlight = '';
589 727
 			    }
590 728
 			    
591
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
729
+		    } else {
730
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
731
+		    }
592 732
 		    //$dataFound = true;
593 733
 		}
594 734
 
595 735
 		if (isset($line['altitude']) && $line['altitude'] != '') {
596 736
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
597
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
737
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
738
+				$this->all_flights[$id]['putinarchive'] = true;
739
+			}
598 740
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
599 741
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
600 742
 			//$dataFound = true;
@@ -606,21 +748,30 @@  discard block
 block discarded – undo
606 748
 		}
607 749
 		
608 750
 		if (isset($line['heading']) && $line['heading'] != '') {
609
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
751
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
752
+		    	$this->all_flights[$id]['putinarchive'] = true;
753
+		    }
610 754
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
611 755
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
612 756
 		    //$dataFound = true;
613 757
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
614 758
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
615 759
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
616
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
617
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
760
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
761
+		    	$this->all_flights[$id]['putinarchive'] = true;
762
+		    }
763
+  		    if ($globalDebug) {
764
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
765
+  		    }
618 766
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
619 767
   		    // If not enough messages and ACARS set heading to 0
620 768
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
621 769
   		}
622
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
623
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
770
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
771
+			$dataFound = false;
772
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
773
+			$dataFound = false;
774
+		}
624 775
 
625 776
 //		print_r($this->all_flights[$id]);
626 777
 		//gets the callsign from the last hour
@@ -636,23 +787,38 @@  discard block
 block discarded – undo
636 787
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
637 788
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
638 789
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
639
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
790
+				    if ($globalDebug) {
791
+				    	echo "Check if aircraft is already in DB...";
792
+				    }
640 793
 				    $timeelapsed = microtime(true);
641 794
 				    $SpotterLive = new SpotterLive($this->db);
642 795
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
643 796
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
644
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
797
+					if ($globalDebugTimeElapsed) {
798
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
799
+					}
645 800
 				    } elseif (isset($line['id'])) {
646 801
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
647
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
802
+					if ($globalDebugTimeElapsed) {
803
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
804
+					}
648 805
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
649 806
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
650
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
651
-				    } else $recent_ident = '';
807
+					if ($globalDebugTimeElapsed) {
808
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
809
+					}
810
+				    } else {
811
+				    	$recent_ident = '';
812
+				    }
652 813
 				    $SpotterLive->db=null;
653
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
654
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
655
-				} else $recent_ident = '';
814
+				    if ($globalDebug && $recent_ident == '') {
815
+				    	echo " Not in DB.\n";
816
+				    } elseif ($globalDebug && $recent_ident != '') {
817
+				    	echo " Already in DB.\n";
818
+				    }
819
+				} else {
820
+					$recent_ident = '';
821
+				}
656 822
 			    } else {
657 823
 				$recent_ident = '';
658 824
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -660,7 +826,9 @@  discard block
 block discarded – undo
660 826
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
661 827
 			    if($recent_ident == "")
662 828
 			    {
663
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
829
+				if ($globalDebug) {
830
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
831
+				}
664 832
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
665 833
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
666 834
 				//adds the spotter data for the archive
@@ -704,31 +872,49 @@  discard block
 block discarded – undo
704 872
 				
705 873
 				if (!$ignoreImport) {
706 874
 				    $highlight = '';
707
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
708
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
709
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
710
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
875
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
876
+				    	$highlight = 'Squawk 7500 : Hijack';
877
+				    }
878
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
879
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
880
+				    }
881
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
882
+				    	$highlight = 'Squawk 7700 : Emergency';
883
+				    }
884
+				    if (!isset($this->all_flights[$id]['id'])) {
885
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
886
+				    }
711 887
 				    $timeelapsed = microtime(true);
712 888
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
713 889
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
714 890
 					    $Spotter = new Spotter($this->db);
715 891
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
716 892
 					    $Spotter->db = null;
717
-					    if ($globalDebug && isset($result)) echo $result."\n";
893
+					    if ($globalDebug && isset($result)) {
894
+					    	echo $result."\n";
895
+					    }
718 896
 					}
719 897
 				    }
720
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
898
+				    if ($globalDebugTimeElapsed) {
899
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
900
+				    }
721 901
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
722 902
 
723 903
 				    // Add source stat in DB
724 904
 				    $Stats = new Stats($this->db);
725 905
 				    if (!empty($this->stats)) {
726
-					if ($globalDebug) echo 'Add source stats : ';
906
+					if ($globalDebug) {
907
+						echo 'Add source stats : ';
908
+					}
727 909
 				        foreach($this->stats as $date => $data) {
728 910
 					    foreach($data as $source => $sourced) {
729 911
 					        //print_r($sourced);
730
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
731
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
912
+				    	        if (isset($sourced['polar'])) {
913
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
914
+				    	        }
915
+				    	        if (isset($sourced['hist'])) {
916
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
917
+				    	        }
732 918
 				    		if (isset($sourced['msg'])) {
733 919
 				    		    if (time() - $sourced['msg']['date'] > 10) {
734 920
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -741,13 +927,17 @@  discard block
 block discarded – undo
741 927
 			    			unset($this->stats[$date]);
742 928
 			    		    }
743 929
 				    	}
744
-				    	if ($globalDebug) echo 'Done'."\n";
930
+				    	if ($globalDebug) {
931
+				    		echo 'Done'."\n";
932
+				    	}
745 933
 
746 934
 				    }
747 935
 				    $Stats->db = null;
748 936
 				    }
749 937
 				    $this->del();
750
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
938
+				} elseif ($globalDebug) {
939
+					echo 'Ignore data'."\n";
940
+				}
751 941
 				//$ignoreImport = false;
752 942
 				$this->all_flights[$id]['addedSpotter'] = 1;
753 943
 				//print_r($this->all_flights[$id]);
@@ -764,7 +954,9 @@  discard block
 block discarded – undo
764 954
 			*/
765 955
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
766 956
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
767
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
957
+				    if ($globalDebug) {
958
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
959
+				    }
768 960
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
769 961
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
770 962
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -773,7 +965,9 @@  discard block
 block discarded – undo
773 965
 					    $SpotterLive->db=null;
774 966
 					}
775 967
 				    }
776
-				    if ($globalDebug) echo " Done\n";
968
+				    if ($globalDebug) {
969
+				    	echo " Done\n";
970
+				    }
777 971
 				    $this->last_delete = time();
778 972
 				}
779 973
 			    } else {
@@ -800,11 +994,17 @@  discard block
 block discarded – undo
800 994
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
801 995
 		    if ($globalDebug) {
802 996
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
803
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
804
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
997
+				if (isset($this->all_flights[$id]['source_name'])) {
998
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
999
+				} else {
1000
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1001
+				}
805 1002
 			} else {
806
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
807
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1003
+				if (isset($this->all_flights[$id]['source_name'])) {
1004
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1005
+				} else {
1006
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1007
+				}
808 1008
 			}
809 1009
 		    }
810 1010
 		    $ignoreImport = false;
@@ -850,22 +1050,30 @@  discard block
 block discarded – undo
850 1050
 
851 1051
 		    if (!$ignoreImport) {
852 1052
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
853
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1053
+				if (!isset($this->all_flights[$id]['id'])) {
1054
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1055
+				}
854 1056
 				$timeelapsed = microtime(true);
855 1057
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
856 1058
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
857
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1059
+					if ($globalDebug) {
1060
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1061
+					}
858 1062
 					$SpotterLive = new SpotterLive($this->db);
859 1063
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
860 1064
 					$SpotterLive->db = null;
861
-					if ($globalDebug) echo $result."\n";
1065
+					if ($globalDebug) {
1066
+						echo $result."\n";
1067
+					}
862 1068
 				    }
863 1069
 				}
864 1070
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
865 1071
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
866 1072
 				}
867 1073
 				$this->all_flights[$id]['putinarchive'] = false;
868
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1074
+				if ($globalDebugTimeElapsed) {
1075
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1076
+				}
869 1077
 
870 1078
 				// Put statistics in $this->stats variable
871 1079
 				//if ($line['format_source'] != 'aprs') {
@@ -873,7 +1081,9 @@  discard block
 block discarded – undo
873 1081
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
874 1082
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
875 1083
 					$source = $this->all_flights[$id]['source_name'];
876
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1084
+					if ($source == '') {
1085
+						$source = $this->all_flights[$id]['format_source'];
1086
+					}
877 1087
 					if (!isset($this->source_location[$source])) {
878 1088
 						$Location = new Source();
879 1089
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -894,7 +1104,9 @@  discard block
 block discarded – undo
894 1104
 					$stats_heading = round($stats_heading/22.5);
895 1105
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
896 1106
 					$current_date = date('Y-m-d');
897
-					if ($stats_heading == 16) $stats_heading = 0;
1107
+					if ($stats_heading == 16) {
1108
+						$stats_heading = 0;
1109
+					}
898 1110
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
899 1111
 						for ($i=0;$i<=15;$i++) {
900 1112
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -912,7 +1124,9 @@  discard block
 block discarded – undo
912 1124
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
913 1125
 						    end($this->stats[$current_date][$source]['hist']);
914 1126
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
915
-						} else $mini = 0;
1127
+						} else {
1128
+							$mini = 0;
1129
+						}
916 1130
 						for ($i=$mini;$i<=$distance;$i+=10) {
917 1131
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
918 1132
 						}
@@ -924,19 +1138,27 @@  discard block
 block discarded – undo
924 1138
 				}
925 1139
 
926 1140
 				$this->all_flights[$id]['lastupdate'] = time();
927
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1141
+				if ($this->all_flights[$id]['putinarchive']) {
1142
+					$send = true;
1143
+				}
928 1144
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
929
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1145
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1146
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1147
+			}
930 1148
 			//$this->del();
931 1149
 			
932 1150
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
933 1151
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
934
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1152
+				if ($globalDebug) {
1153
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1154
+				}
935 1155
 				$SpotterLive = new SpotterLive($this->db);
936 1156
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
937 1157
 				$SpotterLive->db = null;
938 1158
 				//SpotterLive->deleteLiveSpotterData();
939
-				if ($globalDebug) echo " Done\n";
1159
+				if ($globalDebug) {
1160
+					echo " Done\n";
1161
+				}
940 1162
 				$this->last_delete_hourly = time();
941 1163
 			    } else {
942 1164
 				$this->del();
@@ -948,7 +1170,9 @@  discard block
 block discarded – undo
948 1170
 		    //$ignoreImport = false;
949 1171
 		}
950 1172
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
951
-		if ($send) return $this->all_flights[$id];
1173
+		if ($send) {
1174
+			return $this->all_flights[$id];
1175
+		}
952 1176
 	    }
953 1177
 	}
954 1178
     }
Please login to merge, or discard this patch.
Indentation   +402 added lines, -402 removed lines patch added patch discarded remove patch
@@ -8,20 +8,20 @@  discard block
 block discarded – undo
8 8
 require_once(dirname(__FILE__).'/class.Stats.php');
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 if (isset($globalServerAPRS) && $globalServerAPRS) {
11
-    require_once(dirname(__FILE__).'/class.APRS.php');
11
+	require_once(dirname(__FILE__).'/class.APRS.php');
12 12
 }
13 13
 
14 14
 class SpotterImport {
15
-    private $all_flights = array();
16
-    private $last_delete_hourly = 0;
17
-    private $last_delete = 0;
18
-    private $stats = array();
19
-    private $tmd = 0;
20
-    private $source_location = array();
21
-    public $db = null;
22
-    public $nb = 0;
23
-
24
-    public function __construct($dbc = null) {
15
+	private $all_flights = array();
16
+	private $last_delete_hourly = 0;
17
+	private $last_delete = 0;
18
+	private $stats = array();
19
+	private $tmd = 0;
20
+	private $source_location = array();
21
+	public $db = null;
22
+	public $nb = 0;
23
+
24
+	public function __construct($dbc = null) {
25 25
 	global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB;
26 26
 	if (!(isset($globalNoDB) && $globalNoDB)) {
27 27
 		$Connection = new Connection($dbc);
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 		$currentdate = date('Y-m-d');
34 34
 		$sourcestat = $Stats->getStatsSource($currentdate);
35 35
 		if (!empty($sourcestat)) {
36
-		    foreach($sourcestat as $srcst) {
37
-		    	$type = $srcst['stats_type'];
36
+			foreach($sourcestat as $srcst) {
37
+				$type = $srcst['stats_type'];
38 38
 			if ($type == 'polar' || $type == 'hist') {
39
-			    $source = $srcst['source_name'];
40
-			    $data = $srcst['source_data'];
41
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
-	    		}
43
-		    }
39
+				$source = $srcst['source_name'];
40
+				$data = $srcst['source_data'];
41
+				$this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
+				}
43
+			}
44 44
 		}
45 45
 	}
46 46
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 		//$APRSSpotter->connect();
49 49
 	}
50 50
 
51
-    }
51
+	}
52 52
 
53
-    public function get_Schedule($id,$ident) {
53
+	public function get_Schedule($id,$ident) {
54 54
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
55 55
 	// Get schedule here, so it's done only one time
56 56
 	
@@ -70,42 +70,42 @@  discard block
 block discarded – undo
70 70
 	$operator = $Spotter->getOperator($ident);
71 71
 	$scheduleexist = false;
72 72
 	if ($Schedule->checkSchedule($operator) == 0) {
73
-	    $operator = $Translation->checkTranslation($ident);
74
-	    if ($Schedule->checkSchedule($operator) == 0) {
73
+		$operator = $Translation->checkTranslation($ident);
74
+		if ($Schedule->checkSchedule($operator) == 0) {
75 75
 		$schedule = $Schedule->fetchSchedule($operator);
76 76
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80
-		    // Should also check if route schedule = route from DB
81
-		    if ($schedule['DepartureAirportIATA'] != '') {
77
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80
+			// Should also check if route schedule = route from DB
81
+			if ($schedule['DepartureAirportIATA'] != '') {
82 82
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
83
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84
-			    if (trim($airport_icao) != '') {
83
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84
+				if (trim($airport_icao) != '') {
85 85
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86 86
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
87
-			    }
87
+				}
88
+			}
88 89
 			}
89
-		    }
90
-		    if ($schedule['ArrivalAirportIATA'] != '') {
90
+			if ($schedule['ArrivalAirportIATA'] != '') {
91 91
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
92
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93
-			    if (trim($airport_icao) != '') {
92
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93
+				if (trim($airport_icao) != '') {
94 94
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95 95
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
96
-			    }
96
+				}
97 97
 			}
98
-		    }
99
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
98
+			}
99
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
100 100
 		}
101
-	    } else $scheduleexist = true;
101
+		} else $scheduleexist = true;
102 102
 	} else $scheduleexist = true;
103 103
 	// close connection, at least one way will work ?
104
-       if ($scheduleexist) {
104
+	   if ($scheduleexist) {
105 105
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
106
-    		$sch = $Schedule->getSchedule($operator);
106
+			$sch = $Schedule->getSchedule($operator);
107 107
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
108
-       }
108
+	   }
109 109
 	$Spotter->db = null;
110 110
 	$Schedule->db = null;
111 111
 	$Translation->db = null;
@@ -120,96 +120,96 @@  discard block
 block discarded – undo
120 120
 	}
121 121
 	  */
122 122
 	}
123
-    }
123
+	}
124 124
 
125
-    public function checkAll() {
125
+	public function checkAll() {
126 126
 	global $globalDebug, $globalNoImport;
127 127
 	if ($globalDebug) echo "Update last seen flights data...\n";
128 128
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129
-	    foreach ($this->all_flights as $key => $flight) {
129
+		foreach ($this->all_flights as $key => $flight) {
130 130
 		if (isset($this->all_flights[$key]['id'])) {
131
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132
-    		    $Spotter = new Spotter($this->db);
133
-        	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
135
-        	}
136
-	    }
131
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132
+				$Spotter = new Spotter($this->db);
133
+				$real_arrival = $this->arrival($key);
134
+				if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
135
+			}
136
+		}
137
+	}
137 138
 	}
138
-    }
139 139
 
140
-    public function arrival($key) {
140
+	public function arrival($key) {
141 141
 	global $globalClosestMinDist, $globalDebug;
142 142
 	if ($globalDebug) echo 'Update arrival...'."\n";
143 143
 	$Spotter = new Spotter($this->db);
144
-        $airport_icao = '';
145
-        $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
144
+		$airport_icao = '';
145
+		$airport_time = '';
146
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
147 147
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149
-    	    if (isset($closestAirports[0])) {
150
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151
-        	    $airport_icao = $closestAirports[0]['icao'];
152
-        	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
154
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155
-        	    foreach ($closestAirports as $airport) {
156
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157
-        		    $airport_icao = $airport['icao'];
158
-        		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
160
-        		    break;
161
-        		}
162
-        	    }
163
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
164
-        		$airport_icao = $closestAirports[0]['icao'];
165
-        		$airport_time = $this->all_flights[$key]['datetime'];
166
-        	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
168
-        	}
169
-    	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
171
-    	    }
172
-
173
-        } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175
-        }
176
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177
-    }
178
-
179
-
180
-
181
-    public function del() {
148
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149
+			if (isset($closestAirports[0])) {
150
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151
+				$airport_icao = $closestAirports[0]['icao'];
152
+				$airport_time = $this->all_flights[$key]['datetime'];
153
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
154
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155
+				foreach ($closestAirports as $airport) {
156
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157
+					$airport_icao = $airport['icao'];
158
+					$airport_time = $this->all_flights[$key]['datetime'];
159
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
160
+					break;
161
+				}
162
+				}
163
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
164
+				$airport_icao = $closestAirports[0]['icao'];
165
+				$airport_time = $this->all_flights[$key]['datetime'];
166
+			} else {
167
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
168
+			}
169
+			} else {
170
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
171
+			}
172
+
173
+		} else {
174
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175
+		}
176
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177
+	}
178
+
179
+
180
+
181
+	public function del() {
182 182
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 183
 	// Delete old infos
184 184
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
185 185
 	foreach ($this->all_flights as $key => $flight) {
186
-    	    if (isset($flight['lastupdate'])) {
187
-        	if ($flight['lastupdate'] < (time()-3000)) {
188
-            	    if (isset($this->all_flights[$key]['id'])) {
189
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
186
+			if (isset($flight['lastupdate'])) {
187
+			if ($flight['lastupdate'] < (time()-3000)) {
188
+					if (isset($this->all_flights[$key]['id'])) {
189
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
190 190
 			/*
191 191
 			$SpotterLive = new SpotterLive();
192 192
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
193 193
 			$SpotterLive->db = null;
194 194
 			*/
195 195
 			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
196
-            		    $real_arrival = $this->arrival($key);
197
-            		    $Spotter = new Spotter($this->db);
198
-            	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
196
+						$real_arrival = $this->arrival($key);
197
+						$Spotter = new Spotter($this->db);
198
+							if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199 199
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
200 200
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
201
-			    }
201
+				}
202 202
 			// Put in archive
203 203
 //				$Spotter->db = null;
204 204
 			}
205
-            	    }
206
-            	    unset($this->all_flights[$key]);
207
-    	        }
208
-	    }
209
-        }
210
-    }
205
+					}
206
+					unset($this->all_flights[$key]);
207
+				}
208
+		}
209
+		}
210
+	}
211 211
 
212
-    public function add($line) {
212
+	public function add($line) {
213 213
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB;
214 214
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
215 215
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -234,18 +234,18 @@  discard block
 block discarded – undo
234 234
 	
235 235
 	// SBS format is CSV format
236 236
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237
-	    //print_r($line);
238
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
237
+		//print_r($line);
238
+  		if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
239 239
 
240 240
 		// Increment message number
241 241
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
242
-		    $current_date = date('Y-m-d');
243
-		    $source = $line['source_name'];
244
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
245
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
246
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
247
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
242
+			$current_date = date('Y-m-d');
243
+			$source = $line['source_name'];
244
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
245
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
246
+				$this->stats[$current_date][$source]['msg']['date'] = time();
247
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
249 249
 		}
250 250
 		
251 251
 		/*
@@ -261,49 +261,49 @@  discard block
 block discarded – undo
261 261
 		//$this->db = $dbc;
262 262
 
263 263
 		//$hex = trim($line['hex']);
264
-	        if (!isset($line['id'])) $id = trim($line['hex']);
265
-	        else $id = trim($line['id']);
264
+			if (!isset($line['id'])) $id = trim($line['hex']);
265
+			else $id = trim($line['id']);
266 266
 		
267 267
 		if (!isset($this->all_flights[$id])) {
268
-		    $this->all_flights[$id] = array();
269
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
272
-		    if (!isset($line['id'])) {
268
+			$this->all_flights[$id] = array();
269
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
271
+			if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
272
+			if (!isset($line['id'])) {
273 273
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274 274
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
275 275
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
276 276
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
277
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
277
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
+			if ($globalAllFlights !== FALSE) $dataFound = true;
280 280
 		}
281 281
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
282
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
283 283
 		}
284 284
 		
285 285
 		//print_r($this->all_flights);
286 286
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
287
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
288
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
287
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
288
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
289 289
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
290
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
291
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
290
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
291
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
292 292
 			$timeelapsed = microtime(true);
293 293
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
294
-			    $Spotter = new Spotter($this->db);
295
-			    if (isset($this->all_flights[$id]['source_type'])) {
294
+				$Spotter = new Spotter($this->db);
295
+				if (isset($this->all_flights[$id]['source_type'])) {
296 296
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
297
-			    } else {
297
+				} else {
298 298
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299
-			    }
300
-			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
299
+				}
300
+				$Spotter->db = null;
301
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
303 303
 			}
304
-		    }
305
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
306
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
304
+			}
305
+			if ($globalAllFlights !== FALSE) $dataFound = true;
306
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
307 307
 		}
308 308
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309 309
 			$icao = $line['aircraft_icao'];
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
 		}
334 334
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
335 335
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
336
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
336
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
337 337
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
338
-		    } else {
338
+			} else {
339 339
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
340 340
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
341 341
 				/*
@@ -344,43 +344,43 @@  discard block
 block discarded – undo
344 344
 				print_r($line);
345 345
 				*/
346 346
 				return '';
347
-		    }
347
+			}
348 348
 		} else {
349 349
 			date_default_timezone_set('UTC');
350 350
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
351 351
 		}
352 352
 
353 353
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
354
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
354
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
355 355
 		}
356 356
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
357
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
357
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
358 358
 		}
359 359
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
360
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
360
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
361 361
 		}
362 362
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
363
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
363
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
364 364
 		}
365 365
  
366 366
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
367
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
368
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
367
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
368
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
369 369
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
370
-			    $timeelapsed = microtime(true);
371
-            		    $Spotter = new Spotter($this->db);
372
-            		    $fromsource = NULL;
373
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
374
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
375
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
376
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
377
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
378
-            		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
379
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
380
-			    $Spotter->db = null;
381
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
382
-			}
383
-		    }
370
+				$timeelapsed = microtime(true);
371
+						$Spotter = new Spotter($this->db);
372
+						$fromsource = NULL;
373
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
374
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
375
+				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
376
+				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
377
+				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
378
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
379
+				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
380
+				$Spotter->db = null;
381
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
382
+			}
383
+			}
384 384
 
385 385
 /*
386 386
 		    if (!isset($line['id'])) {
@@ -390,104 +390,104 @@  discard block
 block discarded – undo
390 390
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
391 391
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
392 392
   */
393
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
393
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
394 394
 
395
-		    //$putinarchive = true;
396
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
395
+			//$putinarchive = true;
396
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
397 397
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
398
-		    }
399
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
398
+			}
399
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
400 400
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
401
-		    }
402
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
403
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
404
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
401
+			}
402
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
403
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
404
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
405 405
 			$timeelapsed = microtime(true);
406 406
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
407 407
 				$Spotter = new Spotter($this->db);
408 408
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
409 409
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
410
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
410
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
411 411
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
412
-                        }
413
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
412
+						}
413
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
414 414
 			$timeelapsed = microtime(true);
415 415
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
416
-			    $Spotter = new Spotter($this->db);
417
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
418
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
416
+				$Spotter = new Spotter($this->db);
417
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
418
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
419 419
 				$Translation = new Translation($this->db);
420 420
 				$ident = $Translation->checkTranslation(trim($line['ident']));
421 421
 				$route = $Spotter->getRouteInfo($ident);
422 422
 				$Translation->db = null;
423
-			    }
424
-			    $Spotter->db = null;
425
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
426
-                    	}
423
+				}
424
+				$Spotter->db = null;
425
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
426
+						}
427 427
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
428
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
429
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
428
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
429
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
430 430
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
431
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
432
-		    	    }
431
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
432
+					}
433 433
 			}
434 434
 			if (!isset($globalFork)) $globalFork = TRUE;
435 435
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
436 436
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
437 437
 			}
438
-		    }
438
+			}
439 439
 		}
440 440
 
441 441
 		if (isset($line['speed']) && $line['speed'] != '') {
442 442
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
443
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
444
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
445
-		    //$dataFound = true;
443
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
444
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
445
+			//$dataFound = true;
446 446
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
447
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
448
-		    if ($distance > 1000 && $distance < 10000) {
449
-		    // use datetime
447
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
448
+			if ($distance > 1000 && $distance < 10000) {
449
+			// use datetime
450 450
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
451 451
 			$speed = $speed*3.6;
452 452
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
453 453
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
454
-		    }
454
+			}
455 455
 		}
456 456
 
457 457
 
458 458
 
459
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
460
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
461
-	    	    else unset($timediff);
462
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
459
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
460
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
461
+				else unset($timediff);
462
+				if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
463 463
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
464
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
464
+				if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
465 465
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
466 466
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
467 467
 				$this->all_flights[$id]['putinarchive'] = true;
468 468
 				$this->tmd = 0;
469 469
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
470
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
471
-				    $timeelapsed = microtime(true);
472
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
470
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
471
+					$timeelapsed = microtime(true);
472
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
473 473
 					$Spotter = new Spotter($this->db);
474 474
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
475 475
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
476 476
 					$Spotter->db = null;
477 477
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
478 478
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
479
-				    }
479
+					}
480
+				}
480 481
 				}
481
-			    }
482 482
 			}
483 483
 
484 484
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
485
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
485
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
486 486
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
487 487
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
488
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
489
-				    $dataFound = true;
490
-				    $this->all_flights[$id]['time_last_coord'] = time();
488
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
489
+					$dataFound = true;
490
+					$this->all_flights[$id]['time_last_coord'] = time();
491 491
 				}
492 492
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
493 493
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -498,20 +498,20 @@  discard block
 block discarded – undo
498 498
 				    //$putinarchive = true;
499 499
 				}
500 500
 				*/
501
-			    /*
501
+				/*
502 502
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
503 503
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
504 504
 			    }
505 505
 			    */
506 506
 			}
507 507
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
508
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
509
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
508
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
509
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
510 510
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
511 511
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
512
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
513
-				    $dataFound = true;
514
-				    $this->all_flights[$id]['time_last_coord'] = time();
512
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
513
+					$dataFound = true;
514
+					$this->all_flights[$id]['time_last_coord'] = time();
515 515
 				}
516 516
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
517 517
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -529,95 +529,95 @@  discard block
 block discarded – undo
529 529
 			    */
530 530
 			}
531 531
 
532
-		    } else if ($globalDebug && $timediff > 30) {
532
+			} else if ($globalDebug && $timediff > 30) {
533 533
 			$this->tmd = $this->tmd + 1;
534 534
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
535 535
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
536 536
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
537 537
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
538
-		    }
538
+			}
539 539
 		}
540 540
 		if (isset($line['last_update']) && $line['last_update'] != '') {
541
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
542
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
541
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
542
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
543 543
 		}
544 544
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
545
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
546
-		    //$dataFound = true;
545
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
546
+			//$dataFound = true;
547 547
 		}
548 548
 		if (isset($line['format_source']) && $line['format_source'] != '') {
549
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
549
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
550 550
 		}
551 551
 		if (isset($line['source_name']) && $line['source_name'] != '') {
552
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
552
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
553 553
 		}
554 554
 		if (isset($line['emergency']) && $line['emergency'] != '') {
555
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
556
-		    //$dataFound = true;
555
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
556
+			//$dataFound = true;
557 557
 		}
558 558
 		if (isset($line['ground']) && $line['ground'] != '') {
559
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
559
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
560 560
 			// Here we force archive of flight because after ground it's a new one (or should be)
561 561
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
562 562
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
563 563
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
564
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
564
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
565 565
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
566
-		    }
567
-		    if ($line['ground'] != 1) $line['ground'] = 0;
568
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
569
-		    //$dataFound = true;
566
+			}
567
+			if ($line['ground'] != 1) $line['ground'] = 0;
568
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
569
+			//$dataFound = true;
570 570
 		}
571 571
 		if (isset($line['squawk']) && $line['squawk'] != '') {
572
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
573
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
574
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
575
-			    $highlight = '';
576
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
577
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
578
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
579
-			    if ($highlight != '') {
572
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
573
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
574
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
575
+				$highlight = '';
576
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
577
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
578
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
579
+				if ($highlight != '') {
580 580
 				$timeelapsed = microtime(true);
581 581
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
582
-				    $Spotter = new Spotter($this->db);
583
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
584
-				    $Spotter->db = null;
585
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
582
+					$Spotter = new Spotter($this->db);
583
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
584
+					$Spotter->db = null;
585
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
586 586
 				}
587 587
 				//$putinarchive = true;
588 588
 				//$highlight = '';
589
-			    }
589
+				}
590 590
 			    
591
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
592
-		    //$dataFound = true;
591
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
592
+			//$dataFound = true;
593 593
 		}
594 594
 
595 595
 		if (isset($line['altitude']) && $line['altitude'] != '') {
596
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
596
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
597 597
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
598 598
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
599 599
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
600 600
 			//$dataFound = true;
601
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
601
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
602 602
   		}
603 603
 
604 604
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
605
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
605
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
606 606
 		}
607 607
 		
608 608
 		if (isset($line['heading']) && $line['heading'] != '') {
609
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
610
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
611
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
612
-		    //$dataFound = true;
609
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
610
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
611
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
612
+			//$dataFound = true;
613 613
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
614
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
615
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
616
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
617
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
614
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
615
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
616
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
617
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
618 618
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
619
-  		    // If not enough messages and ACARS set heading to 0
620
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
619
+  			// If not enough messages and ACARS set heading to 0
620
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
621 621
   		}
622 622
 		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
623 623
 		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -628,125 +628,125 @@  discard block
 block discarded – undo
628 628
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
629 629
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
630 630
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
631
-		    $this->all_flights[$id]['lastupdate'] = time();
632
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
633
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
634
-			    //print_r($this->all_flights);
635
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
636
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
637
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
631
+			$this->all_flights[$id]['lastupdate'] = time();
632
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
633
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
634
+				//print_r($this->all_flights);
635
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
636
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
637
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
638 638
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
639
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
640
-				    $timeelapsed = microtime(true);
641
-				    $SpotterLive = new SpotterLive($this->db);
642
-				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
639
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
640
+					$timeelapsed = microtime(true);
641
+					$SpotterLive = new SpotterLive($this->db);
642
+					if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
643 643
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
644 644
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
645
-				    } elseif (isset($line['id'])) {
645
+					} elseif (isset($line['id'])) {
646 646
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
647 647
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
648
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
648
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
649 649
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
650 650
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
651
-				    } else $recent_ident = '';
652
-				    $SpotterLive->db=null;
653
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
654
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
651
+					} else $recent_ident = '';
652
+					$SpotterLive->db=null;
653
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
654
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
655 655
 				} else $recent_ident = '';
656
-			    } else {
656
+				} else {
657 657
 				$recent_ident = '';
658 658
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
659
-			    }
660
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
661
-			    if($recent_ident == "")
662
-			    {
659
+				}
660
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
661
+				if($recent_ident == "")
662
+				{
663 663
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
664 664
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
665 665
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
666 666
 				//adds the spotter data for the archive
667 667
 				$ignoreImport = false;
668 668
 				foreach($globalAirportIgnore as $airportIgnore) {
669
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
669
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
670 670
 					$ignoreImport = true;
671
-				    }
671
+					}
672 672
 				}
673 673
 				if (count($globalAirportAccept) > 0) {
674
-				    $ignoreImport = true;
675
-				    foreach($globalAirportIgnore as $airportIgnore) {
674
+					$ignoreImport = true;
675
+					foreach($globalAirportIgnore as $airportIgnore) {
676 676
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
677
-					    $ignoreImport = false;
677
+						$ignoreImport = false;
678
+					}
678 679
 					}
679
-				    }
680 680
 				}
681 681
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
682
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
682
+					foreach($globalAirlineIgnore as $airlineIgnore) {
683 683
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
684
-					    $ignoreImport = true;
684
+						$ignoreImport = true;
685
+					}
685 686
 					}
686
-				    }
687 687
 				}
688 688
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
689
-				    $ignoreImport = true;
690
-				    foreach($globalAirlineAccept as $airlineAccept) {
689
+					$ignoreImport = true;
690
+					foreach($globalAirlineAccept as $airlineAccept) {
691 691
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
692
-					    $ignoreImport = false;
692
+						$ignoreImport = false;
693
+					}
693 694
 					}
694
-				    }
695 695
 				}
696 696
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
697
-				    $ignoreImport = true;
698
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
697
+					$ignoreImport = true;
698
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
699 699
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
700
-					    $ignoreImport = false;
700
+						$ignoreImport = false;
701
+					}
701 702
 					}
702
-				    }
703 703
 				}
704 704
 				
705 705
 				if (!$ignoreImport) {
706
-				    $highlight = '';
707
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
708
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
709
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
710
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
711
-				    $timeelapsed = microtime(true);
712
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
706
+					$highlight = '';
707
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
708
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
709
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
710
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
711
+					$timeelapsed = microtime(true);
712
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
713 713
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
714
-					    $Spotter = new Spotter($this->db);
715
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
716
-					    $Spotter->db = null;
717
-					    if ($globalDebug && isset($result)) echo $result."\n";
714
+						$Spotter = new Spotter($this->db);
715
+						$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
716
+						$Spotter->db = null;
717
+						if ($globalDebug && isset($result)) echo $result."\n";
718
+					}
718 719
 					}
719
-				    }
720
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
721
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
720
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
721
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
722 722
 
723
-				    // Add source stat in DB
724
-				    $Stats = new Stats($this->db);
725
-				    if (!empty($this->stats)) {
723
+					// Add source stat in DB
724
+					$Stats = new Stats($this->db);
725
+					if (!empty($this->stats)) {
726 726
 					if ($globalDebug) echo 'Add source stats : ';
727
-				        foreach($this->stats as $date => $data) {
728
-					    foreach($data as $source => $sourced) {
729
-					        //print_r($sourced);
730
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
731
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
732
-				    		if (isset($sourced['msg'])) {
733
-				    		    if (time() - $sourced['msg']['date'] > 10) {
734
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
735
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
736
-			    			        unset($this->stats[$date][$source]['msg']);
737
-			    			    }
738
-			    			}
739
-			    		    }
740
-			    		    if ($date != date('Y-m-d')) {
741
-			    			unset($this->stats[$date]);
742
-			    		    }
743
-				    	}
744
-				    	if ($globalDebug) echo 'Done'."\n";
745
-
746
-				    }
747
-				    $Stats->db = null;
748
-				    }
749
-				    $this->del();
727
+						foreach($this->stats as $date => $data) {
728
+						foreach($data as $source => $sourced) {
729
+							//print_r($sourced);
730
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
731
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
732
+							if (isset($sourced['msg'])) {
733
+								if (time() - $sourced['msg']['date'] > 10) {
734
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
735
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
736
+									unset($this->stats[$date][$source]['msg']);
737
+								}
738
+							}
739
+							}
740
+							if ($date != date('Y-m-d')) {
741
+							unset($this->stats[$date]);
742
+							}
743
+						}
744
+						if ($globalDebug) echo 'Done'."\n";
745
+
746
+					}
747
+					$Stats->db = null;
748
+					}
749
+					$this->del();
750 750
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
751 751
 				//$ignoreImport = false;
752 752
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -764,41 +764,41 @@  discard block
 block discarded – undo
764 764
 			*/
765 765
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
766 766
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
767
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
768
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
769
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
767
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
768
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
769
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
770 770
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
771
-					    $SpotterLive = new SpotterLive($this->db);
772
-					    $SpotterLive->deleteLiveSpotterData();
773
-					    $SpotterLive->db=null;
771
+						$SpotterLive = new SpotterLive($this->db);
772
+						$SpotterLive->deleteLiveSpotterData();
773
+						$SpotterLive->db=null;
774
+					}
774 775
 					}
775
-				    }
776
-				    if ($globalDebug) echo " Done\n";
777
-				    $this->last_delete = time();
776
+					if ($globalDebug) echo " Done\n";
777
+					$this->last_delete = time();
778 778
 				}
779
-			    } else {
779
+				} else {
780 780
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
781
-				    $this->all_flights[$id]['id'] = $recent_ident;
782
-				    $this->all_flights[$id]['addedSpotter'] = 1;
781
+					$this->all_flights[$id]['id'] = $recent_ident;
782
+					$this->all_flights[$id]['addedSpotter'] = 1;
783 783
 				}
784 784
 				if (isset($globalDaemon) && !$globalDaemon) {
785
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
785
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
786 786
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
787
-					    $Spotter = new Spotter($this->db);
788
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
789
-					    $Spotter->db = null;
787
+						$Spotter = new Spotter($this->db);
788
+						$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
789
+						$Spotter->db = null;
790
+					}
790 791
 					}
791
-				    }
792 792
 				}
793 793
 				
794
-			    }
794
+				}
795
+			}
795 796
 			}
796
-		    }
797
-		    //adds the spotter LIVE data
798
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
799
-		    //echo "\nAdd in Live !! \n";
800
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
801
-		    if ($globalDebug) {
797
+			//adds the spotter LIVE data
798
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
799
+			//echo "\nAdd in Live !! \n";
800
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
801
+			if ($globalDebug) {
802 802
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
803 803
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
804 804
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -806,60 +806,60 @@  discard block
 block discarded – undo
806 806
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
807 807
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
808 808
 			}
809
-		    }
810
-		    $ignoreImport = false;
811
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
812
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
809
+			}
810
+			$ignoreImport = false;
811
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
812
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
813 813
 
814
-		    foreach($globalAirportIgnore as $airportIgnore) {
815
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
816
-			    $ignoreImport = true;
814
+			foreach($globalAirportIgnore as $airportIgnore) {
815
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
816
+				$ignoreImport = true;
817 817
 			}
818
-		    }
819
-		    if (count($globalAirportAccept) > 0) {
820
-		        $ignoreImport = true;
821
-		        foreach($globalAirportIgnore as $airportIgnore) {
822
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
818
+			}
819
+			if (count($globalAirportAccept) > 0) {
820
+				$ignoreImport = true;
821
+				foreach($globalAirportIgnore as $airportIgnore) {
822
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
823 823
 				$ignoreImport = false;
824
-			    }
824
+				}
825
+			}
825 826
 			}
826
-		    }
827
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
827
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
828 828
 			foreach($globalAirlineIgnore as $airlineIgnore) {
829
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
829
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
830 830
 				$ignoreImport = true;
831
-			    }
831
+				}
832 832
 			}
833
-		    }
834
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
833
+			}
834
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
835 835
 			$ignoreImport = true;
836 836
 			foreach($globalAirlineAccept as $airlineAccept) {
837
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
837
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
838 838
 				$ignoreImport = false;
839
-			    }
839
+				}
840
+			}
840 841
 			}
841
-		    }
842
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
842
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
843 843
 			$ignoreImport = true;
844 844
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
845
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
846
-			        $ignoreImport = false;
847
-			    }
845
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
846
+					$ignoreImport = false;
847
+				}
848
+			}
848 849
 			}
849
-		    }
850 850
 
851
-		    if (!$ignoreImport) {
851
+			if (!$ignoreImport) {
852 852
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
853 853
 				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
854 854
 				$timeelapsed = microtime(true);
855 855
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
856
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
856
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
857 857
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
858 858
 					$SpotterLive = new SpotterLive($this->db);
859 859
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
860 860
 					$SpotterLive->db = null;
861 861
 					if ($globalDebug) echo $result."\n";
862
-				    }
862
+					}
863 863
 				}
864 864
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
865 865
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 				//if ($line['format_source'] != 'aprs') {
872 872
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
873 873
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
874
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
874
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
875 875
 					$source = $this->all_flights[$id]['source_name'];
876 876
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
877 877
 					if (!isset($this->source_location[$source])) {
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 					if ($stats_heading == 16) $stats_heading = 0;
898 898
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
899 899
 						for ($i=0;$i<=15;$i++) {
900
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
900
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
901 901
 						}
902 902
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
903 903
 					} else {
@@ -910,17 +910,17 @@  discard block
 block discarded – undo
910 910
 					//var_dump($this->stats);
911 911
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
912 912
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
913
-						    end($this->stats[$current_date][$source]['hist']);
914
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
913
+							end($this->stats[$current_date][$source]['hist']);
914
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
915 915
 						} else $mini = 0;
916 916
 						for ($i=$mini;$i<=$distance;$i+=10) {
917
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
917
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
918 918
 						}
919 919
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
920 920
 					} else {
921 921
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
922 922
 					}
923
-				    }
923
+					}
924 924
 				}
925 925
 
926 926
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 			//$this->del();
931 931
 			
932 932
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
933
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
933
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
934 934
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
935 935
 				$SpotterLive = new SpotterLive($this->db);
936 936
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -938,19 +938,19 @@  discard block
 block discarded – undo
938 938
 				//SpotterLive->deleteLiveSpotterData();
939 939
 				if ($globalDebug) echo " Done\n";
940 940
 				$this->last_delete_hourly = time();
941
-			    } else {
941
+				} else {
942 942
 				$this->del();
943 943
 				$this->last_delete_hourly = time();
944
-			    }
944
+				}
945 945
 			}
946 946
 			
947
-		    }
948
-		    //$ignoreImport = false;
947
+			}
948
+			//$ignoreImport = false;
949 949
 		}
950 950
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
951 951
 		if ($send) return $this->all_flights[$id];
952
-	    }
952
+		}
953
+	}
953 954
 	}
954
-    }
955 955
 }
956 956
 ?>
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 		$currentdate = date('Y-m-d');
34 34
 		$sourcestat = $Stats->getStatsSource($currentdate);
35 35
 		if (!empty($sourcestat)) {
36
-		    foreach($sourcestat as $srcst) {
36
+		    foreach ($sourcestat as $srcst) {
37 37
 		    	$type = $srcst['stats_type'];
38 38
 			if ($type == 'polar' || $type == 'hist') {
39 39
 			    $source = $srcst['source_name'];
40 40
 			    $data = $srcst['source_data'];
41
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
41
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
42 42
 	    		}
43 43
 		    }
44 44
 		}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     }
52 52
 
53
-    public function get_Schedule($id,$ident) {
53
+    public function get_Schedule($id, $ident) {
54 54
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
55 55
 	// Get schedule here, so it's done only one time
56 56
 	
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 		$schedule = $Schedule->fetchSchedule($operator);
76 76
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77 77
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
78
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
79
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
80 80
 		    // Should also check if route schedule = route from DB
81 81
 		    if ($schedule['DepartureAirportIATA'] != '') {
82 82
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			    }
97 97
 			}
98 98
 		    }
99
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
99
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
100 100
 		}
101 101
 	    } else $scheduleexist = true;
102 102
 	} else $scheduleexist = true;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
        if ($scheduleexist) {
105 105
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
106 106
     		$sch = $Schedule->getSchedule($operator);
107
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
107
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
108 108
        }
109 109
 	$Spotter->db = null;
110 110
 	$Schedule->db = null;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 132
     		    $Spotter = new Spotter($this->db);
133 133
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
134
+        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
135 135
         	}
136 136
 	    }
137 137
 	}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         $airport_time = '';
146 146
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
147 147
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
148
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
149 149
     	    if (isset($closestAirports[0])) {
150 150
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 151
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         		    break;
161 161
         		}
162 162
         	    }
163
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
163
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
164 164
         		$airport_icao = $closestAirports[0]['icao'];
165 165
         		$airport_time = $this->all_flights[$key]['datetime'];
166 166
         	} else {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         } else {
174 174
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175 175
         }
176
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
176
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
177 177
     }
178 178
 
179 179
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
185 185
 	foreach ($this->all_flights as $key => $flight) {
186 186
     	    if (isset($flight['lastupdate'])) {
187
-        	if ($flight['lastupdate'] < (time()-3000)) {
187
+        	if ($flight['lastupdate'] < (time() - 3000)) {
188 188
             	    if (isset($this->all_flights[$key]['id'])) {
189 189
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
190 190
 			/*
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             		    $real_arrival = $this->arrival($key);
197 197
             		    $Spotter = new Spotter($this->db);
198 198
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
199
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
200 200
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
201 201
 			    }
202 202
 			// Put in archive
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	$send = false;
234 234
 	
235 235
 	// SBS format is CSV format
236
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
236
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237 237
 	    //print_r($line);
238 238
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
239 239
 
@@ -266,25 +266,25 @@  discard block
 block discarded – undo
266 266
 		
267 267
 		if (!isset($this->all_flights[$id])) {
268 268
 		    $this->all_flights[$id] = array();
269
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
269
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
270
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => ''));
271
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
272 272
 		    if (!isset($line['id'])) {
273 273
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274 274
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
275 275
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
276
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
276
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
277 277
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
278
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
279 279
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
280 280
 		}
281 281
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
282
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
283 283
 		}
284 284
 		
285 285
 		//print_r($this->all_flights);
286 286
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
287
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
287
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
288 288
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
289 289
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
290 290
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -293,13 +293,13 @@  discard block
 block discarded – undo
293 293
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
294 294
 			    $Spotter = new Spotter($this->db);
295 295
 			    if (isset($this->all_flights[$id]['source_type'])) {
296
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
296
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
297 297
 			    } else {
298 298
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299 299
 			    }
300 300
 			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
301
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
302
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
303 303
 			}
304 304
 		    }
305 305
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			$Spotter = new Spotter($this->db);
311 311
 			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
312 312
 			$Spotter->db = null;
313
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
313
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
314 314
 		}
315 315
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
316 316
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 				$Spotter = new Spotter($this->db);
319 319
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
320 320
 				$Spotter->db = null;
321
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
321
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
322 322
 			}
323 323
 		}
324 324
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -326,15 +326,15 @@  discard block
 block discarded – undo
326 326
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
327 327
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
328 328
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
329
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
329
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
330 330
 		}
331 331
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
332
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
332
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
333 333
 		}
334 334
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
335
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
335
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
336 336
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
337
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
337
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
338 338
 		    } else {
339 339
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
340 340
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -347,24 +347,24 @@  discard block
 block discarded – undo
347 347
 		    }
348 348
 		} else {
349 349
 			date_default_timezone_set('UTC');
350
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
350
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
351 351
 		}
352 352
 
353 353
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
354
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
354
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
355 355
 		}
356 356
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
357
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
357
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
358 358
 		}
359 359
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
360
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
360
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
361 361
 		}
362 362
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
363
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
363
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
364 364
 		}
365 365
  
366 366
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
367
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
367
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
368 368
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
369 369
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
370 370
 			    $timeelapsed = microtime(true);
@@ -375,10 +375,10 @@  discard block
 block discarded – undo
375 375
 			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
376 376
 			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
377 377
 			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
378
-            		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
378
+            		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
379 379
 			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
380 380
 			    $Spotter->db = null;
381
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
381
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
382 382
 			}
383 383
 		    }
384 384
 
@@ -390,25 +390,25 @@  discard block
 block discarded – undo
390 390
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
391 391
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
392 392
   */
393
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
393
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
394 394
 
395 395
 		    //$putinarchive = true;
396 396
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
397
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
397
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
398 398
 		    }
399 399
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
400
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
400
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
401 401
 		    }
402 402
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
403
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
403
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
404 404
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
405 405
 			$timeelapsed = microtime(true);
406 406
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
407 407
 				$Spotter = new Spotter($this->db);
408 408
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
409 409
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
410
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
411
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
410
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
411
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
412 412
                         }
413 413
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
414 414
 			$timeelapsed = microtime(true);
@@ -422,34 +422,34 @@  discard block
 block discarded – undo
422 422
 				$Translation->db = null;
423 423
 			    }
424 424
 			    $Spotter->db = null;
425
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
425
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
426 426
                     	}
427 427
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
428 428
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
429 429
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
430 430
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
431
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
431
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
432 432
 		    	    }
433 433
 			}
434 434
 			if (!isset($globalFork)) $globalFork = TRUE;
435 435
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
436
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
436
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
437 437
 			}
438 438
 		    }
439 439
 		}
440 440
 
441 441
 		if (isset($line['speed']) && $line['speed'] != '') {
442 442
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
443
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
444
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
443
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
444
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
445 445
 		    //$dataFound = true;
446 446
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
447
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
447
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
448 448
 		    if ($distance > 1000 && $distance < 10000) {
449 449
 		    // use datetime
450 450
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
451 451
 			$speed = $speed*3.6;
452
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
452
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
453 453
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
454 454
 		    }
455 455
 		}
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 
458 458
 
459 459
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
460
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
460
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
461 461
 	    	    else unset($timediff);
462
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
462
+	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) {
463 463
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
464
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
464
+			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
465 465
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
466 466
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
467 467
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -471,10 +471,10 @@  discard block
 block discarded – undo
471 471
 				    $timeelapsed = microtime(true);
472 472
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
473 473
 					$Spotter = new Spotter($this->db);
474
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
474
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
475 475
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
476 476
 					$Spotter->db = null;
477
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
477
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
478 478
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
479 479
 				    }
480 480
 				}
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
485 485
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
486 486
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
487
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
487
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
488 488
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
489 489
 				    $dataFound = true;
490 490
 				    $this->all_flights[$id]['time_last_coord'] = time();
491 491
 				}
492 492
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
493
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
493
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
494 494
 				/*
495 495
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
496 496
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -508,13 +508,13 @@  discard block
 block discarded – undo
508 508
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
509 509
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
510 510
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
511
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
511
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
512 512
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
513 513
 				    $dataFound = true;
514 514
 				    $this->all_flights[$id]['time_last_coord'] = time();
515 515
 				}
516 516
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
517
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
517
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
518 518
 				/*
519 519
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
520 520
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -532,46 +532,46 @@  discard block
 block discarded – undo
532 532
 		    } else if ($globalDebug && $timediff > 30) {
533 533
 			$this->tmd = $this->tmd + 1;
534 534
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
535
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
536
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
535
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
536
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
537 537
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
538 538
 		    }
539 539
 		}
540 540
 		if (isset($line['last_update']) && $line['last_update'] != '') {
541 541
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
542
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
542
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
543 543
 		}
544 544
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
545
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
545
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
546 546
 		    //$dataFound = true;
547 547
 		}
548 548
 		if (isset($line['format_source']) && $line['format_source'] != '') {
549
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
549
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
550 550
 		}
551 551
 		if (isset($line['source_name']) && $line['source_name'] != '') {
552
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
552
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
553 553
 		}
554 554
 		if (isset($line['emergency']) && $line['emergency'] != '') {
555
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
555
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
556 556
 		    //$dataFound = true;
557 557
 		}
558 558
 		if (isset($line['ground']) && $line['ground'] != '') {
559 559
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
560 560
 			// Here we force archive of flight because after ground it's a new one (or should be)
561
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
562
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
563
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
564
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
565
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
561
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
562
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
563
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
564
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
565
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
566 566
 		    }
567 567
 		    if ($line['ground'] != 1) $line['ground'] = 0;
568
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
568
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
569 569
 		    //$dataFound = true;
570 570
 		}
571 571
 		if (isset($line['squawk']) && $line['squawk'] != '') {
572 572
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
573 573
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
574
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
574
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
575 575
 			    $highlight = '';
576 576
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
577 577
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -580,47 +580,47 @@  discard block
 block discarded – undo
580 580
 				$timeelapsed = microtime(true);
581 581
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
582 582
 				    $Spotter = new Spotter($this->db);
583
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
583
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
584 584
 				    $Spotter->db = null;
585
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
585
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
586 586
 				}
587 587
 				//$putinarchive = true;
588 588
 				//$highlight = '';
589 589
 			    }
590 590
 			    
591
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
591
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
592 592
 		    //$dataFound = true;
593 593
 		}
594 594
 
595 595
 		if (isset($line['altitude']) && $line['altitude'] != '') {
596 596
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
597
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
598
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
599
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
597
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
598
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
599
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
600 600
 			//$dataFound = true;
601 601
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
602 602
   		}
603 603
 
604 604
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
605
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
605
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
606 606
 		}
607 607
 		
608 608
 		if (isset($line['heading']) && $line['heading'] != '') {
609
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
610
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
611
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
609
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
610
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
611
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
612 612
 		    //$dataFound = true;
613 613
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
614
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
615
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
616
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
614
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
615
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
616
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
617 617
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
618 618
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
619 619
   		    // If not enough messages and ACARS set heading to 0
620
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
620
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
621 621
   		}
622
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
623
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
622
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
623
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
624 624
 
625 625
 //		print_r($this->all_flights[$id]);
626 626
 		//gets the callsign from the last hour
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
631 631
 		    $this->all_flights[$id]['lastupdate'] = time();
632 632
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
633
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
633
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
634 634
 			    //print_r($this->all_flights);
635 635
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
636 636
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -641,61 +641,61 @@  discard block
 block discarded – undo
641 641
 				    $SpotterLive = new SpotterLive($this->db);
642 642
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
643 643
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
644
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
644
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
645 645
 				    } elseif (isset($line['id'])) {
646 646
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
647
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
647
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
648 648
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
649 649
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
650
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
650
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
651 651
 				    } else $recent_ident = '';
652
-				    $SpotterLive->db=null;
652
+				    $SpotterLive->db = null;
653 653
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
654 654
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
655 655
 				} else $recent_ident = '';
656 656
 			    } else {
657 657
 				$recent_ident = '';
658
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
658
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
659 659
 			    }
660 660
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
661
-			    if($recent_ident == "")
661
+			    if ($recent_ident == "")
662 662
 			    {
663 663
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
664 664
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
665 665
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
666 666
 				//adds the spotter data for the archive
667 667
 				$ignoreImport = false;
668
-				foreach($globalAirportIgnore as $airportIgnore) {
668
+				foreach ($globalAirportIgnore as $airportIgnore) {
669 669
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
670 670
 					$ignoreImport = true;
671 671
 				    }
672 672
 				}
673 673
 				if (count($globalAirportAccept) > 0) {
674 674
 				    $ignoreImport = true;
675
-				    foreach($globalAirportIgnore as $airportIgnore) {
675
+				    foreach ($globalAirportIgnore as $airportIgnore) {
676 676
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
677 677
 					    $ignoreImport = false;
678 678
 					}
679 679
 				    }
680 680
 				}
681 681
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
682
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
683
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
682
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
683
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
684 684
 					    $ignoreImport = true;
685 685
 					}
686 686
 				    }
687 687
 				}
688 688
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
689 689
 				    $ignoreImport = true;
690
-				    foreach($globalAirlineAccept as $airlineAccept) {
691
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
690
+				    foreach ($globalAirlineAccept as $airlineAccept) {
691
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
692 692
 					    $ignoreImport = false;
693 693
 					}
694 694
 				    }
695 695
 				}
696 696
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
697 697
 				    $ignoreImport = true;
698
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
698
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
699 699
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
700 700
 					    $ignoreImport = false;
701 701
 					}
@@ -707,32 +707,32 @@  discard block
 block discarded – undo
707 707
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
708 708
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
709 709
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
710
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
710
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
711 711
 				    $timeelapsed = microtime(true);
712 712
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
713 713
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
714 714
 					    $Spotter = new Spotter($this->db);
715
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
715
+					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']);
716 716
 					    $Spotter->db = null;
717 717
 					    if ($globalDebug && isset($result)) echo $result."\n";
718 718
 					}
719 719
 				    }
720
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
720
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
721 721
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
722 722
 
723 723
 				    // Add source stat in DB
724 724
 				    $Stats = new Stats($this->db);
725 725
 				    if (!empty($this->stats)) {
726 726
 					if ($globalDebug) echo 'Add source stats : ';
727
-				        foreach($this->stats as $date => $data) {
728
-					    foreach($data as $source => $sourced) {
727
+				        foreach ($this->stats as $date => $data) {
728
+					    foreach ($data as $source => $sourced) {
729 729
 					        //print_r($sourced);
730
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
731
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
730
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
731
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
732 732
 				    		if (isset($sourced['msg'])) {
733 733
 				    		    if (time() - $sourced['msg']['date'] > 10) {
734 734
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
735
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
735
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
736 736
 			    			        unset($this->stats[$date][$source]['msg']);
737 737
 			    			    }
738 738
 			    			}
@@ -770,14 +770,14 @@  discard block
 block discarded – undo
770 770
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
771 771
 					    $SpotterLive = new SpotterLive($this->db);
772 772
 					    $SpotterLive->deleteLiveSpotterData();
773
-					    $SpotterLive->db=null;
773
+					    $SpotterLive->db = null;
774 774
 					}
775 775
 				    }
776 776
 				    if ($globalDebug) echo " Done\n";
777 777
 				    $this->last_delete = time();
778 778
 				}
779 779
 			    } else {
780
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
780
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
781 781
 				    $this->all_flights[$id]['id'] = $recent_ident;
782 782
 				    $this->all_flights[$id]['addedSpotter'] = 1;
783 783
 				}
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
786 786
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
787 787
 					    $Spotter = new Spotter($this->db);
788
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
788
+					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
789 789
 					    $Spotter->db = null;
790 790
 					}
791 791
 				    }
@@ -811,37 +811,37 @@  discard block
 block discarded – undo
811 811
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
812 812
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
813 813
 
814
-		    foreach($globalAirportIgnore as $airportIgnore) {
814
+		    foreach ($globalAirportIgnore as $airportIgnore) {
815 815
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
816 816
 			    $ignoreImport = true;
817 817
 			}
818 818
 		    }
819 819
 		    if (count($globalAirportAccept) > 0) {
820 820
 		        $ignoreImport = true;
821
-		        foreach($globalAirportIgnore as $airportIgnore) {
821
+		        foreach ($globalAirportIgnore as $airportIgnore) {
822 822
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
823 823
 				$ignoreImport = false;
824 824
 			    }
825 825
 			}
826 826
 		    }
827 827
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
828
-			foreach($globalAirlineIgnore as $airlineIgnore) {
829
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
828
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
829
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
830 830
 				$ignoreImport = true;
831 831
 			    }
832 832
 			}
833 833
 		    }
834 834
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
835 835
 			$ignoreImport = true;
836
-			foreach($globalAirlineAccept as $airlineAccept) {
837
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
836
+			foreach ($globalAirlineAccept as $airlineAccept) {
837
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
838 838
 				$ignoreImport = false;
839 839
 			    }
840 840
 			}
841 841
 		    }
842 842
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
843 843
 			$ignoreImport = true;
844
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
844
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
845 845
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
846 846
 			        $ignoreImport = false;
847 847
 			    }
@@ -849,23 +849,23 @@  discard block
 block discarded – undo
849 849
 		    }
850 850
 
851 851
 		    if (!$ignoreImport) {
852
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
853
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
852
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
853
+				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
854 854
 				$timeelapsed = microtime(true);
855 855
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
856 856
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
857 857
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
858 858
 					$SpotterLive = new SpotterLive($this->db);
859
-					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
859
+					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
860 860
 					$SpotterLive->db = null;
861 861
 					if ($globalDebug) echo $result."\n";
862 862
 				    }
863 863
 				}
864 864
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
865
-					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
865
+					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
866 866
 				}
867 867
 				$this->all_flights[$id]['putinarchive'] = false;
868
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
868
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
869 869
 
870 870
 				// Put statistics in $this->stats variable
871 871
 				//if ($line['format_source'] != 'aprs') {
@@ -884,19 +884,19 @@  discard block
 block discarded – undo
884 884
 							$latitude = $globalCenterLatitude;
885 885
 							$longitude = $globalCenterLongitude;
886 886
 						}
887
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
887
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
888 888
 					} else {
889 889
 						$latitude = $this->source_location[$source]['latitude'];
890 890
 						$longitude = $this->source_location[$source]['longitude'];
891 891
 					}
892
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
892
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
893 893
 					//$stats_heading = $stats_heading%22.5;
894 894
 					$stats_heading = round($stats_heading/22.5);
895
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
895
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
896 896
 					$current_date = date('Y-m-d');
897 897
 					if ($stats_heading == 16) $stats_heading = 0;
898 898
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
899
-						for ($i=0;$i<=15;$i++) {
899
+						for ($i = 0; $i <= 15; $i++) {
900 900
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
901 901
 						}
902 902
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -911,9 +911,9 @@  discard block
 block discarded – undo
911 911
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
912 912
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
913 913
 						    end($this->stats[$current_date][$source]['hist']);
914
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
914
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
915 915
 						} else $mini = 0;
916
-						for ($i=$mini;$i<=$distance;$i+=10) {
916
+						for ($i = $mini; $i <= $distance; $i += 10) {
917 917
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
918 918
 						}
919 919
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 				$this->all_flights[$id]['lastupdate'] = time();
927 927
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
928 928
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
929
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
929
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
930 930
 			//$this->del();
931 931
 			
932 932
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.
date.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
4 4
 if ($date == '') $date = date('Y-m-d');
5 5
 header('Location: '.$globalURL.'/date/'.$date);
6 6
 ?>
7 7
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/date/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.
accident.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
4 4
 if ($date == '') $date = date('Y-m-d');
5 5
 header('Location: '.$globalURL.'/accident/'.$date);
6 6
 ?>
7 7
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/accident/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.
statistics-fatalities-year.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 print '<div id="chart" class="chart" width="100%"></div><script>';
20 20
 $year_data = '';
21 21
 $year_cnt = '';
22
-foreach($date_array as $year_item)
22
+foreach ($date_array as $year_item)
23 23
 {
24 24
 	$year_data .= '"'.$year_item['year'].'-01-01",';
25 25
 	$year_cnt .= $year_item['count'].',';
26 26
 }
27 27
 $year_data = "['x',".substr($year_data, 0, -1)."]";
28
-$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
28
+$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
29 29
 print 'c3.generate({
30 30
     bindto: "#chart",
31 31
     data: { x: "x",
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 
36 36
 if (!empty($date_array))
37 37
 {
38
-	foreach($date_array as $key => $row) {
38
+	foreach ($date_array as $key => $row) {
39 39
 		$years[$key] = $row['year'];
40 40
 		$counts[$key] = $row['count'];
41 41
 	}
42 42
 	//array_multisort($years,SORT_DESC,$date_array);
43
-	array_multisort($counts,SORT_DESC,$date_array);
43
+	array_multisort($counts, SORT_DESC, $date_array);
44 44
 	print '<div class="table-responsive">';
45 45
 	print '<table class="common-date table-striped">';
46 46
 	print '<thead>';
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	print '</thead>';
51 51
 	print '<tbody>';
52 52
 	$i = 1;
53
-	foreach($date_array as $date_item)
53
+	foreach ($date_array as $date_item)
54 54
 	{
55 55
 		print '<tr>';
56 56
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
statistics-route-airport.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 $route_array = $Spotter->countAllRoutes();
19 19
 print '<div id="chart" class="chart" width="100%"></div><script>';
20 20
 $route_data = '';
21
-foreach($route_array as $route_item)
21
+foreach ($route_array as $route_item)
22 22
 {
23 23
 	$route_data .= '[ "'.$route_item['airport_departure_icao'].' - '.$route_item['airport_arrival_icao'].'",'.$route_item['route_count'].'],';
24 24
 }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	print '</thead>';
47 47
 	print '<tbody>';
48 48
 	$i = 1;
49
-	foreach($route_array as $route_item)
49
+	foreach ($route_array as $route_item)
50 50
 	{
51 51
 		print '<tr>';
52 52
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 $title = _("Statistics").' - '._("Most common Route by Airport");
7 7
 require_once('header.php');
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 include('statistics-sub-menu.php'); 
10 12
 
11 13
 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
Please login to merge, or discard this patch.
statistics.php 3 patches
Braces   +103 added lines, -42 removed lines patch added patch discarded remove patch
@@ -6,11 +6,15 @@  discard block
 block discarded – undo
6 6
 $beginpage = microtime(true);
7 7
 $Stats = new Stats();
8 8
 
9
-if (!isset($filter_name)) $filter_name = '';
9
+if (!isset($filter_name)) {
10
+	$filter_name = '';
11
+}
10 12
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11 13
 if ($airline_icao == '' && isset($globalFilter)) {
12
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13
-}
14
+	if (isset($globalFilter['airline'])) {
15
+		$airline_icao = $globalFilter['airline'][0];
16
+	}
17
+	}
14 18
 if ($airline_icao != '' && $airline_icao != 'all') {
15 19
 	$Spotter = new Spotter();
16 20
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -41,14 +45,21 @@  discard block
 block discarded – undo
41 45
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
42 46
 <div class="column">
43 47
     <div class="info">
44
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
48
+            <h1><?php if (isset($airline_name)) {
49
+	echo _("Statistics for ").$airline_name;
50
+} else {
51
+	echo _("Statistics");
52
+}
53
+?></h1>
45 54
     <?php 
46 55
 	$last_update = $Stats->getLastStatsUpdate();
47 56
 	//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
48 57
 	if (isset($last_update[0]['value'])) {
49 58
 		date_default_timezone_set('UTC');
50 59
 		$lastupdate = strtotime($last_update[0]['value']);
51
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
60
+		if (isset($globalTimezone) && $globalTimezone != '') {
61
+			date_default_timezone_set($globalTimezone);
62
+		}
52 63
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
53 64
 	}
54 65
     ?>
@@ -100,8 +111,9 @@  discard block
 block discarded – undo
100 111
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
101 112
                  <?php
102 113
                   $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
103
-		    if (count($aircraft_array) == 0) print _("No data available");
104
-		    else {
114
+		    if (count($aircraft_array) == 0) {
115
+		    	print _("No data available");
116
+		    } else {
105 117
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
106 118
                     $aircraft_data = '';
107 119
                     foreach($aircraft_array as $aircraft_item)
@@ -123,11 +135,17 @@  discard block
 block discarded – undo
123 135
             	    <?php
124 136
             		if ($year != '' && $month != '') {
125 137
             	    ?>
126
-            	    <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>
138
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
139
+	echo '/'.$airline_icao;
140
+}
141
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
127 142
             	    <?php
128 143
             		} else {
129 144
             	    ?>
130
-            	    <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>
145
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
146
+	echo '/'.$airline_icao;
147
+}
148
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
131 149
             	    <?php
132 150
             		}
133 151
             	    ?>
@@ -158,11 +176,15 @@  discard block
 block discarded – undo
158 176
             print '</script>';
159 177
 	    if ($year != '' && $month != '') {
160 178
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
161
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
179
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
180
+			echo '/'.$airline_icao;
181
+		}
162 182
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
163 183
 	    } else {
164 184
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
165
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
185
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
186
+			echo '/'.$airline_icao;
187
+		}
166 188
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
167 189
 	    }
168 190
     	    print '</div>';
@@ -186,8 +208,9 @@  discard block
 block discarded – undo
186 208
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
187 209
 <?php
188 210
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
189
-	if (count($pilot_array) == 0) print _("No data available");
190
-	else {
211
+	if (count($pilot_array) == 0) {
212
+		print _("No data available");
213
+	} else {
191 214
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
192 215
 	    $pilot_data = '';
193 216
 	    foreach($pilot_array as $pilot_item)
@@ -206,7 +229,9 @@  discard block
 block discarded – undo
206 229
         }
207 230
         print '<div class="more">';
208 231
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
209
-	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
+	}
210 235
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
211 236
 	print '</div>';
212 237
 ?>
@@ -220,8 +245,9 @@  discard block
 block discarded – undo
220 245
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
221 246
 <?php
222 247
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
223
-	if (count($owner_array) == 0) print _("No data available");
224
-	else {
248
+	if (count($owner_array) == 0) {
249
+		print _("No data available");
250
+	} else {
225 251
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
226 252
 	    $owner_data = '';
227 253
 	    foreach($owner_array as $owner_item)
@@ -240,7 +266,10 @@  discard block
 block discarded – undo
240 266
 	}
241 267
 ?>
242 268
                 <div class="more">
243
-                    <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>
269
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
270
+	echo '/'.$airline_icao;
271
+}
272
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
244 273
                 </div>
245 274
             </div>
246 275
         
@@ -253,8 +282,9 @@  discard block
 block discarded – undo
253 282
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
254 283
 <?php
255 284
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
256
-	if (count($flightover_array) == 0) print _("No data available");
257
-	else {
285
+	if (count($flightover_array) == 0) {
286
+		print _("No data available");
287
+	} else {
258 288
 	    print '<div id="chart10" class="chart" width="100%"></div><script>';
259 289
 	    print 'var series = [';
260 290
             $flightover_data = '';
@@ -297,7 +327,10 @@  discard block
 block discarded – undo
297 327
 	}
298 328
 ?>
299 329
                 <div class="more">
300
-                    <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>
330
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
331
+	echo '/'.$airline_icao;
332
+}
333
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
301 334
                 </div>
302 335
             </div>
303 336
 <?php
@@ -364,7 +397,9 @@  discard block
 block discarded – undo
364 397
 	print '</script>';
365 398
 
366 399
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
367
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
400
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
401
+		echo '/'.$airline_icao;
402
+	}
368 403
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
369 404
     }
370 405
 ?>
@@ -427,7 +462,9 @@  discard block
 block discarded – undo
427 462
 
428 463
 
429 464
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
430
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
465
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
466
+		echo '/'.$airline_icao;
467
+	}
431 468
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
432 469
     }
433 470
 ?>
@@ -442,8 +479,9 @@  discard block
 block discarded – undo
442 479
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
443 480
                 <?php
444 481
                   $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
445
-		    if (count($year_array) == 0) print _("No data available");
446
-		    else {
482
+		    if (count($year_array) == 0) {
483
+		    	print _("No data available");
484
+		    } else {
447 485
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
448 486
 			$year_data = '';
449 487
 			$year_cnt = '';
@@ -463,7 +501,10 @@  discard block
 block discarded – undo
463 501
                     }
464 502
                   ?>
465 503
                 <div class="more">
466
-                    <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>
504
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
505
+	echo '/'.$airline_icao;
506
+}
507
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
467 508
                 </div>
468 509
             </div>
469 510
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -471,8 +512,9 @@  discard block
 block discarded – undo
471 512
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
472 513
                 <?php
473 514
                   $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
474
-		    if (count($month_array) == 0) print _("No data available");
475
-		    else {
515
+		    if (count($month_array) == 0) {
516
+		    	print _("No data available");
517
+		    } else {
476 518
                 	print '<div id="chart9" class="chart" width="100%"></div><script>';
477 519
                         $month_data = '';
478 520
 			$month_cnt = '';
@@ -493,7 +535,10 @@  discard block
 block discarded – undo
493 535
                     }
494 536
                   ?>
495 537
                 <div class="more">
496
-                    <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>
538
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
539
+	echo '/'.$airline_icao;
540
+}
541
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 542
                 </div>
498 543
             </div>
499 544
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -502,8 +547,9 @@  discard block
 block discarded – undo
502 547
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
503 548
                 <?php
504 549
                     $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
505
-		    if (empty($date_array)) print _("No data available");
506
-		    else {
550
+		    if (empty($date_array)) {
551
+		    	print _("No data available");
552
+		    } else {
507 553
                 	print '<div id="chart5" class="chart" width="100%"></div><script>';
508 554
                         $date_data = '';
509 555
 			$date_cnt = '';
@@ -524,7 +570,10 @@  discard block
 block discarded – undo
524 570
                     }
525 571
                   ?>
526 572
                 <div class="more">
527
-                    <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>
573
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
574
+	echo '/'.$airline_icao;
575
+}
576
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
528 577
                 </div>
529 578
             </div>
530 579
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -532,8 +581,9 @@  discard block
 block discarded – undo
532 581
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
533 582
                 <?php
534 583
                   $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
535
-		    if (empty($hour_array)) print _("No data available");
536
-		    else {
584
+		    if (empty($hour_array)) {
585
+		    	print _("No data available");
586
+		    } else {
537 587
                 	print '<div id="chart6" class="chart" width="100%"></div><script>';
538 588
                         $hour_data = '';
539 589
 			$hour_cnt = '';
@@ -554,7 +604,10 @@  discard block
 block discarded – undo
554 604
                   }
555 605
                 ?>
556 606
                 <div class="more">
557
-                    <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>
607
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
608
+	echo '/'.$airline_icao;
609
+}
610
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
558 611
                 </div>
559 612
             </div>
560 613
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -571,8 +624,9 @@  discard block
 block discarded – undo
571 624
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
572 625
                 <?php
573 626
                   $year_array = $Stats->countFatalitiesByYear();
574
-		    if (count($year_array) == 0) print _("No data available");
575
-		    else {
627
+		    if (count($year_array) == 0) {
628
+		    	print _("No data available");
629
+		    } else {
576 630
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
577 631
                         $year_data = '';
578 632
 			$year_cnt = '';
@@ -603,8 +657,9 @@  discard block
 block discarded – undo
603 657
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
604 658
                 <?php
605 659
                   $year_array = $Stats->countFatalitiesLast12Months();
606
-		    if (count($year_array) == 0) print _("No data available");
607
-		    else {
660
+		    if (count($year_array) == 0) {
661
+		    	print _("No data available");
662
+		    } else {
608 663
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
609 664
                         $year_data = '';
610 665
 			$year_cnt = '';
@@ -664,8 +719,11 @@  discard block
 block discarded – undo
664 719
 					$distance = $distance;
665 720
 					$unit = 'km';
666 721
 				}
667
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
668
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
722
+        			if (!isset($polar_data)) {
723
+        				$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
724
+        			} else {
725
+        	    			$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
726
+        	    		}
669 727
         		    }
670 728
         	?>
671 729
             <div class="col-md-6">
@@ -717,8 +775,11 @@  discard block
 block discarded – undo
717 775
         		foreach ($msg as $eachmsg) {
718 776
         		    //$eachmsg = $msg[0];
719 777
         		    $data = $eachmsg['source_data'];
720
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
721
-        		    else $max = 500;
778
+        		    if ($data > 500) {
779
+        		    	$max = (round(($data+100)/100))*100;
780
+        		    } else {
781
+        		    	$max = 500;
782
+        		    }
722 783
         	?>
723 784
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
724 785
         	<script>
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 $Stats = new Stats();
8 8
 
9 9
 if (!isset($filter_name)) $filter_name = '';
10
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
11 11
 if ($airline_icao == '' && isset($globalFilter)) {
12 12
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13 13
 }
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	$title = _("Statistics");
23 23
 }
24 24
 
25
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
26
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
25
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
26
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
27 27
 
28 28
 require_once('header.php');
29 29
 
@@ -49,36 +49,36 @@  discard block
 block discarded – undo
49 49
 		date_default_timezone_set('UTC');
50 50
 		$lastupdate = strtotime($last_update[0]['value']);
51 51
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
52
-		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
52
+		print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
53 53
 	}
54 54
     ?>
55 55
     </div>
56 56
     <?php include('statistics-sub-menu.php'); ?>
57 57
     <p class="global-stats">
58
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
59
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
60
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
61
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
58
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
59
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
60
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
61
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
62 62
 	<?php
63 63
 	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
64 64
 	?>
65
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
66
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
65
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
66
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
67 67
         <?php
68 68
     	    } else {
69 69
     	?>
70
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
71
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
70
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
71
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
72 72
     	<?php
73 73
     	    }
74 74
     	?>
75
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
76
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
75
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
76
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
77 77
         <?php
78 78
     		if ($airline_icao == '') {
79 79
     	?>
80
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
81
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
80
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
81
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
82 82
 	<?php
83 83
 		}
84 84
 	?>
@@ -86,25 +86,25 @@  discard block
 block discarded – undo
86 86
 		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
87 87
 			if ($airline_icao == '' || $airline_icao == 'all') {
88 88
 	?>
89
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
90
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
89
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
90
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
91 91
 	<?php
92 92
 			}
93 93
 		}
94 94
 	?>
95 95
     </p>
96
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
96
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
97 97
     <div class="specific-stats">
98 98
         <div class="row column">
99 99
             <div class="col-md-6">
100 100
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
101 101
                  <?php
102
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
102
+                  $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
103 103
 		    if (count($aircraft_array) == 0) print _("No data available");
104 104
 		    else {
105 105
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
106 106
                     $aircraft_data = '';
107
-                    foreach($aircraft_array as $aircraft_item)
107
+                    foreach ($aircraft_array as $aircraft_item)
108 108
                     {
109 109
                         $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
110 110
                     }
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
             	    ?>
134 134
                 </div>
135 135
             </div>
136
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
136
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
137 137
 <?php
138 138
 //    echo $airline_icao;
139 139
     if ($airline_icao == '' || $airline_icao == 'all') {
140
-	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
140
+	$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
141 141
 	if (count($airline_array) > 0) {
142 142
             print '<div class="col-md-6">';
143 143
 	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
144 144
 	    print '<div id="chart2" class="chart" width="100%"></div><script>';
145 145
 	    $airline_data = '';
146
-	    foreach($airline_array as $airline_item)
146
+	    foreach ($airline_array as $airline_item)
147 147
 	    {
148 148
 		$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
149 149
 	    }
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 	}
170 170
 ?>
171 171
         </div>
172
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
172
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
173 173
 <?php
174 174
     }
175 175
 ?>
176 176
         <div class="row column">
177 177
 <?php
178
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
178
+    $flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
179 179
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
180 180
 	if (empty($flightover_array)) {
181 181
 	    print '<div class="col-md-12">';
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 ?>
186 186
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
187 187
 <?php
188
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
188
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
189 189
 	if (count($pilot_array) == 0) print _("No data available");
190 190
 	else {
191 191
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
192 192
 	    $pilot_data = '';
193
-	    foreach($pilot_array as $pilot_item)
193
+	    foreach ($pilot_array as $pilot_item)
194 194
 	    {
195 195
 		$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
196 196
 	    }
@@ -212,19 +212,19 @@  discard block
 block discarded – undo
212 212
 ?>
213 213
             </div>
214 214
         
215
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
215
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
216 216
 <?php
217 217
     } else {
218 218
 ?>
219 219
             <div class="col-md-6">
220 220
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
221 221
 <?php
222
-	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
222
+	$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
223 223
 	if (count($owner_array) == 0) print _("No data available");
224 224
 	else {
225 225
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
226 226
 	    $owner_data = '';
227
-	    foreach($owner_array as $owner_item)
227
+	    foreach ($owner_array as $owner_item)
228 228
 	    {
229 229
 		$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
230 230
 	    }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                 </div>
245 245
             </div>
246 246
         
247
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
247
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
248 248
 <?php
249 249
     }
250 250
     if (!empty($flightover_array)) {
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	    print '<div id="chart10" class="chart" width="100%"></div><script>';
259 259
 	    print 'var series = [';
260 260
             $flightover_data = '';
261
-	    foreach($flightover_array as $flightover_item)
261
+	    foreach ($flightover_array as $flightover_item)
262 262
 	    {
263 263
 		$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
264 264
 	    }
@@ -304,21 +304,21 @@  discard block
 block discarded – undo
304 304
     }
305 305
 ?>
306 306
         </div>
307
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
307
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
308 308
 
309 309
     	
310 310
         </div>
311 311
         <div class="row column">
312 312
             <div class="col-md-6">
313 313
 <?php
314
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
314
+    $airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
315 315
     if (count($airport_airport_array) > 0) {
316 316
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
317 317
 	print '<div id="chart3" class="chart" width="100%"></div><script>';
318 318
         print "\n";
319 319
         print 'var series = [';
320 320
         $airport_data = '';
321
-	foreach($airport_airport_array as $airport_item)
321
+	foreach ($airport_airport_array as $airport_item)
322 322
 	{
323 323
 		$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
324 324
 	}
@@ -369,18 +369,18 @@  discard block
 block discarded – undo
369 369
     }
370 370
 ?>
371 371
             </div>
372
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
372
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
373 373
 
374 374
             <div class="col-md-6">
375 375
 <?php
376
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
376
+    $airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
377 377
     if (count($airport_airport_array2) > 0) {
378 378
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
379 379
 	print '<div id="chart4" class="chart" width="100%"></div><script>';
380 380
         print "\n";
381 381
         print 'var series = [';
382 382
         $airport_data = '';
383
-	foreach($airport_airport_array2 as $airport_item)
383
+	foreach ($airport_airport_array2 as $airport_item)
384 384
 	{
385 385
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
386 386
 	}
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 ?>
434 434
             </div>
435 435
         </div>
436
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
436
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
437 437
 <?php
438 438
     if ($year == '' && $month == '') {
439 439
 ?>
@@ -441,19 +441,19 @@  discard block
 block discarded – undo
441 441
             <div class="col-md-6">
442 442
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
443 443
                 <?php
444
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
444
+                  $year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
445 445
 		    if (count($year_array) == 0) print _("No data available");
446 446
 		    else {
447 447
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
448 448
 			$year_data = '';
449 449
 			$year_cnt = '';
450
-			foreach($year_array as $year_item)
450
+			foreach ($year_array as $year_item)
451 451
 			{
452 452
 			    $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
453 453
 			    $year_cnt .= $year_item['date_count'].',';
454 454
 			}
455 455
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
456
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
456
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
457 457
 			print 'c3.generate({
458 458
                 	    bindto: "#chart8",
459 459
                 	    data: { x: "x",
@@ -466,23 +466,23 @@  discard block
 block discarded – undo
466 466
                     <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>
467 467
                 </div>
468 468
             </div>
469
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
469
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
470 470
             <div class="col-md-6">
471 471
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
472 472
                 <?php
473
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
473
+                  $month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
474 474
 		    if (count($month_array) == 0) print _("No data available");
475 475
 		    else {
476 476
                 	print '<div id="chart9" class="chart" width="100%"></div><script>';
477 477
                         $month_data = '';
478 478
 			$month_cnt = '';
479
-			foreach($month_array as $month_item)
479
+			foreach ($month_array as $month_item)
480 480
 			{
481 481
 			    $month_data .= '"'.$month_item['date_name'].'",';
482 482
 			    $month_cnt .= $month_item['date_count'].',';
483 483
 			}
484 484
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
485
-			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
485
+			$month_cnt = "['flights',".substr($month_cnt, 0, -1)."]";
486 486
 			print 'c3.generate({
487 487
                 	    bindto: "#chart9",
488 488
                 	    data: { x: "x",
@@ -496,24 +496,24 @@  discard block
 block discarded – undo
496 496
                     <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>
497 497
                 </div>
498 498
             </div>
499
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
499
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
500 500
 
501 501
             <div class="col-md-6">
502 502
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
503 503
                 <?php
504
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
504
+                    $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
505 505
 		    if (empty($date_array)) print _("No data available");
506 506
 		    else {
507 507
                 	print '<div id="chart5" class="chart" width="100%"></div><script>';
508 508
                         $date_data = '';
509 509
 			$date_cnt = '';
510
-			foreach($date_array as $date_item)
510
+			foreach ($date_array as $date_item)
511 511
 			{
512 512
 			    $date_data .= '"'.$date_item['date_name'].'",';
513 513
 			    $date_cnt .= $date_item['date_count'].',';
514 514
 			}
515 515
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
516
-			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
516
+			$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
517 517
 			print 'c3.generate({
518 518
                 	    bindto: "#chart5",
519 519
                 	    data: { x: "x",
@@ -527,23 +527,23 @@  discard block
 block discarded – undo
527 527
                     <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>
528 528
                 </div>
529 529
             </div>
530
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
530
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
531 531
             <div class="col-md-6">
532 532
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
533 533
                 <?php
534
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
534
+                  $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
535 535
 		    if (empty($hour_array)) print _("No data available");
536 536
 		    else {
537 537
                 	print '<div id="chart6" class="chart" width="100%"></div><script>';
538 538
                         $hour_data = '';
539 539
 			$hour_cnt = '';
540
-			foreach($hour_array as $hour_item)
540
+			foreach ($hour_array as $hour_item)
541 541
 			{
542 542
 			    $hour_data .= '"'.$hour_item['hour_name'].':00",';
543 543
 			    $hour_cnt .= $hour_item['hour_count'].',';
544 544
 			}
545 545
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
546
-			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
546
+			$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
547 547
 			print 'c3.generate({
548 548
                 	    bindto: "#chart6",
549 549
                 	    data: {
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
                     <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>
558 558
                 </div>
559 559
             </div>
560
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
560
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
561 561
         </div>
562 562
 <?php
563 563
     }
@@ -576,13 +576,13 @@  discard block
 block discarded – undo
576 576
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
577 577
                         $year_data = '';
578 578
 			$year_cnt = '';
579
-			foreach($year_array as $year_item)
579
+			foreach ($year_array as $year_item)
580 580
 			{
581 581
 			    $year_data .= '"'.$year_item['year'].'-01-01",';
582 582
 			    $year_cnt .= $year_item['count'].',';
583 583
 			}
584 584
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
585
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
585
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
586 586
 			print 'c3.generate({
587 587
                 	    bindto: "#chart32",
588 588
                 	    data: { x: "x",
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
597 597
                 </div>
598 598
             </div>
599
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
599
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
600 600
 
601 601
         <div class="row column">
602 602
             <div class="col-md-6">
@@ -608,13 +608,13 @@  discard block
 block discarded – undo
608 608
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
609 609
                         $year_data = '';
610 610
 			$year_cnt = '';
611
-			foreach($year_array as $year_item)
611
+			foreach ($year_array as $year_item)
612 612
 			{
613 613
 			    $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
614 614
 			    $year_cnt .= $year_item['count'].',';
615 615
 			}
616 616
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
617
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
617
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
618 618
 			print 'c3.generate({
619 619
                 	    bindto: "#chart33",
620 620
                 	    data: { x: "x",
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
628 628
                 </div>
629 629
             </div>
630
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
630
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
631 631
 <br/>
632 632
 <?php
633 633
     }
@@ -640,9 +640,9 @@  discard block
 block discarded – undo
640 640
         	<?php
641 641
         	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
642 642
         	    if ($year == '' && $month == '') {
643
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
643
+		        $polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
644 644
 		    } else {
645
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
645
+        		$polar = $Stats->getStatsSource('polar', $year, $month);
646 646
         	    }
647 647
         	    if (!empty($polar)) {
648 648
             		print '<h2>'._("Coverage pattern").'</h2>';
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         		    unset($polar_data);
651 651
 	        	    $Spotter = new Spotter();
652 652
         		    $data = json_decode($eachpolar['source_data']);
653
-        		    foreach($data as $value => $key) {
653
+        		    foreach ($data as $value => $key) {
654 654
         			$direction = $Spotter->parseDirection(($value*22.5));
655 655
         			$distance = $key;
656 656
         			$unit = 'km';
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
         	?>
671 671
             <div class="col-md-6">
672 672
                 <h4><?php print $eachpolar['source_name']; ?></h4>
673
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
673
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
674 674
         	<script>
675 675
         	    (function() {
676 676
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 		      color: color,
695 695
 		      unit: '<?php echo $unit; ?>'
696 696
 		    };
697
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
697
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
698 698
 		    })();
699 699
 		</script>
700 700
             </div>
@@ -708,22 +708,22 @@  discard block
 block discarded – undo
708 708
         	<?php
709 709
         	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
710 710
         	    if ($year == '' && $month == '') {
711
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
711
+        		$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
712 712
         	    } else {
713
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
713
+        		$msg = $Stats->getStatsSource('msg', $year, $month);
714 714
         	    }
715 715
         	    if (!empty($msg)) {
716 716
             		print '<h2>'._("Messages received").'</h2>';
717 717
         		foreach ($msg as $eachmsg) {
718 718
         		    //$eachmsg = $msg[0];
719 719
         		    $data = $eachmsg['source_data'];
720
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
720
+        		    if ($data > 500) $max = (round(($data + 100)/100))*100;
721 721
         		    else $max = 500;
722 722
         	?>
723
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
723
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
724 724
         	<script>
725 725
 		      var g = new JustGage({
726
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
726
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
727 727
 			    value: <?php echo $data; ?>,
728 728
 			    min: 0,
729 729
 			    max: <?php print $max; ?>,
@@ -745,9 +745,9 @@  discard block
 block discarded – undo
745 745
             <?php
746 746
 		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
747 747
 		if ($year == '' && $month == '') {
748
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
748
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
749 749
 		} else {
750
-			$hist = $Stats->getStatsSource('hist',$year,$month);
750
+			$hist = $Stats->getStatsSource('hist', $year, $month);
751 751
 		}
752 752
 		foreach ($hist as $hists) {
753 753
 			//$hist_data = '';
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 			$source = $hists['source_name'];
757 757
 			$hist_array = json_decode($hists['source_data']);
758 758
 			$unit = 'km';
759
-			foreach($hist_array as $distance => $nb)
759
+			foreach ($hist_array as $distance => $nb)
760 760
 			{
761 761
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
762 762
 					$distance = round($distance*0.539957);
@@ -777,18 +777,18 @@  discard block
 block discarded – undo
777 777
 			$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
778 778
             ?>
779 779
             <div class="col-md-6">
780
-                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
780
+                <h2><?php echo sprintf(_("Flights Distance for %s"), $source); ?></h2>
781 781
                 <?php
782
-                    print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
782
+                    print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>';
783 783
 		    print 'c3.generate({
784
-			bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
784
+			bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'",
785 785
 			data: { x: "x",
786 786
 			columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
787 787
 			axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
788 788
 		    print '</script>';
789 789
         	?>
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
                 ?>
Please login to merge, or discard this patch.
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
52 52
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
53 53
 	}
54
-    ?>
54
+	?>
55 55
     </div>
56 56
     <?php include('statistics-sub-menu.php'); ?>
57 57
     <p class="global-stats">
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
         <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
61 61
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
62 62
 	<?php
63
-	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
63
+		if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
64 64
 	?>
65 65
     	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
66 66
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
67 67
         <?php
68
-    	    } else {
69
-    	?>
68
+			} else {
69
+		?>
70 70
     	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
71 71
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
72 72
     	<?php
73
-    	    }
74
-    	?>
73
+			}
74
+		?>
75 75
         <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
76 76
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
77 77
         <?php
78
-    		if ($airline_icao == '') {
79
-    	?>
78
+			if ($airline_icao == '') {
79
+		?>
80 80
         <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
81 81
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
82 82
 	<?php
@@ -99,88 +99,88 @@  discard block
 block discarded – undo
99 99
             <div class="col-md-6">
100 100
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
101 101
                  <?php
102
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
103
-		    if (count($aircraft_array) == 0) print _("No data available");
104
-		    else {
105
-                    print '<div id="chart1" class="chart" width="100%"></div><script>';
106
-                    $aircraft_data = '';
107
-                    foreach($aircraft_array as $aircraft_item)
108
-                    {
109
-                        $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
110
-                    }
111
-                    $aircraft_data = substr($aircraft_data, 0, -1);
112
-		    print 'var series = ['.$aircraft_data.'];';
113
-		    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
114
-		    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
115
-		    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
116
-                    print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
117
-                    print 'dataset';
118
-                    print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
119
-                    print '</script>';
120
-                  }
121
-                  ?>
102
+				  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
103
+			if (count($aircraft_array) == 0) print _("No data available");
104
+			else {
105
+					print '<div id="chart1" class="chart" width="100%"></div><script>';
106
+					$aircraft_data = '';
107
+					foreach($aircraft_array as $aircraft_item)
108
+					{
109
+						$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
110
+					}
111
+					$aircraft_data = substr($aircraft_data, 0, -1);
112
+			print 'var series = ['.$aircraft_data.'];';
113
+			print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
114
+			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
115
+			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
116
+					print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
117
+					print 'dataset';
118
+					print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
119
+					print '</script>';
120
+				  }
121
+				  ?>
122 122
                 <div class="more">
123 123
             	    <?php
124
-            		if ($year != '' && $month != '') {
125
-            	    ?>
124
+					if ($year != '' && $month != '') {
125
+					?>
126 126
             	    <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>
127 127
             	    <?php
128
-            		} else {
129
-            	    ?>
128
+					} else {
129
+					?>
130 130
             	    <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>
131 131
             	    <?php
132
-            		}
133
-            	    ?>
132
+					}
133
+					?>
134 134
                 </div>
135 135
             </div>
136 136
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
137 137
 <?php
138 138
 //    echo $airline_icao;
139
-    if ($airline_icao == '' || $airline_icao == 'all') {
139
+	if ($airline_icao == '' || $airline_icao == 'all') {
140 140
 	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
141 141
 	if (count($airline_array) > 0) {
142
-            print '<div class="col-md-6">';
143
-	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
144
-	    print '<div id="chart2" class="chart" width="100%"></div><script>';
145
-	    $airline_data = '';
146
-	    foreach($airline_array as $airline_item)
147
-	    {
142
+			print '<div class="col-md-6">';
143
+		print '<h2>'._("Top 10 Most Common Airline").'</h2>';
144
+		print '<div id="chart2" class="chart" width="100%"></div><script>';
145
+		$airline_data = '';
146
+		foreach($airline_array as $airline_item)
147
+		{
148 148
 		$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
149
-	    }
150
-	    $airline_data = substr($airline_data, 0, -1);
151
-	    print 'var series = ['.$airline_data.'];';
152
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
153
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
154
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
155
-            print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
156
-	    print 'dataset';
157
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
158
-            print '</script>';
159
-	    if ($year != '' && $month != '') {
149
+		}
150
+		$airline_data = substr($airline_data, 0, -1);
151
+		print 'var series = ['.$airline_data.'];';
152
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
153
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
154
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
155
+			print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
156
+		print 'dataset';
157
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
158
+			print '</script>';
159
+		if ($year != '' && $month != '') {
160 160
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
161 161
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
162 162
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
163
-	    } else {
163
+		} else {
164 164
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
165 165
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
166 166
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
167
-	    }
168
-    	    print '</div>';
167
+		}
168
+			print '</div>';
169 169
 	}
170 170
 ?>
171 171
         </div>
172 172
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
173 173
 <?php
174
-    }
174
+	}
175 175
 ?>
176 176
         <div class="row column">
177 177
 <?php
178
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
179
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
178
+	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
179
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
180 180
 	if (empty($flightover_array)) {
181
-	    print '<div class="col-md-12">';
181
+		print '<div class="col-md-12">';
182 182
 	} else {
183
-            print '<div class="col-md-6">';
183
+			print '<div class="col-md-6">';
184 184
 	}
185 185
 ?>
186 186
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
189 189
 	if (count($pilot_array) == 0) print _("No data available");
190 190
 	else {
191
-	    print '<div id="chart7" class="chart" width="100%"></div><script>';
192
-	    $pilot_data = '';
193
-	    foreach($pilot_array as $pilot_item)
194
-	    {
191
+		print '<div id="chart7" class="chart" width="100%"></div><script>';
192
+		$pilot_data = '';
193
+		foreach($pilot_array as $pilot_item)
194
+		{
195 195
 		$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
196
-	    }
197
-	    $pilot_data = substr($pilot_data, 0, -1);
198
-	    print 'var series = ['.$pilot_data.'];';
199
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
200
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
201
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
202
-            print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
203
-	    print 'dataset';
204
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
205
-            print '</script>';
206
-        }
207
-        print '<div class="more">';
196
+		}
197
+		$pilot_data = substr($pilot_data, 0, -1);
198
+		print 'var series = ['.$pilot_data.'];';
199
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
200
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
201
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
202
+			print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
203
+		print 'dataset';
204
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
205
+			print '</script>';
206
+		}
207
+		print '<div class="more">';
208 208
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
209 209
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
210 210
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         
215 215
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
216 216
 <?php
217
-    } else {
217
+	} else {
218 218
 ?>
219 219
             <div class="col-md-6">
220 220
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
@@ -222,21 +222,21 @@  discard block
 block discarded – undo
222 222
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
223 223
 	if (count($owner_array) == 0) print _("No data available");
224 224
 	else {
225
-	    print '<div id="chart7" class="chart" width="100%"></div><script>';
226
-	    $owner_data = '';
227
-	    foreach($owner_array as $owner_item)
228
-	    {
225
+		print '<div id="chart7" class="chart" width="100%"></div><script>';
226
+		$owner_data = '';
227
+		foreach($owner_array as $owner_item)
228
+		{
229 229
 		$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
230
-	    }
231
-	    $owner_data = substr($owner_data, 0, -1);
232
-	    print 'var series = ['.$owner_data.'];';
233
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
234
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
235
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
236
-            print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
237
-	    print 'dataset';
238
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
239
-	    print '</script>';
230
+		}
231
+		$owner_data = substr($owner_data, 0, -1);
232
+		print 'var series = ['.$owner_data.'];';
233
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
234
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
235
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
236
+			print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
237
+		print 'dataset';
238
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
239
+		print '</script>';
240 240
 	}
241 241
 ?>
242 242
                 <div class="more">
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
         
247 247
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
248 248
 <?php
249
-    }
250
-    if (!empty($flightover_array)) {
249
+	}
250
+	if (!empty($flightover_array)) {
251 251
 ?>
252 252
             <div class="col-md-6">
253 253
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
@@ -255,20 +255,20 @@  discard block
 block discarded – undo
255 255
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
256 256
 	if (count($flightover_array) == 0) print _("No data available");
257 257
 	else {
258
-	    print '<div id="chart10" class="chart" width="100%"></div><script>';
259
-	    print 'var series = [';
260
-            $flightover_data = '';
261
-	    foreach($flightover_array as $flightover_item)
262
-	    {
258
+		print '<div id="chart10" class="chart" width="100%"></div><script>';
259
+		print 'var series = [';
260
+			$flightover_data = '';
261
+		foreach($flightover_array as $flightover_item)
262
+		{
263 263
 		$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
264
-	    }
265
-	    $flightover_data = substr($flightover_data, 0, -1);
266
-	    print $flightover_data;
267
-	    print '];';
268
-	    print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
269
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
270
-	    print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
271
-	    print 'new Datamap({
264
+		}
265
+		$flightover_data = substr($flightover_data, 0, -1);
266
+		print $flightover_data;
267
+		print '];';
268
+		print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
269
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
270
+		print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
271
+		print 'new Datamap({
272 272
 		element: document.getElementById("chart10"),
273 273
 		projection: "mercator", // big world map
274 274
 		fills: { defaultFill: "#F5F5F5" },
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         	    }
294 294
 		}
295 295
 	    });";
296
-	    print '</script>';
296
+		print '</script>';
297 297
 	}
298 298
 ?>
299 299
                 <div class="more">
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                 </div>
302 302
             </div>
303 303
 <?php
304
-    }
304
+	}
305 305
 ?>
306 306
         </div>
307 307
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
         <div class="row column">
312 312
             <div class="col-md-6">
313 313
 <?php
314
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
315
-    if (count($airport_airport_array) > 0) {
314
+	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
315
+	if (count($airport_airport_array) > 0) {
316 316
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
317 317
 	print '<div id="chart3" class="chart" width="100%"></div><script>';
318
-        print "\n";
319
-        print 'var series = [';
320
-        $airport_data = '';
318
+		print "\n";
319
+		print 'var series = [';
320
+		$airport_data = '';
321 321
 	foreach($airport_airport_array as $airport_item)
322 322
 	{
323 323
 		$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
367 367
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
368 368
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
369
-    }
369
+	}
370 370
 ?>
371 371
             </div>
372 372
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
373 373
 
374 374
             <div class="col-md-6">
375 375
 <?php
376
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
377
-    if (count($airport_airport_array2) > 0) {
376
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
377
+	if (count($airport_airport_array2) > 0) {
378 378
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
379 379
 	print '<div id="chart4" class="chart" width="100%"></div><script>';
380
-        print "\n";
381
-        print 'var series = [';
382
-        $airport_data = '';
380
+		print "\n";
381
+		print 'var series = [';
382
+		$airport_data = '';
383 383
 	foreach($airport_airport_array2 as $airport_item)
384 384
 	{
385 385
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
@@ -429,28 +429,28 @@  discard block
 block discarded – undo
429 429
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
430 430
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
431 431
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
432
-    }
432
+	}
433 433
 ?>
434 434
             </div>
435 435
         </div>
436 436
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
437 437
 <?php
438
-    if ($year == '' && $month == '') {
438
+	if ($year == '' && $month == '') {
439 439
 ?>
440 440
         <div class="row column">
441 441
             <div class="col-md-6">
442 442
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
443 443
                 <?php
444
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
445
-		    if (count($year_array) == 0) print _("No data available");
446
-		    else {
444
+				  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
445
+			if (count($year_array) == 0) print _("No data available");
446
+			else {
447 447
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
448 448
 			$year_data = '';
449 449
 			$year_cnt = '';
450 450
 			foreach($year_array as $year_item)
451 451
 			{
452
-			    $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
453
-			    $year_cnt .= $year_item['date_count'].',';
452
+				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
453
+				$year_cnt .= $year_item['date_count'].',';
454 454
 			}
455 455
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
456 456
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
                 	     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
461 461
                 	     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});';
462 462
 			print '</script>';
463
-                    }
464
-                  ?>
463
+					}
464
+				  ?>
465 465
                 <div class="more">
466 466
                     <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>
467 467
                 </div>
@@ -470,16 +470,16 @@  discard block
 block discarded – undo
470 470
             <div class="col-md-6">
471 471
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
472 472
                 <?php
473
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
474
-		    if (count($month_array) == 0) print _("No data available");
475
-		    else {
476
-                	print '<div id="chart9" class="chart" width="100%"></div><script>';
477
-                        $month_data = '';
473
+				  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
474
+			if (count($month_array) == 0) print _("No data available");
475
+			else {
476
+					print '<div id="chart9" class="chart" width="100%"></div><script>';
477
+						$month_data = '';
478 478
 			$month_cnt = '';
479 479
 			foreach($month_array as $month_item)
480 480
 			{
481
-			    $month_data .= '"'.$month_item['date_name'].'",';
482
-			    $month_cnt .= $month_item['date_count'].',';
481
+				$month_data .= '"'.$month_item['date_name'].'",';
482
+				$month_cnt .= $month_item['date_count'].',';
483 483
 			}
484 484
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
485 485
 			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
                 	     columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
490 490
                 	     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
491 491
 			
492
-            		print '</script>';
493
-                    }
494
-                  ?>
492
+					print '</script>';
493
+					}
494
+				  ?>
495 495
                 <div class="more">
496 496
                     <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>
497 497
                 </div>
@@ -501,16 +501,16 @@  discard block
 block discarded – undo
501 501
             <div class="col-md-6">
502 502
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
503 503
                 <?php
504
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
505
-		    if (empty($date_array)) print _("No data available");
506
-		    else {
507
-                	print '<div id="chart5" class="chart" width="100%"></div><script>';
508
-                        $date_data = '';
504
+					$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
505
+			if (empty($date_array)) print _("No data available");
506
+			else {
507
+					print '<div id="chart5" class="chart" width="100%"></div><script>';
508
+						$date_data = '';
509 509
 			$date_cnt = '';
510 510
 			foreach($date_array as $date_item)
511 511
 			{
512
-			    $date_data .= '"'.$date_item['date_name'].'",';
513
-			    $date_cnt .= $date_item['date_count'].',';
512
+				$date_data .= '"'.$date_item['date_name'].'",';
513
+				$date_cnt .= $date_item['date_count'].',';
514 514
 			}
515 515
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
516 516
 			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
@@ -520,9 +520,9 @@  discard block
 block discarded – undo
520 520
                 	     columns: ['.$date_data.','.$date_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
521 521
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
522 522
 			
523
-                	print '</script>';
524
-                    }
525
-                  ?>
523
+					print '</script>';
524
+					}
525
+				  ?>
526 526
                 <div class="more">
527 527
                     <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>
528 528
                 </div>
@@ -531,16 +531,16 @@  discard block
 block discarded – undo
531 531
             <div class="col-md-6">
532 532
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
533 533
                 <?php
534
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
535
-		    if (empty($hour_array)) print _("No data available");
536
-		    else {
537
-                	print '<div id="chart6" class="chart" width="100%"></div><script>';
538
-                        $hour_data = '';
534
+				  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
535
+			if (empty($hour_array)) print _("No data available");
536
+			else {
537
+					print '<div id="chart6" class="chart" width="100%"></div><script>';
538
+						$hour_data = '';
539 539
 			$hour_cnt = '';
540 540
 			foreach($hour_array as $hour_item)
541 541
 			{
542
-			    $hour_data .= '"'.$hour_item['hour_name'].':00",';
543
-			    $hour_cnt .= $hour_item['hour_count'].',';
542
+				$hour_data .= '"'.$hour_item['hour_name'].':00",';
543
+				$hour_cnt .= $hour_item['hour_count'].',';
544 544
 			}
545 545
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
546 546
 			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
                 	     columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
551 551
                 	     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
552 552
 
553
-            	     print '</script>';
554
-                  }
555
-                ?>
553
+					 print '</script>';
554
+				  }
555
+				?>
556 556
                 <div class="more">
557 557
                     <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>
558 558
                 </div>
@@ -560,26 +560,26 @@  discard block
 block discarded – undo
560 560
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
561 561
         </div>
562 562
 <?php
563
-    }
563
+	}
564 564
 ?>
565 565
 
566 566
 <?php
567
-    if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
567
+	if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
568 568
 ?>
569 569
         <div class="row column">
570 570
             <div class="col-md-6">
571 571
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
572 572
                 <?php
573
-                  $year_array = $Stats->countFatalitiesByYear();
574
-		    if (count($year_array) == 0) print _("No data available");
575
-		    else {
573
+				  $year_array = $Stats->countFatalitiesByYear();
574
+			if (count($year_array) == 0) print _("No data available");
575
+			else {
576 576
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
577
-                        $year_data = '';
577
+						$year_data = '';
578 578
 			$year_cnt = '';
579 579
 			foreach($year_array as $year_item)
580 580
 			{
581
-			    $year_data .= '"'.$year_item['year'].'-01-01",';
582
-			    $year_cnt .= $year_item['count'].',';
581
+				$year_data .= '"'.$year_item['year'].'-01-01",';
582
+				$year_cnt .= $year_item['count'].',';
583 583
 			}
584 584
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
585 585
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
591 591
 
592 592
 			print '</script>';
593
-		    }
594
-                  ?>
593
+			}
594
+				  ?>
595 595
                 <div class="more">
596 596
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
597 597
                 </div>
@@ -602,16 +602,16 @@  discard block
 block discarded – undo
602 602
             <div class="col-md-6">
603 603
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
604 604
                 <?php
605
-                  $year_array = $Stats->countFatalitiesLast12Months();
606
-		    if (count($year_array) == 0) print _("No data available");
607
-		    else {
605
+				  $year_array = $Stats->countFatalitiesLast12Months();
606
+			if (count($year_array) == 0) print _("No data available");
607
+			else {
608 608
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
609
-                        $year_data = '';
609
+						$year_data = '';
610 610
 			$year_cnt = '';
611 611
 			foreach($year_array as $year_item)
612 612
 			{
613
-			    $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
614
-			    $year_cnt .= $year_item['count'].',';
613
+				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
614
+				$year_cnt .= $year_item['count'].',';
615 615
 			}
616 616
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
617 617
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -621,8 +621,8 @@  discard block
 block discarded – undo
621 621
                 	     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
622 622
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y-%m"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
623 623
 			print '</script>';
624
-		    }
625
-                  ?>
624
+			}
625
+				  ?>
626 626
                 <div class="more">
627 627
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
628 628
                 </div>
@@ -630,30 +630,30 @@  discard block
 block discarded – undo
630 630
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
631 631
 <br/>
632 632
 <?php
633
-    }
633
+	}
634 634
 ?>
635 635
 
636 636
 <?php
637
-    if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
637
+	if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
638 638
 ?>
639 639
         <div class="row column">
640 640
         	<?php
641
-        	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
642
-        	    if ($year == '' && $month == '') {
643
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
644
-		    } else {
645
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
646
-        	    }
647
-        	    if (!empty($polar)) {
648
-            		print '<h2>'._("Coverage pattern").'</h2>';
649
-        		foreach ($polar as $eachpolar) {
650
-        		    unset($polar_data);
651
-	        	    $Spotter = new Spotter();
652
-        		    $data = json_decode($eachpolar['source_data']);
653
-        		    foreach($data as $value => $key) {
654
-        			$direction = $Spotter->parseDirection(($value*22.5));
655
-        			$distance = $key;
656
-        			$unit = 'km';
641
+				//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
642
+				if ($year == '' && $month == '') {
643
+				$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
644
+			} else {
645
+				$polar = $Stats->getStatsSource('polar',$year,$month);
646
+				}
647
+				if (!empty($polar)) {
648
+					print '<h2>'._("Coverage pattern").'</h2>';
649
+				foreach ($polar as $eachpolar) {
650
+					unset($polar_data);
651
+					$Spotter = new Spotter();
652
+					$data = json_decode($eachpolar['source_data']);
653
+					foreach($data as $value => $key) {
654
+					$direction = $Spotter->parseDirection(($value*22.5));
655
+					$distance = $key;
656
+					$unit = 'km';
657 657
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
658 658
 					$distance = round($distance*0.539957);
659 659
 					$unit = 'nm';
@@ -664,10 +664,10 @@  discard block
 block discarded – undo
664 664
 					$distance = $distance;
665 665
 					$unit = 'km';
666 666
 				}
667
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
668
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
669
-        		    }
670
-        	?>
667
+					if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
668
+						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
669
+					}
670
+			?>
671 671
             <div class="col-md-6">
672 672
                 <h4><?php print $eachpolar['source_name']; ?></h4>
673 673
         	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
@@ -699,27 +699,27 @@  discard block
 block discarded – undo
699 699
 		</script>
700 700
             </div>
701 701
             <?php
702
-        	    }
703
-        	}
704
-            ?>
702
+				}
703
+			}
704
+			?>
705 705
         </div>
706 706
         <div class="row column">
707 707
             <div class="col-md-6">
708 708
         	<?php
709
-        	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
710
-        	    if ($year == '' && $month == '') {
711
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
712
-        	    } else {
713
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
714
-        	    }
715
-        	    if (!empty($msg)) {
716
-            		print '<h2>'._("Messages received").'</h2>';
717
-        		foreach ($msg as $eachmsg) {
718
-        		    //$eachmsg = $msg[0];
719
-        		    $data = $eachmsg['source_data'];
720
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
721
-        		    else $max = 500;
722
-        	?>
709
+				//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
710
+				if ($year == '' && $month == '') {
711
+				$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
712
+				} else {
713
+				$msg = $Stats->getStatsSource('msg',$year,$month);
714
+				}
715
+				if (!empty($msg)) {
716
+					print '<h2>'._("Messages received").'</h2>';
717
+				foreach ($msg as $eachmsg) {
718
+					//$eachmsg = $msg[0];
719
+					$data = $eachmsg['source_data'];
720
+					if ($data > 500) $max = (round(($data+100)/100))*100;
721
+					else $max = 500;
722
+			?>
723 723
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
724 724
         	<script>
725 725
 		      var g = new JustGage({
@@ -735,9 +735,9 @@  discard block
 block discarded – undo
735 735
 			  });
736 736
 		</script>
737 737
             <?php
738
-        	   }
739
-        	}
740
-            ?>
738
+			   }
739
+			}
740
+			?>
741 741
             </div>
742 742
         </div>
743 743
         <div class="row column">
@@ -775,26 +775,26 @@  discard block
 block discarded – undo
775 775
 			//$hist_data = substr($hist_data, 0, -1);
776 776
 			$distance_data = "['x',".substr($distance_data, 0, -1)."]";
777 777
 			$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
778
-            ?>
778
+			?>
779 779
             <div class="col-md-6">
780 780
                 <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
781 781
                 <?php
782
-                    print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
783
-		    print 'c3.generate({
782
+					print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
783
+			print 'c3.generate({
784 784
 			bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
785 785
 			data: { x: "x",
786 786
 			columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
787 787
 			axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
788
-		    print '</script>';
789
-        	?>
788
+			print '</script>';
789
+			?>
790 790
     	    </div>
791 791
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
792 792
         	<?php
793
-                  }
794
-                ?>
793
+				  }
794
+				?>
795 795
         </div>
796 796
 <?php
797
-    }
797
+	}
798 798
 ?>
799 799
     </div>
800 800
 </div>  
Please login to merge, or discard this patch.