Completed
Push — master ( 561404...142633 )
by Yannick
08:13
created
date-statistics-arrival-airport-country.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
8
-$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
8
+$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort);
9 9
 
10 10
 if (!empty($spotter_array))
11 11
 {
12
-	$title = sprintf(_("Most Common Arrival Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
12
+	$title = sprintf(_("Most Common Arrival Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
13 13
 	require_once('header.php');
14 14
 	print '<div class="select-item">';
15 15
 	print '<form action="'.$globalURL.'/date" method="post" class="form-inline">';
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 	print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
27 27
 	print '<br />';
28 28
 	print '<div class="info column">';
29
-	print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
29
+	print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
30 30
 	print '</div>';
31 31
 
32 32
 	include('date-sub-menu.php');
33 33
 	print '<div class="column">';
34 34
 	print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
35
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
35
+	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
36 36
 
37 37
 	$airport_country_array = $Spotter->countAllArrivalAirportCountriesByDate($date);
38 38
 	//print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 */
74 74
 	print 'var series = [';
75 75
 	$country_data = '';
76
-	foreach($airport_country_array as $airport_item)
76
+	foreach ($airport_country_array as $airport_item)
77 77
 	{
78 78
 		$country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
79 79
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		print '</thead>';
122 122
 		print '<tbody>';
123 123
 		$i = 1;
124
-		foreach($airport_country_array as $airport_item)
124
+		foreach ($airport_country_array as $airport_item)
125 125
 		{
126 126
 			print '<tr>';
127 127
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
require/class.Common.php 4 patches
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.
Doc Comments   +15 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');
@@ -106,6 +110,9 @@  discard block
 block discarded – undo
106 110
 		fclose($fp);
107 111
 	}
108 112
 
113
+	/**
114
+	 * @param string $in_file
115
+	 */
109 116
 	public static function gunzip($in_file,$out_file_name = '') {
110 117
 		//echo $in_file.' -> '.$out_file_name."\n";
111 118
 		$buffer_size = 4096; // read 4kb at a time
@@ -211,7 +218,7 @@  discard block
 block discarded – undo
211 218
 	* Check is distance realistic
212 219
 	* @param int $timeDifference the time between the reception of both messages
213 220
 	* @param float $distance distance covered
214
-	* @return whether distance is realistic
221
+	* @return boolean distance is realistic
215 222
 	*/
216 223
 	public function withinThreshold ($timeDifference, $distance) {
217 224
 		$x = abs($timeDifference);
@@ -234,6 +241,9 @@  discard block
 block discarded – undo
234 241
 	}
235 242
 
236 243
 
244
+	/**
245
+	 * @param string $latlong
246
+	 */
237 247
 	public function convertDec($dms,$latlong) {
238 248
 		if ($latlong == 'latitude') {
239 249
 			$deg = substr($dms, 0, 2);
@@ -245,6 +255,9 @@  discard block
 block discarded – undo
245 255
 		return $deg+(($min*60)/3600);
246 256
 	}
247 257
 	
258
+	/**
259
+	 * @param string $latlong
260
+	 */
248 261
 	public function convertDM($coord,$latlong) {
249 262
 		if ($latlong == 'latitude') {
250 263
 			if ($coord < 0) $NSEW = 'S';
@@ -382,7 +395,7 @@  discard block
 block discarded – undo
382 395
 	/**
383 396
 	* Returns list of available locales
384 397
 	*
385
-	* @return array
398
+	* @return string[]
386 399
 	 */
387 400
 	public function listLocaleDir()
388 401
 	{
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 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;
@@ -106,20 +106,20 @@  discard block
 block discarded – undo
106 106
 		fclose($fp);
107 107
 	}
108 108
 
109
-	public static function gunzip($in_file,$out_file_name = '') {
109
+	public static function gunzip($in_file, $out_file_name = '') {
110 110
 		//echo $in_file.' -> '.$out_file_name."\n";
111 111
 		$buffer_size = 4096; // read 4kb at a time
112 112
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
113 113
 		if ($in_file != '' && file_exists($in_file)) {
114 114
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
115
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
116
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
115
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
116
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
117 117
 			else {
118 118
 				echo 'gzopen not available';
119 119
 				die;
120 120
 			}
121 121
 			$out_file = fopen($out_file_name, 'wb'); 
122
-			while(!gzeof($file)) {
122
+			while (!gzeof($file)) {
123 123
 				fwrite($out_file, gzread($file, $buffer_size));
124 124
 			}  
125 125
 			fclose($out_file);
@@ -127,19 +127,19 @@  discard block
 block discarded – undo
127 127
 		}
128 128
 	}
129 129
 
130
-	public static function bunzip2($in_file,$out_file_name = '') {
130
+	public static function bunzip2($in_file, $out_file_name = '') {
131 131
 		//echo $in_file.' -> '.$out_file_name."\n";
132 132
 		$buffer_size = 4096; // read 4kb at a time
133 133
 		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
134 134
 		if ($in_file != '' && file_exists($in_file)) {
135 135
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
136
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
136
+			if (function_exists('bzopen')) $file = bzopen($in_file, 'rb');
137 137
 			else {
138 138
 				echo 'bzopen not available';
139 139
 				die;
140 140
 			}
141 141
 			$out_file = fopen($out_file_name, 'wb'); 
142
-			while(!feof($file)) {
142
+			while (!feof($file)) {
143 143
 				fwrite($out_file, bzread($file, $buffer_size));
144 144
 			}  
145 145
 			fclose($out_file);
@@ -157,27 +157,27 @@  discard block
 block discarded – undo
157 157
 		if ($data == '') return array();
158 158
 		$html = str_get_html($data);
159 159
 		if ($html === false) return array();
160
-		$tabledata=array();
161
-		foreach($html->find('tr') as $element)
160
+		$tabledata = array();
161
+		foreach ($html->find('tr') as $element)
162 162
 		{
163 163
 			$td = array();
164
-			foreach( $element->find('th') as $row)
164
+			foreach ($element->find('th') as $row)
165 165
 			{
166 166
 				$td [] = trim($row->plaintext);
167 167
 			}
168
-			$td=array_filter($td);
168
+			$td = array_filter($td);
169 169
 			$tabledata[] = $td;
170 170
 
171 171
 			$td = array();
172 172
 			$tdi = array();
173
-			foreach( $element->find('td') as $row)
173
+			foreach ($element->find('td') as $row)
174 174
 			{
175 175
 				$td [] = trim($row->plaintext);
176 176
 				$tdi [] = trim($row->innertext);
177 177
 			}
178
-			$td=array_filter($td);
179
-			$tdi=array_filter($tdi);
180
-			$tabledata[]=array_merge($td,$tdi);
178
+			$td = array_filter($td);
179
+			$tdi = array_filter($tdi);
180
+			$tabledata[] = array_merge($td, $tdi);
181 181
 		}
182 182
 		$html->clear();
183 183
 		unset($html);
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	public function text2array($data) {
193 193
 		$html = str_get_html($data);
194 194
 		if ($html === false) return array();
195
-		$tabledata=array();
196
-		foreach($html->find('p') as $element)
195
+		$tabledata = array();
196
+		foreach ($html->find('p') as $element)
197 197
 		{
198 198
 			$tabledata [] = trim($element->plaintext);
199 199
 		}
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	*/
214 214
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
215 215
 		if ($lat == $latc && $lon == $lonc) return 0;
216
-		$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;
216
+		$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;
217 217
 		if ($unit == "km") {
218
-			return round($dist * 1.609344);
218
+			return round($dist*1.609344);
219 219
 		} elseif ($unit == "m") {
220
-			return round($dist * 1.609344 * 1000);
220
+			return round($dist*1.609344*1000);
221 221
 		} elseif ($unit == "mile" || $unit == "mi") {
222 222
 			return round($dist);
223 223
 		} elseif ($unit == "nm") {
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	* @param float $distance distance covered
234 234
 	* @return whether distance is realistic
235 235
 	*/
236
-	public function withinThreshold ($timeDifference, $distance) {
236
+	public function withinThreshold($timeDifference, $distance) {
237 237
 		$x = abs($timeDifference);
238 238
 		$d = abs($distance);
239 239
 		if ($x == 0 || $d == 0) return true;
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
 		return ($array !== array_values($array));
250 250
 	}
251 251
 
252
-	public function isInteger($input){
252
+	public function isInteger($input) {
253 253
 	    return(ctype_digit(strval($input)));
254 254
 	}
255 255
 
256 256
 
257
-	public function convertDec($dms,$latlong) {
257
+	public function convertDec($dms, $latlong) {
258 258
 		if ($latlong == 'latitude') {
259 259
 			$deg = substr($dms, 0, 2);
260 260
 			$min = substr($dms, 2, 4);
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
 			$deg = substr($dms, 0, 3);
263 263
 			$min = substr($dms, 3, 5);
264 264
 		}
265
-		return $deg+(($min*60)/3600);
265
+		return $deg + (($min*60)/3600);
266 266
 	}
267 267
 	
268
-	public function convertDM($coord,$latlong) {
268
+	public function convertDM($coord, $latlong) {
269 269
 		if ($latlong == 'latitude') {
270 270
 			if ($coord < 0) $NSEW = 'S';
271 271
 			else $NSEW = 'N';
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 		}
276 276
 		$coord = abs($coord);
277 277
 		$deg = floor($coord);
278
-		$coord = ($coord-$deg)*60;
278
+		$coord = ($coord - $deg)*60;
279 279
 		$min = $coord;
280
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
280
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
281 281
 	}
282 282
 	
283 283
 	/**
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	public function xcopy($source, $dest)
290 290
 	{
291 291
 		$files = glob($source.'*.*');
292
-		foreach($files as $file){
293
-			$file_to_go = str_replace($source,$dest,$file);
292
+		foreach ($files as $file) {
293
+			$file_to_go = str_replace($source, $dest, $file);
294 294
 			copy($file, $file_to_go);
295 295
 		}
296 296
 		return true;
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
 	* @param	String $url url to check
302 302
 	* @return	bool Return true on succes false on failure
303 303
 	*/
304
-	public function urlexist($url){
305
-		$headers=get_headers($url);
306
-		return stripos($headers[0],"200 OK")?true:false;
304
+	public function urlexist($url) {
305
+		$headers = get_headers($url);
306
+		return stripos($headers[0], "200 OK") ? true : false;
307 307
 	}
308 308
 	
309 309
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	public function hex2str($hex) {
315 315
 		$str = '';
316 316
 		$hexln = strlen($hex);
317
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
317
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
318 318
 		return $str;
319 319
 	}
320 320
 	
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	* @return	String Return result
325 325
 	*/
326 326
 	public function hex2rgb($hex) {
327
-		$hex = str_replace('#','',$hex);
327
+		$hex = str_replace('#', '', $hex);
328 328
 		return sscanf($hex, "%02x%02x%02x"); 
329 329
 	}
330 330
 	
@@ -332,33 +332,33 @@  discard block
 block discarded – undo
332 332
 		//difference in longitudinal coordinates
333 333
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
334 334
 		//difference in the phi of latitudinal coordinates
335
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
335
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
336 336
 		//we need to recalculate $dLon if it is greater than pi
337
-		if(abs($dLon) > pi()) {
338
-			if($dLon > 0) {
339
-				$dLon = (2 * pi() - $dLon) * -1;
337
+		if (abs($dLon) > pi()) {
338
+			if ($dLon > 0) {
339
+				$dLon = (2*pi() - $dLon)*-1;
340 340
 			} else {
341
-				$dLon = 2 * pi() + $dLon;
341
+				$dLon = 2*pi() + $dLon;
342 342
 			}
343 343
 		}
344 344
 		//return the angle, normalized
345
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
345
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
346 346
 	}
347 347
 	
348
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) {
348
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) {
349 349
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
350
-		$a = -($lon2-$lon1);
350
+		$a = -($lon2 - $lon1);
351 351
 		$b = $lat2 - $lat1;
352
-		$c = -($a*$lat1+$b*$lon1);
353
-		$d = $a*$lat3+$b*$lon3+$c;
352
+		$c = -($a*$lat1 + $b*$lon1);
353
+		$d = $a*$lat3 + $b*$lon3 + $c;
354 354
 		if ($d > -$approx && $d < $approx) return true;
355 355
 		else return false;
356 356
 	}
357 357
 	
358 358
 	public function array_merge_noappend() {
359 359
 		$output = array();
360
-		foreach(func_get_args() as $array) {
361
-			foreach($array as $key => $value) {
360
+		foreach (func_get_args() as $array) {
361
+			foreach ($array as $key => $value) {
362 362
 				$output[$key] = isset($output[$key]) ?
363 363
 				array_merge($output[$key], $value) : $value;
364 364
 			}
@@ -422,34 +422,34 @@  discard block
 block discarded – undo
422 422
 		return $result;
423 423
 	}
424 424
 
425
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){
425
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) {
426 426
 		global $globalMapRefresh;
427 427
 		$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
428 428
 		$r = 6378;
429 429
 		$latitude = deg2rad($latitude);
430 430
 		$longitude = deg2rad($longitude);
431 431
 		$bearing = deg2rad($heading); 
432
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
433
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
434
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
432
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
433
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
434
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
435 435
 	}
436 436
 	
437
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
437
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
438 438
 		// distance in meter
439 439
 		$R = 6378.14;
440
-		$latitude1 = $latitude * (M_PI/180);
441
-		$longitude1 = $longitude * (M_PI/180);
442
-		$brng = $bearing * (M_PI/180);
440
+		$latitude1 = $latitude*(M_PI/180);
441
+		$longitude1 = $longitude*(M_PI/180);
442
+		$brng = $bearing*(M_PI/180);
443 443
 		$d = $distance;
444 444
 
445 445
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
446
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
446
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
447 447
 
448
-		$latitude2 = $latitude2 * (180/M_PI);
449
-		$longitude2 = $longitude2 * (180/M_PI);
448
+		$latitude2 = $latitude2*(180/M_PI);
449
+		$longitude2 = $longitude2*(180/M_PI);
450 450
 
451
-		$flat = round ($latitude2,6);
452
-		$flong = round ($longitude2,6);
451
+		$flat = round($latitude2, 6);
452
+		$flong = round($longitude2, 6);
453 453
 /*
454 454
 		$dx = $distance*cos($bearing);
455 455
 		$dy = $distance*sin($bearing);
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 		$flong = $longitude + $dlong;
459 459
 		$flat = $latitude + $dlat;
460 460
 */
461
-		return array('latitude' => $flat,'longitude' => $flong);
461
+		return array('latitude' => $flat, 'longitude' => $flong);
462 462
 	}
463 463
 
464 464
 	/**
@@ -472,14 +472,14 @@  discard block
 block discarded – undo
472 472
 	 * @param integer $level GZIP compression level (default: 9)
473 473
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
474 474
 	 */
475
-	public function gzCompressFile($source, $level = 9){ 
476
-		$dest = $source . '.gz'; 
477
-		$mode = 'wb' . $level; 
475
+	public function gzCompressFile($source, $level = 9) { 
476
+		$dest = $source.'.gz'; 
477
+		$mode = 'wb'.$level; 
478 478
 		$error = false; 
479 479
 		if ($fp_out = gzopen($dest, $mode)) { 
480
-			if ($fp_in = fopen($source,'rb')) { 
480
+			if ($fp_in = fopen($source, 'rb')) { 
481 481
 				while (!feof($fp_in)) 
482
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
482
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
483 483
 				fclose($fp_in); 
484 484
 			} else {
485 485
 				$error = true; 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	} 
496 496
 	
497 497
 	public function remove_accents($string) {
498
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
498
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
499 499
 		$chars = array(
500 500
 		    // Decompositions for Latin-1 Supplement
501 501
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
553 553
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
554 554
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
555
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
555
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
556 556
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
557 557
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
558 558
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -568,13 +568,13 @@  discard block
 block discarded – undo
568 568
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
569 569
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
570 570
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
571
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
572
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
573
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
574
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
575
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
576
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
577
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
571
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
572
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
573
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
574
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
575
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
576
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
577
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
578 578
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
579 579
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
580 580
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
609 609
 			if (is_numeric($string[$i]) && $concat_flag) {
610 610
 				$int .= $string[$i];
611
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
611
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
612 612
 				$concat_flag = false;
613 613
 			}
614 614
 		}
Please login to merge, or discard this patch.
Braces   +87 added lines, -37 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
 	}
@@ -109,12 +117,16 @@  discard block
 block discarded – undo
109 117
 	public static function gunzip($in_file,$out_file_name = '') {
110 118
 		//echo $in_file.' -> '.$out_file_name."\n";
111 119
 		$buffer_size = 4096; // read 4kb at a time
112
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
120
+		if ($out_file_name == '') {
121
+			$out_file_name = str_replace('.gz', '', $in_file);
122
+		}
113 123
 		if ($in_file != '' && file_exists($in_file)) {
114 124
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
115
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
116
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
117
-			else {
125
+			if (function_exists('gzopen')) {
126
+				$file = gzopen($in_file,'rb');
127
+			} elseif (function_exists('gzopen64')) {
128
+				$file = gzopen64($in_file,'rb');
129
+			} else {
118 130
 				echo 'gzopen not available';
119 131
 				die;
120 132
 			}
@@ -130,11 +142,14 @@  discard block
 block discarded – undo
130 142
 	public static function bunzip2($in_file,$out_file_name = '') {
131 143
 		//echo $in_file.' -> '.$out_file_name."\n";
132 144
 		$buffer_size = 4096; // read 4kb at a time
133
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
145
+		if ($out_file_name == '') {
146
+			$out_file_name = str_replace('.bz2', '', $in_file);
147
+		}
134 148
 		if ($in_file != '' && file_exists($in_file)) {
135 149
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
136
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
137
-			else {
150
+			if (function_exists('bzopen')) {
151
+				$file = bzopen($in_file,'rb');
152
+			} else {
138 153
 				echo 'bzopen not available';
139 154
 				die;
140 155
 			}
@@ -153,10 +168,16 @@  discard block
 block discarded – undo
153 168
 	* @return Array array of the tables in HTML page
154 169
 	*/
155 170
 	public function table2array($data) {
156
-		if (!is_string($data)) return array();
157
-		if ($data == '') return array();
171
+		if (!is_string($data)) {
172
+			return array();
173
+		}
174
+		if ($data == '') {
175
+			return array();
176
+		}
158 177
 		$html = str_get_html($data);
159
-		if ($html === false) return array();
178
+		if ($html === false) {
179
+			return array();
180
+		}
160 181
 		$tabledata=array();
161 182
 		foreach($html->find('tr') as $element)
162 183
 		{
@@ -191,7 +212,9 @@  discard block
 block discarded – undo
191 212
 	*/
192 213
 	public function text2array($data) {
193 214
 		$html = str_get_html($data);
194
-		if ($html === false) return array();
215
+		if ($html === false) {
216
+			return array();
217
+		}
195 218
 		$tabledata=array();
196 219
 		foreach($html->find('p') as $element)
197 220
 		{
@@ -212,7 +235,9 @@  discard block
 block discarded – undo
212 235
 	* @return Float Distance in $unit
213 236
 	*/
214 237
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
215
-		if ($lat == $latc && $lon == $lonc) return 0;
238
+		if ($lat == $latc && $lon == $lonc) {
239
+			return 0;
240
+		}
216 241
 		$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;
217 242
 		if ($unit == "km") {
218 243
 			return round($dist * 1.609344);
@@ -236,10 +261,16 @@  discard block
 block discarded – undo
236 261
 	public function withinThreshold ($timeDifference, $distance) {
237 262
 		$x = abs($timeDifference);
238 263
 		$d = abs($distance);
239
-		if ($x == 0 || $d == 0) return true;
264
+		if ($x == 0 || $d == 0) {
265
+			return true;
266
+		}
240 267
 		// may be due to Internet jitter; distance is realistic
241
-		if ($x < 0.7 && $d < 2000) return true;
242
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
268
+		if ($x < 0.7 && $d < 2000) {
269
+			return true;
270
+		} else {
271
+			return $d/$x < 1500*0.27778;
272
+		}
273
+		// 1500 km/h max
243 274
 	}
244 275
 
245 276
 
@@ -267,11 +298,17 @@  discard block
 block discarded – undo
267 298
 	
268 299
 	public function convertDM($coord,$latlong) {
269 300
 		if ($latlong == 'latitude') {
270
-			if ($coord < 0) $NSEW = 'S';
271
-			else $NSEW = 'N';
301
+			if ($coord < 0) {
302
+				$NSEW = 'S';
303
+			} else {
304
+				$NSEW = 'N';
305
+			}
272 306
 		} elseif ($latlong == 'longitude') {
273
-			if ($coord < 0) $NSEW = 'W';
274
-			else $NSEW = 'E';
307
+			if ($coord < 0) {
308
+				$NSEW = 'W';
309
+			} else {
310
+				$NSEW = 'E';
311
+			}
275 312
 		}
276 313
 		$coord = abs($coord);
277 314
 		$deg = floor($coord);
@@ -314,7 +351,9 @@  discard block
 block discarded – undo
314 351
 	public function hex2str($hex) {
315 352
 		$str = '';
316 353
 		$hexln = strlen($hex);
317
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
354
+		for($i=0;$i<$hexln;$i+=2) {
355
+			$str .= chr(hexdec(substr($hex,$i,2)));
356
+		}
318 357
 		return $str;
319 358
 	}
320 359
 	
@@ -351,8 +390,11 @@  discard block
 block discarded – undo
351 390
 		$b = $lat2 - $lat1;
352 391
 		$c = -($a*$lat1+$b*$lon1);
353 392
 		$d = $a*$lat3+$b*$lon3+$c;
354
-		if ($d > -$approx && $d < $approx) return true;
355
-		else return false;
393
+		if ($d > -$approx && $d < $approx) {
394
+			return true;
395
+		} else {
396
+			return false;
397
+		}
356 398
 	}
357 399
 	
358 400
 	public function array_merge_noappend() {
@@ -411,7 +453,9 @@  discard block
 block discarded – undo
411 453
 			return $result;
412 454
 		}
413 455
 		$handle = @opendir('./locale');
414
-		if ($handle === false) return $result;
456
+		if ($handle === false) {
457
+			return $result;
458
+		}
415 459
 		while (false !== ($file = readdir($handle))) {
416 460
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
417 461
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -478,8 +522,9 @@  discard block
 block discarded – undo
478 522
 		$error = false; 
479 523
 		if ($fp_out = gzopen($dest, $mode)) { 
480 524
 			if ($fp_in = fopen($source,'rb')) { 
481
-				while (!feof($fp_in)) 
482
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
525
+				while (!feof($fp_in)) {
526
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
527
+				}
483 528
 				fclose($fp_in); 
484 529
 			} else {
485 530
 				$error = true; 
@@ -488,14 +533,17 @@  discard block
 block discarded – undo
488 533
 		} else {
489 534
 			$error = true; 
490 535
 		}
491
-		if ($error)
492
-			return false; 
493
-		else
494
-			return $dest; 
536
+		if ($error) {
537
+					return false;
538
+		} else {
539
+					return $dest;
540
+		}
495 541
 	} 
496 542
 	
497 543
 	public function remove_accents($string) {
498
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
544
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
545
+			return $string;
546
+		}
499 547
 		$chars = array(
500 548
 		    // Decompositions for Latin-1 Supplement
501 549
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -619,7 +667,9 @@  discard block
 block discarded – undo
619 667
 		$ip = gethostbyname($host);
620 668
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
621 669
 		$r = @socket_connect($s, $ip, $port);
622
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
670
+		if (!socket_set_nonblock($s)) {
671
+			echo "Unable to set nonblock on socket\n";
672
+		}
623 673
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
624 674
 			return $s;
625 675
 		}
Please login to merge, or discard this patch.
manufacturer-sub-menu.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
 </span>
4 4
 <div class="sub-menu sub-menu-container">
5 5
 	<ul class="nav nav-pills">
6
-		<li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
6
+		<li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
7 7
 		<li class="dropdown">
8
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
8
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration") { print 'active'; } ?>" data-toggle="dropdown" href="#">
9 9
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
10 10
 		    </a>
11 11
 		    <ul class="dropdown-menu" role="menu">
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		    </ul>
15 15
 		</li>
16 16
 		<li class="dropdown">
17
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
17
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
18 18
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
19 19
 		    </a>
20 20
 		    <ul class="dropdown-menu" role="menu">
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		    </ul>
24 24
 		</li>
25 25
 		<li class="dropdown">
26
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
26
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
27 27
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
28 28
 		    </a>
29 29
 		    <ul class="dropdown-menu" role="menu">
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 			  <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/arrival-airport-country/<?php print $manufacturer; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
34 34
 		    </ul>
35 35
 		</li>
36
-		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
37
-		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
36
+		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
37
+		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
38 38
 	</ul>
39 39
 </div>
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
airport-geojson.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		date_default_timezone_set('UTC');
28 28
 		//waypoint plotting
29 29
 		$output .= '{"type": "Feature",';
30
-		    $output .= '"properties": {';
30
+			$output .= '"properties": {';
31 31
 			$output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",';
32 32
 			$output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",';
33 33
 			$output .= '"country": "'.$spotter_item['country'].'",';
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 			$output .= '"homepage": "'.$spotter_item['home_link'].'",';
51 51
 			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
52 52
 //			$output .= '"photo": "'.$spotter_item['image_thumbnail'].'",';
53
-		    $output .= '},';
54
-		    $output .= '"geometry": {';
53
+			$output .= '},';
54
+			$output .= '"geometry": {';
55 55
 			$output .= '"type": "Point",';
56 56
 			$output .= '"coordinates": [';
57
-			    $output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
57
+				$output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
58 58
 			$output .= ']';
59
-		    $output .= '}';
59
+			$output .= '}';
60 60
 		$output .= '},';
61 61
 	}
62 62
 	$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (isset($_GET['coord'])) 
13 13
 {
14
-	$coords = explode(',',$_GET['coord']);
14
+	$coords = explode(',', $_GET['coord']);
15 15
 	$spotter_array = $Spotter->getAllAirportInfobyCoord($coords);
16 16
 } else {
17 17
 	$spotter_array = $Spotter->getAllAirportInfo();
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
             
23 23
 if (!empty($spotter_array))
24 24
 {	  
25
-	foreach($spotter_array as $spotter_item)
25
+	foreach ($spotter_array as $spotter_item)
26 26
 	{
27 27
 		date_default_timezone_set('UTC');
28 28
 		//waypoint plotting
29 29
 		$output .= '{"type": "Feature",';
30 30
 		    $output .= '"properties": {';
31
-			$output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",';
32
-			$output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",';
31
+			$output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",';
32
+			$output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",';
33 33
 			$output .= '"country": "'.$spotter_item['country'].'",';
34 34
 			$output .= '"altitude": "'.$spotter_item['altitude'].'",';
35
-			$output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",';
35
+			$output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",';
36 36
 			if ($spotter_item['type'] == 'large_airport') {
37 37
 				$output .= '"icon": "'.$globalURL.'/images/airport.png",';
38 38
 			} elseif ($spotter_item['type'] == 'heliport') {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		    $output .= '}';
60 60
 		$output .= '},';
61 61
 	}
62
-	$output  = substr($output, 0, -1);
62
+	$output = substr($output, 0, -1);
63 63
 }
64 64
 $output .= ']}';
65 65
 print $output;
Please login to merge, or discard this patch.
require/class.Image.php 4 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -254,6 +254,7 @@  discard block
 block discarded – undo
254 254
 	*
255 255
 	* @param String $aircraft_registration the registration of the aircraft
256 256
 	* @param String $aircraft_name type of the aircraft
257
+	* @param string $type
257 258
 	* @return Array the aircraft thumbnail, orignal url and copyright
258 259
 	*
259 260
 	*/
@@ -287,6 +288,7 @@  discard block
 block discarded – undo
287 288
 	*
288 289
 	* @param String $registration the registration of the aircraft
289 290
 	* @param String $name type of the aircraft
291
+	* @param string $type
290 292
 	* @return Array the aircraft thumbnail, orignal url and copyright
291 293
 	*
292 294
 	*/
@@ -325,6 +327,7 @@  discard block
 block discarded – undo
325 327
 	*
326 328
 	* @param String $aircraft_registration the registration of the aircraft
327 329
 	* @param String $aircraft_name type of the aircraft
330
+	* @param string $type
328 331
 	* @return Array the aircraft thumbnail, orignal url and copyright
329 332
 	*
330 333
 	*/
@@ -367,6 +370,7 @@  discard block
 block discarded – undo
367 370
 	*
368 371
 	* @param String $aircraft_registration the registration of the aircraft
369 372
 	* @param String $aircraft_name type of the aircraft
373
+	* @param string $type
370 374
 	* @return Array the aircraft thumbnail, orignal url and copyright
371 375
 	*
372 376
 	*/
@@ -401,6 +405,7 @@  discard block
 block discarded – undo
401 405
 	*
402 406
 	* @param String $registration the registration of the aircraft
403 407
 	* @param String $name type of the aircraft
408
+	* @param string $type
404 409
 	* @return Array the aircraft thumbnail, orignal url and copyright
405 410
 	*
406 411
 	*/
@@ -429,6 +434,10 @@  discard block
 block discarded – undo
429 434
 		return false;
430 435
 	}
431 436
 
437
+	/**
438
+	 * @param string $type
439
+	 * @param string $aircraft_icao
440
+	 */
432 441
 	public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) {
433 442
 		$Common = new Common();
434 443
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
@@ -450,6 +459,7 @@  discard block
 block discarded – undo
450 459
 	*
451 460
 	* @param String $aircraft_registration the registration of the aircraft
452 461
 	* @param String $aircraft_name type of the aircraft
462
+	* @param string $type
453 463
 	* @return Array the aircraft thumbnail, orignal url and copyright
454 464
 	*
455 465
 	*/
@@ -482,6 +492,7 @@  discard block
 block discarded – undo
482 492
 	*
483 493
 	* @param String $aircraft_registration the registration of the aircraft
484 494
 	* @param String $aircraft_name type of the aircraft
495
+	* @param string $type
485 496
 	* @return Array the aircraft thumbnail, orignal url and copyright
486 497
 	*
487 498
 	*/
@@ -507,6 +518,7 @@  discard block
 block discarded – undo
507 518
 	*
508 519
 	* @param String $registration the registration of the aircraft/mmsi
509 520
 	* @param String $name name
521
+	* @param string $type
510 522
 	* @return Array the aircraft thumbnail, orignal url and copyright
511 523
 	*
512 524
 	*/
@@ -568,6 +580,7 @@  discard block
 block discarded – undo
568 580
 	*
569 581
 	* @param String $registration the registration of the aircraft
570 582
 	* @param String $name type of the aircraft
583
+	* @param string $type
571 584
 	* @return Array the aircraft thumbnail, orignal url and copyright
572 585
 	*
573 586
 	*/
Please login to merge, or discard this patch.
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	/**
15
-	* Gets the images based on the aircraft registration
16
-	*
17
-	* @return Array the images list
18
-	*
19
-	*/
15
+	 * Gets the images based on the aircraft registration
16
+	 *
17
+	 * @return Array the images list
18
+	 *
19
+	 */
20 20
 	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
21 21
 	{
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	/**
40
-	* Gets the images based on the ship name
41
-	*
42
-	* @return Array the images list
43
-	*
44
-	*/
40
+	 * Gets the images based on the ship name
41
+	 *
42
+	 * @return Array the images list
43
+	 *
44
+	 */
45 45
 	public function getMarineImage($mmsi,$imo = '',$name = '')
46 46
 	{
47 47
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 
70 70
 	/**
71
-	* Gets the image copyright based on the Exif data
72
-	*
73
-	* @return String image copyright
74
-	*
75
-	*/
71
+	 * Gets the image copyright based on the Exif data
72
+	 *
73
+	 * @return String image copyright
74
+	 *
75
+	 */
76 76
 	public function getExifCopyright($url) {
77 77
 		$exif = exif_read_data($url);
78 78
 		$copyright = '';
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	}
88 88
 
89 89
 	/**
90
-	* Adds the images based on the aircraft registration
91
-	*
92
-	* @return String either success or error
93
-	*
94
-	*/
90
+	 * Adds the images based on the aircraft registration
91
+	 *
92
+	 * @return String either success or error
93
+	 *
94
+	 */
95 95
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
96 96
 	{
97 97
 		global $globalDebug,$globalAircraftImageFetch;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	}
120 120
 
121 121
 	/**
122
-	* Adds the images based on the marine name
123
-	*
124
-	* @return String either success or error
125
-	*
126
-	*/
122
+	 * Adds the images based on the marine name
123
+	 *
124
+	 * @return String either success or error
125
+	 *
126
+	 */
127 127
 	public function addMarineImage($mmsi,$imo = '',$name = '')
128 128
 	{
129 129
 		global $globalDebug,$globalMarineImageFetch;
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 
162 162
 	/**
163
-	* Gets the aircraft image
164
-	*
165
-	* @param String $aircraft_registration the registration of the aircraft
166
-	* @return Array the aircraft thumbnail, orignal url and copyright
167
-	*
168
-	*/
163
+	 * Gets the aircraft image
164
+	 *
165
+	 * @param String $aircraft_registration the registration of the aircraft
166
+	 * @return Array the aircraft thumbnail, orignal url and copyright
167
+	 *
168
+	 */
169 169
 	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
170 170
 	{
171 171
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 	}
210 210
 
211 211
 	/**
212
-	* Gets the vessel image
213
-	*
214
-	* @param String $mmsi the vessel mmsi
215
-	* @param String $imo the vessel imo
216
-	* @param String $name the vessel name
217
-	* @return Array the aircraft thumbnail, orignal url and copyright
218
-	*
219
-	*/
212
+	 * Gets the vessel image
213
+	 *
214
+	 * @param String $mmsi the vessel mmsi
215
+	 * @param String $imo the vessel imo
216
+	 * @param String $name the vessel name
217
+	 * @return Array the aircraft thumbnail, orignal url and copyright
218
+	 *
219
+	 */
220 220
 	public function findMarineImage($mmsi,$imo = '',$name = '')
221 221
 	{
222 222
 		global $globalMarineImageSources;
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 	/**
253
-	* Gets the aircraft image from Planespotters
254
-	*
255
-	* @param String $aircraft_registration the registration of the aircraft
256
-	* @param String $aircraft_name type of the aircraft
257
-	* @return Array the aircraft thumbnail, orignal url and copyright
258
-	*
259
-	*/
253
+	 * Gets the aircraft image from Planespotters
254
+	 *
255
+	 * @param String $aircraft_registration the registration of the aircraft
256
+	 * @param String $aircraft_name type of the aircraft
257
+	 * @return Array the aircraft thumbnail, orignal url and copyright
258
+	 *
259
+	 */
260 260
 	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
261 261
 		$Common = new Common();
262 262
 		// If aircraft registration is only number, also check with aircraft model
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 	/**
286
-	* Gets the aircraft image from Deviantart
287
-	*
288
-	* @param String $registration the registration of the aircraft
289
-	* @param String $name type of the aircraft
290
-	* @return Array the aircraft thumbnail, orignal url and copyright
291
-	*
292
-	*/
286
+	 * Gets the aircraft image from Deviantart
287
+	 *
288
+	 * @param String $registration the registration of the aircraft
289
+	 * @param String $name type of the aircraft
290
+	 * @return Array the aircraft thumbnail, orignal url and copyright
291
+	 *
292
+	 */
293 293
 	public function fromDeviantart($type,$registration, $name='') {
294 294
 		$Common = new Common();
295 295
 		if ($type == 'aircraft') {
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
 	}
322 322
 
323 323
 	/**
324
-	* Gets the aircraft image from JetPhotos
325
-	*
326
-	* @param String $aircraft_registration the registration of the aircraft
327
-	* @param String $aircraft_name type of the aircraft
328
-	* @return Array the aircraft thumbnail, orignal url and copyright
329
-	*
330
-	*/
324
+	 * Gets the aircraft image from JetPhotos
325
+	 *
326
+	 * @param String $aircraft_registration the registration of the aircraft
327
+	 * @param String $aircraft_name type of the aircraft
328
+	 * @return Array the aircraft thumbnail, orignal url and copyright
329
+	 *
330
+	 */
331 331
 	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
332 332
 		$Common = new Common();
333 333
 		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
@@ -363,13 +363,13 @@  discard block
 block discarded – undo
363 363
 	}
364 364
 
365 365
 	/**
366
-	* Gets the aircraft image from PlanePictures
367
-	*
368
-	* @param String $aircraft_registration the registration of the aircraft
369
-	* @param String $aircraft_name type of the aircraft
370
-	* @return Array the aircraft thumbnail, orignal url and copyright
371
-	*
372
-	*/
366
+	 * Gets the aircraft image from PlanePictures
367
+	 *
368
+	 * @param String $aircraft_registration the registration of the aircraft
369
+	 * @param String $aircraft_name type of the aircraft
370
+	 * @return Array the aircraft thumbnail, orignal url and copyright
371
+	 *
372
+	 */
373 373
 	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
374 374
 		$Common = new Common();
375 375
 		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 	}
398 398
 
399 399
 	/**
400
-	* Gets the aircraft image from Flickr
401
-	*
402
-	* @param String $registration the registration of the aircraft
403
-	* @param String $name type of the aircraft
404
-	* @return Array the aircraft thumbnail, orignal url and copyright
405
-	*
406
-	*/
400
+	 * Gets the aircraft image from Flickr
401
+	 *
402
+	 * @param String $registration the registration of the aircraft
403
+	 * @param String $name type of the aircraft
404
+	 * @return Array the aircraft thumbnail, orignal url and copyright
405
+	 *
406
+	 */
407 407
 	public function fromFlickr($type,$registration,$name='') {
408 408
 		$Common = new Common();
409 409
 		if ($type == 'aircraft') {
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
 	}
447 447
 
448 448
 	/**
449
-	* Gets the aircraft image from Bing
450
-	*
451
-	* @param String $aircraft_registration the registration of the aircraft
452
-	* @param String $aircraft_name type of the aircraft
453
-	* @return Array the aircraft thumbnail, orignal url and copyright
454
-	*
455
-	*/
449
+	 * Gets the aircraft image from Bing
450
+	 *
451
+	 * @param String $aircraft_registration the registration of the aircraft
452
+	 * @param String $aircraft_name type of the aircraft
453
+	 * @return Array the aircraft thumbnail, orignal url and copyright
454
+	 *
455
+	 */
456 456
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
457 457
 		global $globalImageBingKey;
458 458
 		$Common = new Common();
@@ -478,13 +478,13 @@  discard block
 block discarded – undo
478 478
 	}
479 479
 
480 480
 	/**
481
-	* Gets the aircraft image from airport-data
482
-	*
483
-	* @param String $aircraft_registration the registration of the aircraft
484
-	* @param String $aircraft_name type of the aircraft
485
-	* @return Array the aircraft thumbnail, orignal url and copyright
486
-	*
487
-	*/
481
+	 * Gets the aircraft image from airport-data
482
+	 *
483
+	 * @param String $aircraft_registration the registration of the aircraft
484
+	 * @param String $aircraft_name type of the aircraft
485
+	 * @return Array the aircraft thumbnail, orignal url and copyright
486
+	 *
487
+	 */
488 488
 	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
489 489
 		$Common = new Common();
490 490
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
 	}
504 504
 
505 505
 	/**
506
-	* Gets image from WikiMedia
507
-	*
508
-	* @param String $registration the registration of the aircraft/mmsi
509
-	* @param String $name name
510
-	* @return Array the aircraft thumbnail, orignal url and copyright
511
-	*
512
-	*/
506
+	 * Gets image from WikiMedia
507
+	 *
508
+	 * @param String $registration the registration of the aircraft/mmsi
509
+	 * @param String $name name
510
+	 * @return Array the aircraft thumbnail, orignal url and copyright
511
+	 *
512
+	 */
513 513
 	public function fromWikimedia($type,$registration,$name='') {
514 514
 		$Common = new Common();
515 515
 		if ($type == 'aircraft') {
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 	}
565 565
 
566 566
 	/**
567
-	* Gets the aircraft image from custom url
568
-	*
569
-	* @param String $registration the registration of the aircraft
570
-	* @param String $name type of the aircraft
571
-	* @return Array the aircraft thumbnail, orignal url and copyright
572
-	*
573
-	*/
567
+	 * Gets the aircraft image from custom url
568
+	 *
569
+	 * @param String $registration the registration of the aircraft
570
+	 * @param String $name type of the aircraft
571
+	 * @return Array the aircraft thumbnail, orignal url and copyright
572
+	 *
573
+	 */
574 574
 	public function fromCustomSource($type,$registration,$name='') {
575 575
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
576 576
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 	* @return Array the images list
18 18
 	*
19 19
 	*/
20
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
20
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
21 21
 	{
22
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
22
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
23
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
24
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
25 25
 		$reg = $registration;
26 26
 		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
27 27
 		$reg = trim($reg);
28
-		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
28
+		$query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
29 29
 			FROM spotter_image 
30 30
 			WHERE spotter_image.registration = :registration LIMIT 1";
31 31
 		$sth = $this->db->prepare($query);
32 32
 		$sth->execute(array(':registration' => $reg));
33 33
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
34 34
 		if (!empty($result)) return $result;
35
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
35
+		elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao);
36 36
 		else return array();
37 37
 	}
38 38
 
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
 	* @return Array the images list
43 43
 	*
44 44
 	*/
45
-	public function getMarineImage($mmsi,$imo = '',$name = '')
45
+	public function getMarineImage($mmsi, $imo = '', $name = '')
46 46
 	{
47
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
48
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
49
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
47
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
48
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
49
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
50 50
 		$name = trim($name);
51
-		$query  = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
51
+		$query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
52 52
 			FROM marine_image 
53 53
 			WHERE marine_image.mmsi = :mmsi";
54 54
 		$query_data = array(':mmsi' => $mmsi);
55 55
 		if ($imo != '') {
56 56
 			$query .= " AND marine_image.imo = :imo";
57
-			$query_data = array_merge($query_data,array(':imo' => $imo));
57
+			$query_data = array_merge($query_data, array(':imo' => $imo));
58 58
 		}
59 59
 		if ($name != '') {
60 60
 			$query .= " AND marine_image.name = :name";
61
-			$query_data = array_merge($query_data,array(':name' => $name));
61
+			$query_data = array_merge($query_data, array(':name' => $name));
62 62
 		}
63 63
 		$query .= " LIMIT 1";
64 64
 		$sth = $this->db->prepare($query);
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
80 80
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
81 81
 		if ($copyright != '') {
82
-			$copyright = str_replace('Copyright ','',$copyright);
83
-			$copyright = str_replace('© ','',$copyright);
84
-			$copyright = str_replace('(c) ','',$copyright);
82
+			$copyright = str_replace('Copyright ', '', $copyright);
83
+			$copyright = str_replace('© ', '', $copyright);
84
+			$copyright = str_replace('(c) ', '', $copyright);
85 85
 		}
86 86
 		return $copyright;
87 87
 	}
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
 	* @return String either success or error
93 93
 	*
94 94
 	*/
95
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
95
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
96 96
 	{
97
-		global $globalDebug,$globalAircraftImageFetch;
97
+		global $globalDebug, $globalAircraftImageFetch;
98 98
 		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
99
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
99
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
100 100
 		$registration = trim($registration);
101 101
 		//getting the aircraft image
102 102
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
103 103
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
104 104
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
105
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
105
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
106 106
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
107 107
 		if ($image_url['original'] != '') {
108 108
 			if ($globalDebug) echo 'Found !'."\n";
109
-			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
109
+			$query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
110 110
 			try {
111 111
 				$sth = $this->db->prepare($query);
112
-				$sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
113
-			} catch(PDOException $e) {
112
+				$sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
113
+			} catch (PDOException $e) {
114 114
 				echo $e->getMessage()."\n";
115 115
 				return "error";
116 116
 			}
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
 	* @return String either success or error
125 125
 	*
126 126
 	*/
127
-	public function addMarineImage($mmsi,$imo = '',$name = '')
127
+	public function addMarineImage($mmsi, $imo = '', $name = '')
128 128
 	{
129
-		global $globalDebug,$globalMarineImageFetch;
129
+		global $globalDebug, $globalMarineImageFetch;
130 130
 		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return '';
131
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
132
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
133
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
131
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
132
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
133
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
134 134
 		$name = trim($name);
135 135
 		$Marine = new Marine($this->db);
136 136
 		if ($imo == '' || $name == '') {
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 
145 145
 		//getting the aircraft image
146 146
 		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
147
-		$image_url = $this->findMarineImage($mmsi,$imo,$name);
147
+		$image_url = $this->findMarineImage($mmsi, $imo, $name);
148 148
 		if ($image_url['original'] != '') {
149 149
 			if ($globalDebug) echo 'Found !'."\n";
150
-			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
150
+			$query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
151 151
 			try {
152 152
 				$sth = $this->db->prepare($query);
153
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
154
-			} catch(PDOException $e) {
153
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
154
+			} catch (PDOException $e) {
155 155
 				echo $e->getMessage()."\n";
156 156
 				return "error";
157 157
 			}
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
172 172
 		$Spotter = new Spotter($this->db);
173 173
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
174
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
174
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
175 175
 		if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) {
176
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
176
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
177 177
 			$aircraft_registration = urlencode(trim($aircraft_registration));
178 178
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
179 179
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -187,25 +187,25 @@  discard block
 block discarded – undo
187 187
 			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
188 188
 			else $aircraft_name = '';
189 189
 			$aircraft_registration = $aircraft_icao;
190
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
190
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
191 191
 		unset($Spotter);
192
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
192
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
193 193
 		foreach ($globalAircraftImageSources as $source) {
194 194
 			$source = strtolower($source);
195
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
196
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
197
-			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
198
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
199
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
200
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
201
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
202
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
203
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
204
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
195
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao);
196
+			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name);
197
+			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name);
198
+			if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name);
199
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name);
200
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name);
201
+			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name);
202
+			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name);
203
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name);
204
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name);
205 205
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
206 206
 		}
207 207
 		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
208
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
208
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
209 209
 	}
210 210
 
211 211
 	/**
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 	* @return Array the aircraft thumbnail, orignal url and copyright
218 218
 	*
219 219
 	*/
220
-	public function findMarineImage($mmsi,$imo = '',$name = '')
220
+	public function findMarineImage($mmsi, $imo = '', $name = '')
221 221
 	{
222 222
 		global $globalMarineImageSources;
223
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
223
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
224 224
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
225
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
225
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
226 226
 		$name = trim($name);
227
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
227
+		if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
228 228
 		/*
229 229
 		$Marine = new Marine($this->db);
230 230
 		if ($imo == '' || $name == '') {
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
 		}
237 237
 		unset($Marine);
238 238
 		*/
239
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
239
+		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing');
240 240
 		foreach ($globalMarineImageSources as $source) {
241 241
 			$source = strtolower($source);
242
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
243
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
244
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
245
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
246
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
242
+			if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name);
243
+			if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name);
244
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name);
245
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name);
246
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name);
247 247
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
248 248
 		}
249
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
249
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
250 250
 	}
251 251
 
252 252
 	/**
@@ -257,24 +257,24 @@  discard block
 block discarded – undo
257 257
 	* @return Array the aircraft thumbnail, orignal url and copyright
258 258
 	*
259 259
 	*/
260
-	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
260
+	public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') {
261 261
 		$Common = new Common();
262 262
 		// If aircraft registration is only number, also check with aircraft model
263
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
264
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
263
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
264
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
265 265
 		} else {
266 266
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
267
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
267
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
268 268
 		}
269 269
 		$data = $Common->getData($url);
270 270
 		if ($xml = simplexml_load_string($data)) {
271 271
 			if (isset($xml->channel->item)) {
272 272
 				$image_url = array();
273
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
273
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
274 274
 				$image_url['thumbnail'] = $thumbnail_url;
275
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
276
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
277
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
275
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
276
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
277
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
278 278
 				$image_url['source'] = 'planespotters';
279 279
 				return $image_url;
280 280
 			}
@@ -290,29 +290,29 @@  discard block
 block discarded – undo
290 290
 	* @return Array the aircraft thumbnail, orignal url and copyright
291 291
 	*
292 292
 	*/
293
-	public function fromDeviantart($type,$registration, $name='') {
293
+	public function fromDeviantart($type, $registration, $name = '') {
294 294
 		$Common = new Common();
295 295
 		if ($type == 'aircraft') {
296 296
 			// If aircraft registration is only number, also check with aircraft model
297
-			if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') {
298
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
297
+			if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') {
298
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
299 299
 			} else {
300
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
300
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
301 301
 			}
302 302
 		} elseif ($type == 'marine') {
303
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
303
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
304 304
 		}
305 305
 
306 306
 		$data = $Common->getData($url);
307 307
 		if ($xml = simplexml_load_string($data)) {
308 308
 			if (isset($xml->channel->item->link)) {
309 309
 				$image_url = array();
310
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
310
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
311 311
 				$image_url['thumbnail'] = $thumbnail_url;
312
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
312
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
313 313
 				$image_url['original'] = $original_url;
314
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
315
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
314
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
315
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
316 316
 				$image_url['source'] = 'deviantart';
317 317
 				return $image_url;
318 318
 			}
@@ -328,32 +328,32 @@  discard block
 block discarded – undo
328 328
 	* @return Array the aircraft thumbnail, orignal url and copyright
329 329
 	*
330 330
 	*/
331
-	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
331
+	public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') {
332 332
 		$Common = new Common();
333
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
333
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
334 334
 		$data = $Common->getData($url);
335 335
 		$dom = new DOMDocument();
336 336
 		@$dom->loadHTML($data);
337 337
 		$all_pics = array();
338
-		foreach($dom->getElementsByTagName('img') as $image) {
338
+		foreach ($dom->getElementsByTagName('img') as $image) {
339 339
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
340 340
 				$all_pics[] = $image->getAttribute('src');
341 341
 			}
342 342
 		}
343 343
 		$all_authors = array();
344
-		foreach($dom->getElementsByTagName('meta') as $author) {
344
+		foreach ($dom->getElementsByTagName('meta') as $author) {
345 345
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
346 346
 				$all_authors[] = $author->getAttribute('content');
347 347
 			}
348 348
 		}
349 349
 		$all_ref = array();
350
-		foreach($dom->getElementsByTagName('a') as $link) {
350
+		foreach ($dom->getElementsByTagName('a') as $link) {
351 351
 			$all_ref[] = $link->getAttribute('href');
352 352
 		}
353 353
 		if (isset($all_pics[0])) {
354 354
 			$image_url = array();
355 355
 			$image_url['thumbnail'] = $all_pics[0];
356
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
356
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
357 357
 			$image_url['copyright'] = $all_authors[0];
358 358
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
359 359
 			$image_url['source'] = 'JetPhotos';
@@ -370,24 +370,24 @@  discard block
 block discarded – undo
370 370
 	* @return Array the aircraft thumbnail, orignal url and copyright
371 371
 	*
372 372
 	*/
373
-	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
373
+	public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') {
374 374
 		$Common = new Common();
375
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
375
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
376 376
 		$data = $Common->getData($url);
377 377
 		$dom = new DOMDocument();
378 378
 		@$dom->loadHTML($data);
379 379
 		$all_pics = array();
380
-		foreach($dom->getElementsByTagName('img') as $image) {
380
+		foreach ($dom->getElementsByTagName('img') as $image) {
381 381
 			$all_pics[] = $image->getAttribute('src');
382 382
 		}
383 383
 		$all_links = array();
384
-		foreach($dom->getElementsByTagName('a') as $link) {
385
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
384
+		foreach ($dom->getElementsByTagName('a') as $link) {
385
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
386 386
 		}
387
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) {
387
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) {
388 388
 			$image_url = array();
389 389
 			$image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1];
390
-			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]);
390
+			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]);
391 391
 			$image_url['copyright'] = $all_links[6]['text'];
392 392
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
393 393
 			$image_url['source'] = 'PlanePictures';
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	* @return Array the aircraft thumbnail, orignal url and copyright
405 405
 	*
406 406
 	*/
407
-	public function fromFlickr($type,$registration,$name='') {
407
+	public function fromFlickr($type, $registration, $name = '') {
408 408
 		$Common = new Common();
409 409
 		if ($type == 'aircraft') {
410 410
 			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
 		$data = $Common->getData($url);
417 417
 		if ($xml = simplexml_load_string($data)) {
418 418
 			if (isset($xml->channel->item)) {
419
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
419
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
420 420
 				$image_url = array();
421 421
 				$image_url['thumbnail'] = $original_url;
422 422
 				$image_url['original'] = $original_url;
423
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
424
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
423
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
424
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
425 425
 				$image_url['source'] = 'flickr';
426 426
 				return $image_url;
427 427
 			}
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		return false;
430 430
 	}
431 431
 
432
-	public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) {
432
+	public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) {
433 433
 		$Common = new Common();
434 434
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
435 435
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	* @return Array the aircraft thumbnail, orignal url and copyright
454 454
 	*
455 455
 	*/
456
-	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
456
+	public function fromBing($type, $aircraft_registration, $aircraft_name = '') {
457 457
 		global $globalImageBingKey;
458 458
 		$Common = new Common();
459 459
 		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
 			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
465 465
 			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
466 466
 		}
467
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
468
-		$data = $Common->getData($url,'get','',$headers);
467
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
468
+		$data = $Common->getData($url, 'get', '', $headers);
469 469
 		$result = json_decode($data);
470 470
 		if (isset($result->d->results[0]->MediaUrl)) {
471 471
 			$image_url = array();
@@ -490,14 +490,14 @@  discard block
 block discarded – undo
490 490
 	* @return Array the aircraft thumbnail, orignal url and copyright
491 491
 	*
492 492
 	*/
493
-	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
493
+	public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') {
494 494
 		$Common = new Common();
495 495
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
496 496
 		$data = $Common->getData($url);
497 497
 		$result = json_decode($data);
498 498
 		if (isset($result->count) && $result->count > 0) {
499 499
 			$image_url = array();
500
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
500
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
501 501
 			$image_url['source_website'] = $result->data[0]->link;
502 502
 			$image_url['thumbnail'] = $result->data[0]->image;
503 503
 			$image_url['copyright'] = $result->data[0]->photographer;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	* @return Array the aircraft thumbnail, orignal url and copyright
516 516
 	*
517 517
 	*/
518
-	public function fromWikimedia($type,$registration,$name='') {
518
+	public function fromWikimedia($type, $registration, $name = '') {
519 519
 		$Common = new Common();
520 520
 		if ($type == 'aircraft') {
521 521
 			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 		$result = json_decode($data);
529 529
 		if (isset($result->query->search[0]->title)) {
530 530
 			$fileo = $result->query->search[0]->title;
531
-			if (substr($fileo,-3) == 'pdf') return false;
531
+			if (substr($fileo, -3) == 'pdf') return false;
532 532
 			$file = urlencode($fileo);
533 533
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
534 534
 			$data2 = $Common->getData($url2);
@@ -553,11 +553,11 @@  discard block
 block discarded – undo
553 553
 				if (isset($result2->query->pages)) {
554 554
 					foreach ($result2->query->pages as $page) {
555 555
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
556
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
556
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
557 557
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
558 558
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
559 559
 							}
560
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
560
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
561 561
 							return $image_url;
562 562
 						}
563 563
 					}
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	* @return Array the aircraft thumbnail, orignal url and copyright
577 577
 	*
578 578
 	*/
579
-	public function fromCustomSource($type,$registration,$name='') {
579
+	public function fromCustomSource($type, $registration, $name = '') {
580 580
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
581 581
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
582 582
 		if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') {
@@ -593,15 +593,15 @@  discard block
 block discarded – undo
593 593
 					print_r($source);
594 594
 					print_r($customsources);
595 595
 				}
596
-				$url = str_replace('{registration}',$registration,$source['original']);
597
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
596
+				$url = str_replace('{registration}', $registration, $source['original']);
597
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
598 598
 				if ($Common->urlexist($url)) {
599 599
 					$image_url = array();
600 600
 					$image_url['thumbnail'] = $url_thumbnail;
601 601
 					$image_url['original'] = $url;
602 602
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
603 603
 					else $exifCopyright = '';
604
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
604
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
605 605
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
606 606
 					else $image_url['copyright'] = $source['source_website'];
607 607
 					$image_url['source_website'] = $source['source_website'];
@@ -625,19 +625,19 @@  discard block
 block discarded – undo
625 625
 					print_r($source);
626 626
 					print_r($customsources);
627 627
 				}
628
-				$url = str_replace('{registration}',$registration,$source['original']);
629
-				$url = str_replace('{mmsi}',$registration,$url);
630
-				$url = str_replace('{name}',$name,$url);
631
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
632
-				$url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail);
633
-				$url_thumbnail = str_replace('{name}',$name,$url_thumbnail);
628
+				$url = str_replace('{registration}', $registration, $source['original']);
629
+				$url = str_replace('{mmsi}', $registration, $url);
630
+				$url = str_replace('{name}', $name, $url);
631
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
632
+				$url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail);
633
+				$url_thumbnail = str_replace('{name}', $name, $url_thumbnail);
634 634
 				if ($Common->urlexist($url)) {
635 635
 					$image_url = array();
636 636
 					$image_url['thumbnail'] = $url_thumbnail;
637 637
 					$image_url['original'] = $url;
638 638
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
639 639
 					else $exifCopyright = '';
640
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
640
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
641 641
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
642 642
 					else $image_url['copyright'] = $source['source_website'];
643 643
 					$image_url['source_website'] = $source['source_website'];
Please login to merge, or discard this patch.
Braces   +208 added lines, -77 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24 24
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
25 25
 		$reg = $registration;
26
-		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
26
+		if ($reg == '' && $aircraft_icao != '') {
27
+			$reg = $aircraft_icao.$airline_icao;
28
+		}
27 29
 		$reg = trim($reg);
28 30
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
29 31
 			FROM spotter_image 
@@ -31,9 +33,13 @@  discard block
 block discarded – undo
31 33
 		$sth = $this->db->prepare($query);
32 34
 		$sth->execute(array(':registration' => $reg));
33 35
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
34
-		if (!empty($result)) return $result;
35
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
36
-		else return array();
36
+		if (!empty($result)) {
37
+			return $result;
38
+		} elseif ($registration != '') {
39
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
40
+		} else {
41
+			return array();
42
+		}
37 43
 	}
38 44
 
39 45
 	/**
@@ -76,8 +82,11 @@  discard block
 block discarded – undo
76 82
 	public function getExifCopyright($url) {
77 83
 		$exif = exif_read_data($url);
78 84
 		$copyright = '';
79
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
80
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
85
+		if (isset($exif['COMPUTED']['copyright'])) {
86
+			$copyright = $exif['COMPUTED']['copyright'];
87
+		} elseif (isset($exif['copyright'])) {
88
+			$copyright = $exif['copyright'];
89
+		}
81 90
 		if ($copyright != '') {
82 91
 			$copyright = str_replace('Copyright ','',$copyright);
83 92
 			$copyright = str_replace('© ','',$copyright);
@@ -95,17 +104,27 @@  discard block
 block discarded – undo
95 104
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
96 105
 	{
97 106
 		global $globalDebug,$globalAircraftImageFetch;
98
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
107
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
108
+			return '';
109
+		}
99 110
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
100 111
 		$registration = trim($registration);
101 112
 		//getting the aircraft image
102
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
103
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
104
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
113
+		if ($globalDebug && $registration != '') {
114
+			echo 'Try to find an aircraft image for '.$registration.'...';
115
+		} elseif ($globalDebug && $aircraft_icao != '') {
116
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
117
+		} elseif ($globalDebug && $airline_icao != '') {
118
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
119
+		}
105 120
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
106
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
121
+		if ($registration == '' && $aircraft_icao != '') {
122
+			$registration = $aircraft_icao.$airline_icao;
123
+		}
107 124
 		if ($image_url['original'] != '') {
108
-			if ($globalDebug) echo 'Found !'."\n";
125
+			if ($globalDebug) {
126
+				echo 'Found !'."\n";
127
+			}
109 128
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
110 129
 			try {
111 130
 				$sth = $this->db->prepare($query);
@@ -114,7 +133,9 @@  discard block
 block discarded – undo
114 133
 				echo $e->getMessage()."\n";
115 134
 				return "error";
116 135
 			}
117
-		} elseif ($globalDebug) echo "Not found :'(\n";
136
+		} elseif ($globalDebug) {
137
+			echo "Not found :'(\n";
138
+		}
118 139
 		return "success";
119 140
 	}
120 141
 
@@ -127,7 +148,9 @@  discard block
 block discarded – undo
127 148
 	public function addMarineImage($mmsi,$imo = '',$name = '')
128 149
 	{
129 150
 		global $globalDebug,$globalMarineImageFetch;
130
-		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return '';
151
+		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) {
152
+			return '';
153
+		}
131 154
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
132 155
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
133 156
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
@@ -137,16 +160,22 @@  discard block
 block discarded – undo
137 160
 			$identity = $Marine->getIdentity($mmsi);
138 161
 			if (isset($identity[0]['mmsi'])) {
139 162
 				$imo = $identity[0]['imo'];
140
-				if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name'];
163
+				if ($identity[0]['ship_name'] != '') {
164
+					$name = $identity[0]['ship_name'];
165
+				}
141 166
 			}
142 167
 		}
143 168
 		unset($Marine);
144 169
 
145 170
 		//getting the aircraft image
146
-		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
171
+		if ($globalDebug && $name != '') {
172
+			echo 'Try to find an vessel image for '.$name.'...';
173
+		}
147 174
 		$image_url = $this->findMarineImage($mmsi,$imo,$name);
148 175
 		if ($image_url['original'] != '') {
149
-			if ($globalDebug) echo 'Found !'."\n";
176
+			if ($globalDebug) {
177
+				echo 'Found !'."\n";
178
+			}
150 179
 			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
151 180
 			try {
152 181
 				$sth = $this->db->prepare($query);
@@ -155,7 +184,9 @@  discard block
 block discarded – undo
155 184
 				echo $e->getMessage()."\n";
156 185
 				return "error";
157 186
 			}
158
-		} elseif ($globalDebug) echo "Not found :'(\n";
187
+		} elseif ($globalDebug) {
188
+			echo "Not found :'(\n";
189
+		}
159 190
 		return "success";
160 191
 	}
161 192
 
@@ -170,41 +201,85 @@  discard block
 block discarded – undo
170 201
 	{
171 202
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
172 203
 		$Spotter = new Spotter($this->db);
173
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
204
+		if (!isset($globalIVAO)) {
205
+			$globalIVAO = FALSE;
206
+		}
174 207
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
175 208
 		if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) {
176
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
209
+			if (strpos($aircraft_registration,'/') !== false) {
210
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
211
+			}
177 212
 			$aircraft_registration = urlencode(trim($aircraft_registration));
178 213
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
179
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
180
-			else $aircraft_name = '';
181
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
182
-			else $aircraft_icao = '';
183
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
184
-			else $airline_icao = '';
214
+			if (isset($aircraft_info[0]['aircraft_name'])) {
215
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
216
+			} else {
217
+				$aircraft_name = '';
218
+			}
219
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
220
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
221
+			} else {
222
+				$aircraft_icao = '';
223
+			}
224
+			if (isset($aircraft_info[0]['airline_icao'])) {
225
+				$airline_icao = $aircraft_info[0]['airline_icao'];
226
+			} else {
227
+				$airline_icao = '';
228
+			}
185 229
 		} elseif ($aircraft_icao != '') {
186 230
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
187
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
188
-			else $aircraft_name = '';
231
+			if (isset($aircraft_info[0]['type'])) {
232
+				$aircraft_name = $aircraft_info[0]['type'];
233
+			} else {
234
+				$aircraft_name = '';
235
+			}
189 236
 			$aircraft_registration = $aircraft_icao;
190
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
237
+		} else {
238
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
239
+		}
191 240
 		unset($Spotter);
192
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
241
+		if (!isset($globalAircraftImageSources)) {
242
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
243
+		}
193 244
 		foreach ($globalAircraftImageSources as $source) {
194 245
 			$source = strtolower($source);
195
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
196
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
197
-			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
198
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
199
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
200
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
201
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
202
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
203
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
204
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
205
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
206
-		}
207
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
246
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
247
+				$images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
248
+			}
249
+			if ($source == 'planespotters' && !$globalIVAO) {
250
+				$images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
251
+			}
252
+			if ($source == 'flickr') {
253
+				$images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
254
+			}
255
+			if ($source == 'bing') {
256
+				$images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
257
+			}
258
+			if ($source == 'deviantart') {
259
+				$images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
260
+			}
261
+			if ($source == 'wikimedia') {
262
+				$images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
263
+			}
264
+			if ($source == 'jetphotos' && !$globalIVAO) {
265
+				$images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
266
+			}
267
+			if ($source == 'planepictures' && !$globalIVAO) {
268
+				$images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
269
+			}
270
+			if ($source == 'airportdata' && !$globalIVAO) {
271
+				$images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
272
+			}
273
+			if ($source == 'customsources') {
274
+				$images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
275
+			}
276
+			if (isset($images_array) && $images_array['original'] != '') {
277
+				return $images_array;
278
+			}
279
+		}
280
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
281
+			return $this->findAircraftImage($aircraft_icao);
282
+		}
208 283
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
209 284
 	}
210 285
 
@@ -224,7 +299,9 @@  discard block
 block discarded – undo
224 299
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
225 300
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
226 301
 		$name = trim($name);
227
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
302
+		if (strlen($name) < 4) {
303
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
304
+		}
228 305
 		/*
229 306
 		$Marine = new Marine($this->db);
230 307
 		if ($imo == '' || $name == '') {
@@ -236,15 +313,29 @@  discard block
 block discarded – undo
236 313
 		}
237 314
 		unset($Marine);
238 315
 		*/
239
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
316
+		if (!isset($globalMarineImageSources)) {
317
+			$globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
318
+		}
240 319
 		foreach ($globalMarineImageSources as $source) {
241 320
 			$source = strtolower($source);
242
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
243
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
244
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
245
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
246
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
247
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
321
+			if ($source == 'flickr') {
322
+				$images_array = $this->fromFlickr('marine',$mmsi,$name);
323
+			}
324
+			if ($source == 'bing') {
325
+				$images_array = $this->fromBing('marine',$mmsi,$name);
326
+			}
327
+			if ($source == 'deviantart') {
328
+				$images_array = $this->fromDeviantart('marine',$mmsi,$name);
329
+			}
330
+			if ($source == 'wikimedia') {
331
+				$images_array = $this->fromWikimedia('marine',$mmsi,$name);
332
+			}
333
+			if ($source == 'customsources') {
334
+				$images_array = $this->fromCustomSource('marine',$mmsi,$name);
335
+			}
336
+			if (isset($images_array) && $images_array['original'] != '') {
337
+				return $images_array;
338
+			}
248 339
 		}
249 340
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
250 341
 	}
@@ -407,11 +498,17 @@  discard block
 block discarded – undo
407 498
 	public function fromFlickr($type,$registration,$name='') {
408 499
 		$Common = new Common();
409 500
 		if ($type == 'aircraft') {
410
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
411
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
501
+			if ($name != '') {
502
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
503
+			} else {
504
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
505
+			}
412 506
 		} elseif ($type == 'marine') {
413
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
414
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
507
+			if ($name != '') {
508
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
509
+			} else {
510
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
511
+			}
415 512
 		}
416 513
 		$data = $Common->getData($url);
417 514
 		if ($xml = simplexml_load_string($data)) {
@@ -456,13 +553,21 @@  discard block
 block discarded – undo
456 553
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
457 554
 		global $globalImageBingKey;
458 555
 		$Common = new Common();
459
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
556
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
557
+			return false;
558
+		}
460 559
 		if ($type == 'aircraft') {
461
-			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
462
-			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
560
+			if ($aircraft_name != '') {
561
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
562
+			} else {
563
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
564
+			}
463 565
 		} elseif ($type == 'marine') {
464
-			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
465
-			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
566
+			if ($aircraft_name != '') {
567
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
568
+			} else {
569
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
570
+			}
466 571
 		}
467 572
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
468 573
 		$data = $Common->getData($url,'get','',$headers);
@@ -518,17 +623,25 @@  discard block
 block discarded – undo
518 623
 	public function fromWikimedia($type,$registration,$name='') {
519 624
 		$Common = new Common();
520 625
 		if ($type == 'aircraft') {
521
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
522
-			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
626
+			if ($name != '') {
627
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
628
+			} else {
629
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
630
+			}
523 631
 		} elseif ($type == 'marine') {
524
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
525
-			else return false;
632
+			if ($name != '') {
633
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
634
+			} else {
635
+				return false;
636
+			}
526 637
 		}
527 638
 		$data = $Common->getData($url);
528 639
 		$result = json_decode($data);
529 640
 		if (isset($result->query->search[0]->title)) {
530 641
 			$fileo = $result->query->search[0]->title;
531
-			if (substr($fileo,-3) == 'pdf') return false;
642
+			if (substr($fileo,-3) == 'pdf') {
643
+				return false;
644
+			}
532 645
 			$file = urlencode($fileo);
533 646
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
534 647
 			$data2 = $Common->getData($url2);
@@ -599,18 +712,27 @@  discard block
 block discarded – undo
599 712
 					$image_url = array();
600 713
 					$image_url['thumbnail'] = $url_thumbnail;
601 714
 					$image_url['original'] = $url;
602
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
603
-					else $exifCopyright = '';
604
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
605
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
606
-					else $image_url['copyright'] = $source['source_website'];
715
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
716
+						$exifCopyright = $this->getExifCopyright($url);
717
+					} else {
718
+						$exifCopyright = '';
719
+					}
720
+					if ($exifCopyright  != '') {
721
+						$image_url['copyright'] = $exifCopyright;
722
+					} elseif (isset($source['copyright'])) {
723
+						$image_url['copyright'] = $source['copyright'];
724
+					} else {
725
+						$image_url['copyright'] = $source['source_website'];
726
+					}
607 727
 					$image_url['source_website'] = $source['source_website'];
608 728
 					$image_url['source'] = $source['source'];
609 729
 					return $image_url;
610 730
 				}
611 731
 			}
612 732
 			return false;
613
-		} else return false;
733
+		} else {
734
+			return false;
735
+		}
614 736
 		if (!empty($globalMarineImageCustomSources) && $type == 'marine') {
615 737
 			$customsources = array();
616 738
 			if (!isset($globalMarineImageCustomSources[0])) {
@@ -635,18 +757,27 @@  discard block
 block discarded – undo
635 757
 					$image_url = array();
636 758
 					$image_url['thumbnail'] = $url_thumbnail;
637 759
 					$image_url['original'] = $url;
638
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
639
-					else $exifCopyright = '';
640
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
641
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
642
-					else $image_url['copyright'] = $source['source_website'];
760
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
761
+						$exifCopyright = $this->getExifCopyright($url);
762
+					} else {
763
+						$exifCopyright = '';
764
+					}
765
+					if ($exifCopyright  != '') {
766
+						$image_url['copyright'] = $exifCopyright;
767
+					} elseif (isset($source['copyright'])) {
768
+						$image_url['copyright'] = $source['copyright'];
769
+					} else {
770
+						$image_url['copyright'] = $source['source_website'];
771
+					}
643 772
 					$image_url['source_website'] = $source['source_website'];
644 773
 					$image_url['source'] = $source['source'];
645 774
 					return $image_url;
646 775
 				}
647 776
 			}
648 777
 			return false;
649
-		} else return false;
778
+		} else {
779
+			return false;
780
+		}
650 781
 	}
651 782
 }
652 783
 
Please login to merge, or discard this patch.
require/class.MarineArchive.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 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;
Please login to merge, or discard this patch.
Indentation   +603 added lines, -603 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 	}
10 10
 
11 11
 	/**
12
-	* Get SQL query part for filter used
13
-	* @param Array $filter the filter
14
-	* @return Array the SQL part
15
-	*/
12
+	 * Get SQL query part for filter used
13
+	 * @param Array $filter the filter
14
+	 * @return Array the SQL part
15
+	 */
16 16
 	public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 		$filters = array();
@@ -110,44 +110,44 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 
112 112
 
113
-        /**
114
-        * Gets all the spotter information based on a particular callsign
115
-        *
116
-        * @return Array the spotter information
117
-        *
118
-        */
119
-        public function getLastArchiveMarineDataByIdent($ident)
120
-        {
113
+		/**
114
+		 * Gets all the spotter information based on a particular callsign
115
+		 *
116
+		 * @return Array the spotter information
117
+		 *
118
+		 */
119
+		public function getLastArchiveMarineDataByIdent($ident)
120
+		{
121 121
 		$Marine = new Marine($this->db);
122
-                date_default_timezone_set('UTC');
122
+				date_default_timezone_set('UTC');
123 123
 
124
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
125
-                //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
-                $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
124
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
125
+				//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
+				$query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
127 127
 
128
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
128
+				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
129 129
 
130
-                return $spotter_array;
131
-        }
130
+				return $spotter_array;
131
+		}
132 132
 
133 133
 
134
-        /**
135
-        * Gets last the spotter information based on a particular id
136
-        *
137
-        * @return Array the spotter information
138
-        *
139
-        */
140
-        public function getLastArchiveMarineDataById($id)
141
-        {
142
-    		$Marine = new Marine($this->db);
143
-                date_default_timezone_set('UTC');
144
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
145
-                //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146
-                //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
-                $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
134
+		/**
135
+		 * Gets last the spotter information based on a particular id
136
+		 *
137
+		 * @return Array the spotter information
138
+		 *
139
+		 */
140
+		public function getLastArchiveMarineDataById($id)
141
+		{
142
+			$Marine = new Marine($this->db);
143
+				date_default_timezone_set('UTC');
144
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
145
+				//$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146
+				//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
+				$query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
148 148
 
149 149
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
150
-                  /*
150
+				  /*
151 151
                 try {
152 152
                         $Connection = new Connection();
153 153
                         $sth = Connection->$db->prepare($query);
@@ -157,232 +157,232 @@  discard block
 block discarded – undo
157 157
                 }
158 158
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
159 159
                 */
160
-                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
161
-
162
-                return $spotter_array;
163
-        }
164
-
165
-        /**
166
-        * Gets all the spotter information based on a particular id
167
-        *
168
-        * @return Array the spotter information
169
-        *
170
-        */
171
-        public function getAllArchiveMarineDataById($id)
160
+				$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
161
+
162
+				return $spotter_array;
163
+		}
164
+
165
+		/**
166
+		 * Gets all the spotter information based on a particular id
167
+		 *
168
+		 * @return Array the spotter information
169
+		 *
170
+		 */
171
+		public function getAllArchiveMarineDataById($id)
172 172
 	{
173
-                date_default_timezone_set('UTC');
174
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
175
-                $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
173
+				date_default_timezone_set('UTC');
174
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
175
+				$query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
176 176
 
177 177
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
178 178
 
179
-                try {
180
-                        $sth = $this->db->prepare($query);
181
-                        $sth->execute(array(':id' => $id));
182
-                } catch(PDOException $e) {
183
-                        echo $e->getMessage();
184
-                        die;
185
-                }
186
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
187
-
188
-                return $spotter_array;
189
-        }
190
-
191
-        /**
192
-        * Gets coordinate & time spotter information based on a particular id
193
-        *
194
-        * @return Array the spotter information
195
-        *
196
-        */
197
-        public function getCoordArchiveMarineDataById($id)
198
-        {
199
-                date_default_timezone_set('UTC');
200
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
201
-                $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
179
+				try {
180
+						$sth = $this->db->prepare($query);
181
+						$sth->execute(array(':id' => $id));
182
+				} catch(PDOException $e) {
183
+						echo $e->getMessage();
184
+						die;
185
+				}
186
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
187
+
188
+				return $spotter_array;
189
+		}
190
+
191
+		/**
192
+		 * Gets coordinate & time spotter information based on a particular id
193
+		 *
194
+		 * @return Array the spotter information
195
+		 *
196
+		 */
197
+		public function getCoordArchiveMarineDataById($id)
198
+		{
199
+				date_default_timezone_set('UTC');
200
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
201
+				$query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
202 202
 
203 203
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
204 204
 
205
-                try {
206
-                        $sth = $this->db->prepare($query);
207
-                        $sth->execute(array(':id' => $id));
208
-                } catch(PDOException $e) {
209
-                        echo $e->getMessage();
210
-                        die;
211
-                }
212
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
205
+				try {
206
+						$sth = $this->db->prepare($query);
207
+						$sth->execute(array(':id' => $id));
208
+				} catch(PDOException $e) {
209
+						echo $e->getMessage();
210
+						die;
211
+				}
212
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
213 213
 
214
-                return $spotter_array;
215
-        }
214
+				return $spotter_array;
215
+		}
216 216
 
217 217
 
218
-        /**
219
-        * Gets altitude information based on a particular callsign
220
-        *
221
-        * @return Array the spotter information
222
-        *
223
-        */
224
-        public function getAltitudeArchiveMarineDataByIdent($ident)
225
-        {
218
+		/**
219
+		 * Gets altitude information based on a particular callsign
220
+		 *
221
+		 * @return Array the spotter information
222
+		 *
223
+		 */
224
+		public function getAltitudeArchiveMarineDataByIdent($ident)
225
+		{
226 226
 
227
-                date_default_timezone_set('UTC');
227
+				date_default_timezone_set('UTC');
228 228
 
229
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
229
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
231 231
 
232
-                try {
233
-                        $sth = $this->db->prepare($query);
234
-                        $sth->execute(array(':ident' => $ident));
235
-                } catch(PDOException $e) {
236
-                        echo $e->getMessage();
237
-                        die;
238
-                }
239
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
232
+				try {
233
+						$sth = $this->db->prepare($query);
234
+						$sth->execute(array(':ident' => $ident));
235
+				} catch(PDOException $e) {
236
+						echo $e->getMessage();
237
+						die;
238
+				}
239
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
240 240
 
241
-                return $spotter_array;
242
-        }
241
+				return $spotter_array;
242
+		}
243 243
 
244
-        /**
245
-        * Gets altitude information based on a particular id
246
-        *
247
-        * @return Array the spotter information
248
-        *
249
-        */
250
-        public function getAltitudeArchiveMarineDataById($id)
251
-        {
244
+		/**
245
+		 * Gets altitude information based on a particular id
246
+		 *
247
+		 * @return Array the spotter information
248
+		 *
249
+		 */
250
+		public function getAltitudeArchiveMarineDataById($id)
251
+		{
252 252
 
253
-                date_default_timezone_set('UTC');
253
+				date_default_timezone_set('UTC');
254 254
 
255
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
256
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
255
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
256
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
257 257
 
258
-                try {
259
-                        $sth = $this->db->prepare($query);
260
-                        $sth->execute(array(':id' => $id));
261
-                } catch(PDOException $e) {
262
-                        echo $e->getMessage();
263
-                        die;
264
-                }
265
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
258
+				try {
259
+						$sth = $this->db->prepare($query);
260
+						$sth->execute(array(':id' => $id));
261
+				} catch(PDOException $e) {
262
+						echo $e->getMessage();
263
+						die;
264
+				}
265
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
266 266
 
267
-                return $spotter_array;
268
-        }
267
+				return $spotter_array;
268
+		}
269 269
 
270
-        /**
271
-        * Gets altitude & speed information based on a particular id
272
-        *
273
-        * @return Array the spotter information
274
-        *
275
-        */
276
-        public function getAltitudeSpeedArchiveMarineDataById($id)
277
-        {
270
+		/**
271
+		 * Gets altitude & speed information based on a particular id
272
+		 *
273
+		 * @return Array the spotter information
274
+		 *
275
+		 */
276
+		public function getAltitudeSpeedArchiveMarineDataById($id)
277
+		{
278 278
 
279
-                date_default_timezone_set('UTC');
279
+				date_default_timezone_set('UTC');
280 280
 
281
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
282
-                $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
281
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
282
+				$query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
283 283
 
284
-                try {
285
-                        $sth = $this->db->prepare($query);
286
-                        $sth->execute(array(':id' => $id));
287
-                } catch(PDOException $e) {
288
-                        echo $e->getMessage();
289
-                        die;
290
-                }
291
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				try {
285
+						$sth = $this->db->prepare($query);
286
+						$sth->execute(array(':id' => $id));
287
+				} catch(PDOException $e) {
288
+						echo $e->getMessage();
289
+						die;
290
+				}
291
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
292 292
 
293
-                return $spotter_array;
294
-        }
293
+				return $spotter_array;
294
+		}
295 295
 
296 296
 
297
-        /**
298
-        * Gets altitude information based on a particular callsign
299
-        *
300
-        * @return Array the spotter information
301
-        *
302
-        */
303
-        public function getLastAltitudeArchiveMarineDataByIdent($ident)
304
-        {
297
+		/**
298
+		 * Gets altitude information based on a particular callsign
299
+		 *
300
+		 * @return Array the spotter information
301
+		 *
302
+		 */
303
+		public function getLastAltitudeArchiveMarineDataByIdent($ident)
304
+		{
305 305
 
306
-                date_default_timezone_set('UTC');
306
+				date_default_timezone_set('UTC');
307 307
 
308
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
308
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
310 310
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
311 311
 
312
-                try {
313
-                        $sth = $this->db->prepare($query);
314
-                        $sth->execute(array(':ident' => $ident));
315
-                } catch(PDOException $e) {
316
-                        echo $e->getMessage();
317
-                        die;
318
-                }
319
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
312
+				try {
313
+						$sth = $this->db->prepare($query);
314
+						$sth->execute(array(':ident' => $ident));
315
+				} catch(PDOException $e) {
316
+						echo $e->getMessage();
317
+						die;
318
+				}
319
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
320 320
 
321
-                return $spotter_array;
322
-        }
321
+				return $spotter_array;
322
+		}
323 323
 
324 324
 
325 325
 
326
-       /**
327
-        * Gets all the archive spotter information
328
-        *
329
-        * @return Array the spotter information
330
-        *
331
-        */
332
-        public function getMarineArchiveData($ident,$fammarine_id,$date)
333
-        {
334
-    		$Marine = new Marine($this->db);
335
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
336
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
326
+	   /**
327
+	    * Gets all the archive spotter information
328
+	    *
329
+	    * @return Array the spotter information
330
+	    *
331
+	    */
332
+		public function getMarineArchiveData($ident,$fammarine_id,$date)
333
+		{
334
+			$Marine = new Marine($this->db);
335
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
336
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
337 337
 
338
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
338
+				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
339 339
 
340
-                return $spotter_array;
341
-        }
340
+				return $spotter_array;
341
+		}
342 342
         
343
-        public function deleteMarineArchiveTrackData()
344
-        {
343
+		public function deleteMarineArchiveTrackData()
344
+		{
345 345
 		global $globalArchiveKeepTrackMonths;
346
-                date_default_timezone_set('UTC');
346
+				date_default_timezone_set('UTC');
347 347
 		$query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
348
-                try {
349
-                        $sth = $this->db->prepare($query);
350
-                        $sth->execute();
351
-                } catch(PDOException $e) {
352
-                        echo $e->getMessage();
353
-                        die;
354
-                }
348
+				try {
349
+						$sth = $this->db->prepare($query);
350
+						$sth->execute();
351
+				} catch(PDOException $e) {
352
+						echo $e->getMessage();
353
+						die;
354
+				}
355 355
 	}
356 356
 
357 357
 	/**
358
-        * Gets Minimal Live Marine data
359
-        *
360
-        * @return Array the spotter information
361
-        *
362
-        */
363
-        public function getMinLiveMarineData($begindate,$enddate,$filter = array())
364
-        {
365
-                global $globalDBdriver, $globalLiveInterval;
366
-                date_default_timezone_set('UTC');
367
-
368
-                $filter_query = '';
369
-                if (isset($filter['source']) && !empty($filter['source'])) {
370
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
-                }
372
-                // Use spotter_output also ?
373
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
375
-                }
376
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
378
-                }
379
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
-                }
358
+	 * Gets Minimal Live Marine data
359
+	 *
360
+	 * @return Array the spotter information
361
+	 *
362
+	 */
363
+		public function getMinLiveMarineData($begindate,$enddate,$filter = array())
364
+		{
365
+				global $globalDBdriver, $globalLiveInterval;
366
+				date_default_timezone_set('UTC');
367
+
368
+				$filter_query = '';
369
+				if (isset($filter['source']) && !empty($filter['source'])) {
370
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
+				}
372
+				// Use spotter_output also ?
373
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
375
+				}
376
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
378
+				}
379
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
+				}
382 382
 
383
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
-                if ($globalDBdriver == 'mysql') {
385
-                        /*
383
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
+				if ($globalDBdriver == 'mysql') {
385
+						/*
386 386
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
387 387
                     		    FROM marine_archive 
388 388
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
@@ -401,56 +401,56 @@  discard block
 block discarded – undo
401 401
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
402 402
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
403 403
                         	    '.$filter_query.' ORDER BY fammarine_id';
404
-                } else {
405
-                        //$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
406
-                        $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
404
+				} else {
405
+						//$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
406
+						$query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
407 407
                         	    FROM marine_archive 
408 408
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
409 409
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
410 410
                         	    '.$filter_query.' ORDER BY fammarine_id';
411
-                }
412
-                //echo $query;
413
-                try {
414
-                        $sth = $this->db->prepare($query);
415
-                        $sth->execute();
416
-                } catch(PDOException $e) {
417
-                        echo $e->getMessage();
418
-                        die;
419
-                }
420
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
411
+				}
412
+				//echo $query;
413
+				try {
414
+						$sth = $this->db->prepare($query);
415
+						$sth->execute();
416
+				} catch(PDOException $e) {
417
+						echo $e->getMessage();
418
+						die;
419
+				}
420
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
421 421
 
422
-                return $spotter_array;
423
-        }
422
+				return $spotter_array;
423
+		}
424 424
 
425 425
 	/**
426
-        * Gets Minimal Live Marine data
427
-        *
428
-        * @return Array the spotter information
429
-        *
430
-        */
431
-        public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
432
-        {
433
-                global $globalDBdriver, $globalLiveInterval;
434
-                date_default_timezone_set('UTC');
435
-
436
-                $filter_query = '';
437
-                if (isset($filter['source']) && !empty($filter['source'])) {
438
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
-                }
440
-                // Should use spotter_output also ?
441
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
443
-                }
444
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
446
-                }
447
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
-                }
426
+	 * Gets Minimal Live Marine data
427
+	 *
428
+	 * @return Array the spotter information
429
+	 *
430
+	 */
431
+		public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
432
+		{
433
+				global $globalDBdriver, $globalLiveInterval;
434
+				date_default_timezone_set('UTC');
435
+
436
+				$filter_query = '';
437
+				if (isset($filter['source']) && !empty($filter['source'])) {
438
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
+				}
440
+				// Should use spotter_output also ?
441
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
443
+				}
444
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
446
+				}
447
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
+				}
450 450
 
451
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
-                if ($globalDBdriver == 'mysql') {
453
-                        /*
451
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
+				if ($globalDBdriver == 'mysql') {
453
+						/*
454 454
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
455 455
                     		    FROM marine_archive 
456 456
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
@@ -461,95 +461,95 @@  discard block
 block discarded – undo
461 461
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
462 462
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
463 463
 
464
-                } else {
465
-                        //$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
466
-                       /*
464
+				} else {
465
+						//$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
466
+					   /*
467 467
                         $query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
468 468
                         	    FROM marine_archive_output 
469 469
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
470 470
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
471 471
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
472 472
                         */
473
-                        $query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
473
+						$query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
474 474
                         	    FROM marine_archive_output 
475 475
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
476 476
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
477 477
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
478 478
 //                        	    .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
479 479
                         	    
480
-                }
481
-                //echo $query;
482
-                try {
483
-                        $sth = $this->db->prepare($query);
484
-                        $sth->execute();
485
-                } catch(PDOException $e) {
486
-                        echo $e->getMessage();
487
-                        die;
488
-                }
489
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
480
+				}
481
+				//echo $query;
482
+				try {
483
+						$sth = $this->db->prepare($query);
484
+						$sth->execute();
485
+				} catch(PDOException $e) {
486
+						echo $e->getMessage();
487
+						die;
488
+				}
489
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
490 490
 
491
-                return $spotter_array;
492
-        }
491
+				return $spotter_array;
492
+		}
493 493
 
494 494
 	 /**
495
-        * Gets count Live Marine data
496
-        *
497
-        * @return Array the spotter information
498
-        *
499
-        */
500
-        public function getLiveMarineCount($begindate,$enddate,$filter = array())
501
-        {
502
-                global $globalDBdriver, $globalLiveInterval;
503
-                date_default_timezone_set('UTC');
504
-
505
-                $filter_query = '';
506
-                if (isset($filter['source']) && !empty($filter['source'])) {
507
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
-                }
509
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
511
-                }
512
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
514
-                }
515
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
-                }
495
+	  * Gets count Live Marine data
496
+	  *
497
+	  * @return Array the spotter information
498
+	  *
499
+	  */
500
+		public function getLiveMarineCount($begindate,$enddate,$filter = array())
501
+		{
502
+				global $globalDBdriver, $globalLiveInterval;
503
+				date_default_timezone_set('UTC');
518 504
 
519
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
-                if ($globalDBdriver == 'mysql') {
505
+				$filter_query = '';
506
+				if (isset($filter['source']) && !empty($filter['source'])) {
507
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
+				}
509
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
511
+				}
512
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
514
+				}
515
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
+				}
518
+
519
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
+				if ($globalDBdriver == 'mysql') {
521 521
 			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb 
522 522
 			FROM marine_archive l 
523 523
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
524
-                } else {
524
+				} else {
525 525
 			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
526
-                }
527
-                //echo $query;
528
-                try {
529
-                        $sth = $this->db->prepare($query);
530
-                        $sth->execute();
531
-                } catch(PDOException $e) {
532
-                        echo $e->getMessage();
533
-                        die;
534
-                }
526
+				}
527
+				//echo $query;
528
+				try {
529
+						$sth = $this->db->prepare($query);
530
+						$sth->execute();
531
+				} catch(PDOException $e) {
532
+						echo $e->getMessage();
533
+						die;
534
+				}
535 535
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
536 536
 		$sth->closeCursor();
537
-                return $result['nb'];
537
+				return $result['nb'];
538 538
 
539
-        }
539
+		}
540 540
 
541 541
 
542 542
 
543 543
 	// marine_archive_output
544 544
 	
545
-    /**
546
-    * Gets all the spotter information
547
-    *
548
-    * @return Array the spotter information
549
-    *
550
-    */
551
-    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
-    {
545
+	/**
546
+	 * Gets all the spotter information
547
+	 *
548
+	 * @return Array the spotter information
549
+	 *
550
+	 */
551
+	public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
+	{
553 553
 	global $globalTimezone, $globalDBdriver;
554 554
 	require_once(dirname(__FILE__).'/class.Translation.php');
555 555
 	$Translation = new Translation();
@@ -563,159 +563,159 @@  discard block
 block discarded – undo
563 563
 	$filter_query = $this->getFilter($filters);
564 564
 	if ($q != "")
565 565
 	{
566
-	    if (!is_string($q))
567
-	    {
566
+		if (!is_string($q))
567
+		{
568 568
 		return false;
569
-	    } else {
569
+		} else {
570 570
 	        
571 571
 		$q_array = explode(" ", $q);
572 572
 		
573 573
 		foreach ($q_array as $q_item){
574
-		    $additional_query .= " AND (";
575
-		    $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
576
-		    $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
-		    $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
-		    $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
-		    $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
580
-		    $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
581
-		    $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
582
-		    $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
-		    $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
-		    $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
-		    $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
-		    $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
-		    $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
-		    $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
-		    $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
-		    $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
591
-		    $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
592
-		    $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
593
-		    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
594
-		    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
595
-		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
597
-		    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
598
-		    $additional_query .= ")";
574
+			$additional_query .= " AND (";
575
+			$additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
576
+			$additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
+			$additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
+			$additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
+			$additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
580
+			$additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
581
+			$additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
582
+			$additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
+			$additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
+			$additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
+			$additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
+			$additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
+			$additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
+			$additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
+			$additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
+			$additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
591
+			$additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
592
+			$additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
593
+			$additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
594
+			$additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
595
+			$translate = $Translation->ident2icao($q_item);
596
+			if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
597
+			$additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
598
+			$additional_query .= ")";
599
+		}
599 600
 		}
600
-	    }
601 601
 	}
602 602
 	
603 603
 	if ($registration != "")
604 604
 	{
605
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
-	    if (!is_string($registration))
607
-	    {
605
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
+		if (!is_string($registration))
607
+		{
608 608
 		return false;
609
-	    } else {
609
+		} else {
610 610
 		$additional_query .= " AND (marine_archive_output.registration = '".$registration."')";
611
-	    }
611
+		}
612 612
 	}
613 613
 	
614 614
 	if ($aircraft_icao != "")
615 615
 	{
616
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
-	    if (!is_string($aircraft_icao))
618
-	    {
616
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
+		if (!is_string($aircraft_icao))
618
+		{
619 619
 		return false;
620
-	    } else {
620
+		} else {
621 621
 		$additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')";
622
-	    }
622
+		}
623 623
 	}
624 624
 	
625 625
 	if ($aircraft_manufacturer != "")
626 626
 	{
627
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
-	    if (!is_string($aircraft_manufacturer))
629
-	    {
627
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
+		if (!is_string($aircraft_manufacturer))
629
+		{
630 630
 		return false;
631
-	    } else {
631
+		} else {
632 632
 		$additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
633
-	    }
633
+		}
634 634
 	}
635 635
 	
636 636
 	if ($highlights == "true")
637 637
 	{
638
-	    if (!is_string($highlights))
639
-	    {
638
+		if (!is_string($highlights))
639
+		{
640 640
 		return false;
641
-	    } else {
641
+		} else {
642 642
 		$additional_query .= " AND (marine_archive_output.highlight <> '')";
643
-	    }
643
+		}
644 644
 	}
645 645
 	
646 646
 	if ($airline_icao != "")
647 647
 	{
648
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
-	    if (!is_string($airline_icao))
650
-	    {
648
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
+		if (!is_string($airline_icao))
650
+		{
651 651
 		return false;
652
-	    } else {
652
+		} else {
653 653
 		$additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')";
654
-	    }
654
+		}
655 655
 	}
656 656
 	
657 657
 	if ($airline_country != "")
658 658
 	{
659
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
-	    if (!is_string($airline_country))
661
-	    {
659
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
+		if (!is_string($airline_country))
661
+		{
662 662
 		return false;
663
-	    } else {
663
+		} else {
664 664
 		$additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')";
665
-	    }
665
+		}
666 666
 	}
667 667
 	
668 668
 	if ($airline_type != "")
669 669
 	{
670
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
-	    if (!is_string($airline_type))
672
-	    {
670
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
+		if (!is_string($airline_type))
672
+		{
673 673
 		return false;
674
-	    } else {
674
+		} else {
675 675
 		if ($airline_type == "passenger")
676 676
 		{
677
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
677
+			$additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
678 678
 		}
679 679
 		if ($airline_type == "cargo")
680 680
 		{
681
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
681
+			$additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
682 682
 		}
683 683
 		if ($airline_type == "military")
684 684
 		{
685
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'military')";
685
+			$additional_query .= " AND (marine_archive_output.airline_type = 'military')";
686
+		}
686 687
 		}
687
-	    }
688 688
 	}
689 689
 	
690 690
 	if ($airport != "")
691 691
 	{
692
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
-	    if (!is_string($airport))
694
-	    {
692
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
+		if (!is_string($airport))
694
+		{
695 695
 		return false;
696
-	    } else {
696
+		} else {
697 697
 		$additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))";
698
-	    }
698
+		}
699 699
 	}
700 700
 	
701 701
 	if ($airport_country != "")
702 702
 	{
703
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
-	    if (!is_string($airport_country))
705
-	    {
703
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
+		if (!is_string($airport_country))
705
+		{
706 706
 		return false;
707
-	    } else {
707
+		} else {
708 708
 		$additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))";
709
-	    }
709
+		}
710 710
 	}
711 711
     
712 712
 	if ($callsign != "")
713 713
 	{
714
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
-	    if (!is_string($callsign))
716
-	    {
714
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
+		if (!is_string($callsign))
716
+		{
717 717
 		return false;
718
-	    } else {
718
+		} else {
719 719
 		$translate = $Translation->ident2icao($callsign);
720 720
 		if ($translate != $callsign) {
721 721
 			$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
@@ -723,99 +723,99 @@  discard block
 block discarded – undo
723 723
 		} else {
724 724
 			$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
725 725
 		}
726
-	    }
726
+		}
727 727
 	}
728 728
 
729 729
 	if ($owner != "")
730 730
 	{
731
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
-	    if (!is_string($owner))
733
-	    {
731
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
+		if (!is_string($owner))
733
+		{
734 734
 		return false;
735
-	    } else {
735
+		} else {
736 736
 		$additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')";
737
-	    }
737
+		}
738 738
 	}
739 739
 
740 740
 	if ($pilot_name != "")
741 741
 	{
742
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
-	    if (!is_string($pilot_name))
744
-	    {
742
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
+		if (!is_string($pilot_name))
744
+		{
745 745
 		return false;
746
-	    } else {
746
+		} else {
747 747
 		$additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')";
748
-	    }
748
+		}
749 749
 	}
750 750
 	
751 751
 	if ($pilot_id != "")
752 752
 	{
753
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
-	    if (!is_string($pilot_id))
755
-	    {
753
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
+		if (!is_string($pilot_id))
755
+		{
756 756
 		return false;
757
-	    } else {
757
+		} else {
758 758
 		$additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')";
759
-	    }
759
+		}
760 760
 	}
761 761
 	
762 762
 	if ($departure_airport_route != "")
763 763
 	{
764
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
-	    if (!is_string($departure_airport_route))
766
-	    {
764
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
+		if (!is_string($departure_airport_route))
766
+		{
767 767
 		return false;
768
-	    } else {
768
+		} else {
769 769
 		$additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')";
770
-	    }
770
+		}
771 771
 	}
772 772
 	
773 773
 	if ($arrival_airport_route != "")
774 774
 	{
775
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
-	    if (!is_string($arrival_airport_route))
777
-	    {
775
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
+		if (!is_string($arrival_airport_route))
777
+		{
778 778
 		return false;
779
-	    } else {
779
+		} else {
780 780
 		$additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
781
-	    }
781
+		}
782 782
 	}
783 783
 	
784 784
 	if ($altitude != "")
785 785
 	{
786
-	    $altitude_array = explode(",", $altitude);
786
+		$altitude_array = explode(",", $altitude);
787 787
 	    
788
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
790 790
 	    
791 791
 
792
-	    if ($altitude_array[1] != "")
793
-	    {                
792
+		if ($altitude_array[1] != "")
793
+		{                
794 794
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
795 795
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
796 796
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
797
-	    } else {
797
+		} else {
798 798
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
799 799
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
800
-	    }
800
+		}
801 801
 	}
802 802
 	
803 803
 	if ($date_posted != "")
804 804
 	{
805
-	    $date_array = explode(",", $date_posted);
805
+		$date_array = explode(",", $date_posted);
806 806
 	    
807
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
809 809
 	    
810
-	    if ($globalTimezone != '') {
810
+		if ($globalTimezone != '') {
811 811
 		date_default_timezone_set($globalTimezone);
812 812
 		$datetime = new DateTime();
813 813
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
814
+		} else $offset = '+00:00';
815 815
 
816 816
 
817
-	    if ($date_array[1] != "")
818
-	    {                
817
+		if ($date_array[1] != "")
818
+		{                
819 819
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
820 820
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
821 821
 		if ($globalDBdriver == 'mysql') {
@@ -823,28 +823,28 @@  discard block
 block discarded – undo
823 823
 		} else {
824 824
 			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
825 825
 		}
826
-	    } else {
826
+		} else {
827 827
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
828
-                if ($globalDBdriver == 'mysql') {
828
+				if ($globalDBdriver == 'mysql') {
829 829
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
830 830
 		} else {
831 831
 			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
832 832
 		}
833
-	    }
833
+		}
834 834
 	}
835 835
 	
836 836
 	if ($limit != "")
837 837
 	{
838
-	    $limit_array = explode(",", $limit);
838
+		$limit_array = explode(",", $limit);
839 839
 	    
840
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
842 842
 	    
843
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
-	    {
843
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
+		{
845 845
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
846 846
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
847
-	    }
847
+		}
848 848
 	}
849 849
 	
850 850
 
@@ -875,33 +875,33 @@  discard block
 block discarded – undo
875 875
 	$spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
876 876
 
877 877
 	return $spotter_array;
878
-    }
878
+	}
879 879
 
880
-    public function deleteMarineArchiveData()
881
-    {
880
+	public function deleteMarineArchiveData()
881
+	{
882 882
 		global $globalArchiveKeepMonths, $globalDBdriver;
883
-                date_default_timezone_set('UTC');
884
-                if ($globalDBdriver == 'mysql') {
883
+				date_default_timezone_set('UTC');
884
+				if ($globalDBdriver == 'mysql') {
885 885
 			$query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
886 886
 		} else {
887 887
 			$query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
888 888
 		}
889
-                try {
890
-                        $sth = $this->db->prepare($query);
891
-                        $sth->execute();
892
-                } catch(PDOException $e) {
893
-                        return "error";
894
-                }
889
+				try {
890
+						$sth = $this->db->prepare($query);
891
+						$sth->execute();
892
+				} catch(PDOException $e) {
893
+						return "error";
894
+				}
895 895
 	}
896 896
 
897
-    /**
898
-    * Gets all the spotter information based on the callsign
899
-    *
900
-    * @return Array the spotter information
901
-    *
902
-    */
903
-    public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
904
-    {
897
+	/**
898
+	 * Gets all the spotter information based on the callsign
899
+	 *
900
+	 * @return Array the spotter information
901
+	 *
902
+	 */
903
+	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
904
+	{
905 905
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
906 906
 	
907 907
 	date_default_timezone_set('UTC');
@@ -913,35 +913,35 @@  discard block
 block discarded – undo
913 913
 	
914 914
 	if ($ident != "")
915 915
 	{
916
-	    if (!is_string($ident))
917
-	    {
916
+		if (!is_string($ident))
917
+		{
918 918
 		return false;
919
-	    } else {
919
+		} else {
920 920
 		$additional_query = " AND (marine_archive_output.ident = :ident)";
921 921
 		$query_values = array(':ident' => $ident);
922
-	    }
922
+		}
923 923
 	}
924 924
 	
925 925
 	if ($limit != "")
926 926
 	{
927
-	    $limit_array = explode(",", $limit);
927
+		$limit_array = explode(",", $limit);
928 928
 	    
929
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
931 931
 	    
932
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
-	    {
932
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
+		{
934 934
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
935 935
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
936
-	    }
936
+		}
937 937
 	}
938 938
 
939 939
 	if ($sort != "")
940 940
 	{
941
-	    $search_orderby_array = $Marine->getOrderBy();
942
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
941
+		$search_orderby_array = $Marine->getOrderBy();
942
+		$orderby_query = $search_orderby_array[$sort]['sql'];
943 943
 	} else {
944
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
944
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
945 945
 	}
946 946
 
947 947
 	$query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -949,17 +949,17 @@  discard block
 block discarded – undo
949 949
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
950 950
 
951 951
 	return $spotter_array;
952
-    }
952
+	}
953 953
 
954 954
 
955
-    /**
956
-    * Gets all the spotter information based on the owner
957
-    *
958
-    * @return Array the spotter information
959
-    *
960
-    */
961
-    public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
-    {
955
+	/**
956
+	 * Gets all the spotter information based on the owner
957
+	 *
958
+	 * @return Array the spotter information
959
+	 *
960
+	 */
961
+	public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
+	{
963 963
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
964 964
 	
965 965
 	date_default_timezone_set('UTC');
@@ -972,35 +972,35 @@  discard block
 block discarded – undo
972 972
 	
973 973
 	if ($owner != "")
974 974
 	{
975
-	    if (!is_string($owner))
976
-	    {
975
+		if (!is_string($owner))
976
+		{
977 977
 		return false;
978
-	    } else {
978
+		} else {
979 979
 		$additional_query = " AND (marine_archive_output.owner_name = :owner)";
980 980
 		$query_values = array(':owner' => $owner);
981
-	    }
981
+		}
982 982
 	}
983 983
 	
984 984
 	if ($limit != "")
985 985
 	{
986
-	    $limit_array = explode(",", $limit);
986
+		$limit_array = explode(",", $limit);
987 987
 	    
988
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
-	    {
991
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
+		{
993 993
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
994 994
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
995
-	    }
995
+		}
996 996
 	}
997 997
 
998 998
 	if ($sort != "")
999 999
 	{
1000
-	    $search_orderby_array = $Marine->getOrderBy();
1001
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1000
+		$search_orderby_array = $Marine->getOrderBy();
1001
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1002 1002
 	} else {
1003
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1003
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1004 1004
 	}
1005 1005
 
1006 1006
 	$query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1008,16 +1008,16 @@  discard block
 block discarded – undo
1008 1008
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1009 1009
 
1010 1010
 	return $spotter_array;
1011
-    }
1012
-
1013
-    /**
1014
-    * Gets all the spotter information based on the pilot
1015
-    *
1016
-    * @return Array the spotter information
1017
-    *
1018
-    */
1019
-    public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
-    {
1011
+	}
1012
+
1013
+	/**
1014
+	 * Gets all the spotter information based on the pilot
1015
+	 *
1016
+	 * @return Array the spotter information
1017
+	 *
1018
+	 */
1019
+	public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
+	{
1021 1021
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
1022 1022
 	
1023 1023
 	date_default_timezone_set('UTC');
@@ -1036,24 +1036,24 @@  discard block
 block discarded – undo
1036 1036
 	
1037 1037
 	if ($limit != "")
1038 1038
 	{
1039
-	    $limit_array = explode(",", $limit);
1039
+		$limit_array = explode(",", $limit);
1040 1040
 	    
1041
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1043 1043
 	    
1044
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
-	    {
1044
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
+		{
1046 1046
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1047 1047
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1048
-	    }
1048
+		}
1049 1049
 	}
1050 1050
 
1051 1051
 	if ($sort != "")
1052 1052
 	{
1053
-	    $search_orderby_array = $Marine->getOrderBy();
1054
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1053
+		$search_orderby_array = $Marine->getOrderBy();
1054
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1055 1055
 	} else {
1056
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1056
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1057 1057
 	}
1058 1058
 
1059 1059
 	$query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1061,16 +1061,16 @@  discard block
 block discarded – undo
1061 1061
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1062 1062
 
1063 1063
 	return $spotter_array;
1064
-    }
1065
-
1066
-    /**
1067
-    * Gets all number of flight over countries
1068
-    *
1069
-    * @return Array the airline country list
1070
-    *
1071
-    */
1072
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
-    {
1064
+	}
1065
+
1066
+	/**
1067
+	 * Gets all number of flight over countries
1068
+	 *
1069
+	 * @return Array the airline country list
1070
+	 *
1071
+	 */
1072
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
+	{
1074 1074
 	global $globalDBdriver;
1075 1075
 	/*
1076 1076
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1080,14 +1080,14 @@  discard block
 block discarded – undo
1080 1080
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1081 1081
 		    FROM countries c, marine_archive s
1082 1082
 		    WHERE c.iso2 = s.over_country ";
1083
-                if ($olderthanmonths > 0) {
1084
-            		if ($globalDBdriver == 'mysql') {
1083
+				if ($olderthanmonths > 0) {
1084
+					if ($globalDBdriver == 'mysql') {
1085 1085
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1086 1086
 			} else {
1087 1087
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1088
 			}
1089 1089
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1090
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1091 1091
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092 1092
 	if ($limit) $query .= " LIMIT 0,10";
1093 1093
       
@@ -1100,23 +1100,23 @@  discard block
 block discarded – undo
1100 1100
         
1101 1101
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1102 1102
 	{
1103
-	    $temp_array['flight_count'] = $row['nb'];
1104
-	    $temp_array['flight_country'] = $row['name'];
1105
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1106
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1107
-	    $flight_array[] = $temp_array;
1103
+		$temp_array['flight_count'] = $row['nb'];
1104
+		$temp_array['flight_country'] = $row['name'];
1105
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1106
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1107
+		$flight_array[] = $temp_array;
1108 1108
 	}
1109 1109
 	return $flight_array;
1110
-    }
1111
-
1112
-    /**
1113
-    * Gets all number of flight over countries
1114
-    *
1115
-    * @return Array the airline country list
1116
-    *
1117
-    */
1118
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
-    {
1110
+	}
1111
+
1112
+	/**
1113
+	 * Gets all number of flight over countries
1114
+	 *
1115
+	 * @return Array the airline country list
1116
+	 *
1117
+	 */
1118
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
+	{
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
1122 1122
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1126,14 +1126,14 @@  discard block
 block discarded – undo
1126 1126
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1127 1127
 		    FROM countries c, marine_archive s, spotter_output o
1128 1128
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id ";
1129
-                if ($olderthanmonths > 0) {
1130
-            		if ($globalDBdriver == 'mysql') {
1129
+				if ($olderthanmonths > 0) {
1130
+					if ($globalDBdriver == 'mysql') {
1131 1131
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1132 1132
 			} else {
1133 1133
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1134
 			}
1135 1135
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1136
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1137 1137
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138 1138
 	if ($limit) $query .= " LIMIT 0,10";
1139 1139
       
@@ -1146,24 +1146,24 @@  discard block
 block discarded – undo
1146 1146
         
1147 1147
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1150
-	    $temp_array['flight_count'] = $row['nb'];
1151
-	    $temp_array['flight_country'] = $row['name'];
1152
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1153
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1154
-	    $flight_array[] = $temp_array;
1149
+		$temp_array['airline_icao'] = $row['airline_icao'];
1150
+		$temp_array['flight_count'] = $row['nb'];
1151
+		$temp_array['flight_country'] = $row['name'];
1152
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1153
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1154
+		$flight_array[] = $temp_array;
1155 1155
 	}
1156 1156
 	return $flight_array;
1157
-    }
1158
-
1159
-    /**
1160
-    * Gets last spotter information based on a particular callsign
1161
-    *
1162
-    * @return Array the spotter information
1163
-    *
1164
-    */
1165
-    public function getDateArchiveMarineDataById($id,$date)
1166
-    {
1157
+	}
1158
+
1159
+	/**
1160
+	 * Gets last spotter information based on a particular callsign
1161
+	 *
1162
+	 * @return Array the spotter information
1163
+	 *
1164
+	 */
1165
+	public function getDateArchiveMarineDataById($id,$date)
1166
+	{
1167 1167
 	$Marine = new Marine($this->db);
1168 1168
 	date_default_timezone_set('UTC');
1169 1169
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1171,16 +1171,16 @@  discard block
 block discarded – undo
1171 1171
 	$date = date('c',$date);
1172 1172
 	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1173 1173
 	return $spotter_array;
1174
-    }
1175
-
1176
-    /**
1177
-    * Gets all the spotter information based on a particular callsign
1178
-    *
1179
-    * @return Array the spotter information
1180
-    *
1181
-    */
1182
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1183
-    {
1174
+	}
1175
+
1176
+	/**
1177
+	 * Gets all the spotter information based on a particular callsign
1178
+	 *
1179
+	 * @return Array the spotter information
1180
+	 *
1181
+	 */
1182
+	public function getDateArchiveMarineDataByIdent($ident,$date)
1183
+	{
1184 1184
 	$Marine = new Marine($this->db);
1185 1185
 	date_default_timezone_set('UTC');
1186 1186
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1188,16 +1188,16 @@  discard block
 block discarded – undo
1188 1188
 	$date = date('c',$date);
1189 1189
 	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1190 1190
 	return $spotter_array;
1191
-    }
1192
-
1193
-    /**
1194
-    * Gets all the spotter information based on the airport
1195
-    *
1196
-    * @return Array the spotter information
1197
-    *
1198
-    */
1199
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
-    {
1191
+	}
1192
+
1193
+	/**
1194
+	 * Gets all the spotter information based on the airport
1195
+	 *
1196
+	 * @return Array the spotter information
1197
+	 *
1198
+	 */
1199
+	public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
+	{
1201 1201
 	global $global_query;
1202 1202
 	$Marine = new Marine();
1203 1203
 	date_default_timezone_set('UTC');
@@ -1208,35 +1208,35 @@  discard block
 block discarded – undo
1208 1208
 	
1209 1209
 	if ($airport != "")
1210 1210
 	{
1211
-	    if (!is_string($airport))
1212
-	    {
1211
+		if (!is_string($airport))
1212
+		{
1213 1213
 		return false;
1214
-	    } else {
1214
+		} else {
1215 1215
 		$additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))";
1216 1216
 		$query_values = array(':airport' => $airport);
1217
-	    }
1217
+		}
1218 1218
 	}
1219 1219
 	
1220 1220
 	if ($limit != "")
1221 1221
 	{
1222
-	    $limit_array = explode(",", $limit);
1222
+		$limit_array = explode(",", $limit);
1223 1223
 	    
1224
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1226 1226
 	    
1227
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
-	    {
1227
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
+		{
1229 1229
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1230 1230
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1231
-	    }
1231
+		}
1232 1232
 	}
1233 1233
 	
1234 1234
 	if ($sort != "")
1235 1235
 	{
1236
-	    $search_orderby_array = $Marine->getOrderBy();
1237
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1236
+		$search_orderby_array = $Marine->getOrderBy();
1237
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1238 1238
 	} else {
1239
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1239
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1240 1240
 	}
1241 1241
 
1242 1242
 	$query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1244,6 +1244,6 @@  discard block
 block discarded – undo
1244 1244
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1245 1245
 
1246 1246
 	return $spotter_array;
1247
-    }
1247
+	}
1248 1248
 }
1249 1249
 ?>
1250 1250
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -13,33 +13,33 @@  discard block
 block discarded – undo
13 13
 	* @param Array $filter the filter
14 14
 	* @return Array the SQL part
15 15
 	*/
16
-	public function getFilter($filter = array(),$where = false,$and = false) {
16
+	public function getFilter($filter = array(), $where = false, $and = false) {
17 17
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 		$filters = array();
19 19
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21 21
 				$filters = $globalStatsFilters[$globalFilterName];
22 22
 			} else {
23
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
23
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
24 24
 			}
25 25
 		}
26 26
 		if (isset($filter[0]['source'])) {
27
-			$filters = array_merge($filters,$filter);
27
+			$filters = array_merge($filters, $filter);
28 28
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 		$filter_query_join = '';
31 31
 		$filter_query_where = '';
32
-		foreach($filters as $flt) {
32
+		foreach ($filters as $flt) {
33 33
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
34 34
 				if (isset($flt['source'])) {
35
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
35
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
36 36
 				} else {
37
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
37
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
38 38
 				}
39 39
 			}
40 40
 		}
41 41
 		if (isset($filter['source']) && !empty($filter['source'])) {
42
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
42
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
43 43
 		}
44 44
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
45 45
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -67,43 +67,43 @@  discard block
 block discarded – undo
67 67
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'";
68 68
 				}
69 69
 			}
70
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id";
70
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id";
71 71
 		}
72 72
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
73
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
73
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
74 74
 		}
75 75
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76 76
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
77 77
 		if ($filter_query_where != '') {
78
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
78
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
79 79
 		}
80 80
 		$filter_query = $filter_query_join.$filter_query_where;
81 81
 		return $filter_query;
82 82
 	}
83 83
 
84 84
 	// marine_archive
85
-	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') {
85
+	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
86 86
 		
87 87
 		require_once(dirname(__FILE__).'/class.Marine.php');
88 88
 		if ($over_country == '') {
89 89
 			$Marine = new Marine($this->db);
90
-			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude);
90
+			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude);
91 91
 			if (!empty($data_country)) $country = $data_country['iso2'];
92 92
 			else $country = '';
93 93
 		} else $country = $over_country;
94 94
 		
95 95
 		//$country = $over_country;
96 96
 		// Route is not added in marine_archive
97
-		$query  = 'INSERT INTO marine_archive (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) 
97
+		$query = 'INSERT INTO marine_archive (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) 
98 98
 		    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)';
99 99
 
100
-		$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);
100
+		$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);
101 101
 
102 102
 		try {
103 103
 			$sth = $this->db->prepare($query);
104 104
 			$sth->execute($query_values);
105 105
 			$sth->closeCursor();
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
109 109
 		return "success";
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 
124 124
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
125 125
                 //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
-                $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
126
+                $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
127 127
 
128
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
128
+                $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident));
129 129
 
130 130
                 return $spotter_array;
131 131
         }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
145 145
                 //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146 146
                 //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
-                $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
147
+                $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
148 148
 
149 149
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
150 150
                   /*
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                 }
158 158
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
159 159
                 */
160
-                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
160
+                $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id));
161 161
 
162 162
                 return $spotter_array;
163 163
         }
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 	{
173 173
                 date_default_timezone_set('UTC');
174 174
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
175
-                $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
175
+                $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
176 176
 
177 177
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
178 178
 
179 179
                 try {
180 180
                         $sth = $this->db->prepare($query);
181 181
                         $sth->execute(array(':id' => $id));
182
-                } catch(PDOException $e) {
182
+                } catch (PDOException $e) {
183 183
                         echo $e->getMessage();
184 184
                         die;
185 185
                 }
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
         {
199 199
                 date_default_timezone_set('UTC');
200 200
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
201
-                $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
201
+                $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
202 202
 
203 203
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
204 204
 
205 205
                 try {
206 206
                         $sth = $this->db->prepare($query);
207 207
                         $sth->execute(array(':id' => $id));
208
-                } catch(PDOException $e) {
208
+                } catch (PDOException $e) {
209 209
                         echo $e->getMessage();
210 210
                         die;
211 211
                 }
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
                 date_default_timezone_set('UTC');
228 228
 
229 229
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
230
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
231 231
 
232 232
                 try {
233 233
                         $sth = $this->db->prepare($query);
234 234
                         $sth->execute(array(':ident' => $ident));
235
-                } catch(PDOException $e) {
235
+                } catch (PDOException $e) {
236 236
                         echo $e->getMessage();
237 237
                         die;
238 238
                 }
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
                 date_default_timezone_set('UTC');
254 254
 
255 255
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
256
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
256
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
257 257
 
258 258
                 try {
259 259
                         $sth = $this->db->prepare($query);
260 260
                         $sth->execute(array(':id' => $id));
261
-                } catch(PDOException $e) {
261
+                } catch (PDOException $e) {
262 262
                         echo $e->getMessage();
263 263
                         die;
264 264
                 }
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
                 date_default_timezone_set('UTC');
280 280
 
281 281
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
282
-                $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
282
+                $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
283 283
 
284 284
                 try {
285 285
                         $sth = $this->db->prepare($query);
286 286
                         $sth->execute(array(':id' => $id));
287
-                } catch(PDOException $e) {
287
+                } catch (PDOException $e) {
288 288
                         echo $e->getMessage();
289 289
                         die;
290 290
                 }
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
                 date_default_timezone_set('UTC');
307 307
 
308 308
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
309
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
310 310
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
311 311
 
312 312
                 try {
313 313
                         $sth = $this->db->prepare($query);
314 314
                         $sth->execute(array(':ident' => $ident));
315
-                } catch(PDOException $e) {
315
+                } catch (PDOException $e) {
316 316
                         echo $e->getMessage();
317 317
                         die;
318 318
                 }
@@ -329,13 +329,13 @@  discard block
 block discarded – undo
329 329
         * @return Array the spotter information
330 330
         *
331 331
         */
332
-        public function getMarineArchiveData($ident,$fammarine_id,$date)
332
+        public function getMarineArchiveData($ident, $fammarine_id, $date)
333 333
         {
334 334
     		$Marine = new Marine($this->db);
335 335
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
336
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
336
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
337 337
 
338
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
338
+                $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%'));
339 339
 
340 340
                 return $spotter_array;
341 341
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                 try {
349 349
                         $sth = $this->db->prepare($query);
350 350
                         $sth->execute();
351
-                } catch(PDOException $e) {
351
+                } catch (PDOException $e) {
352 352
                         echo $e->getMessage();
353 353
                         die;
354 354
                 }
@@ -360,24 +360,24 @@  discard block
 block discarded – undo
360 360
         * @return Array the spotter information
361 361
         *
362 362
         */
363
-        public function getMinLiveMarineData($begindate,$enddate,$filter = array())
363
+        public function getMinLiveMarineData($begindate, $enddate, $filter = array())
364 364
         {
365 365
                 global $globalDBdriver, $globalLiveInterval;
366 366
                 date_default_timezone_set('UTC');
367 367
 
368 368
                 $filter_query = '';
369 369
                 if (isset($filter['source']) && !empty($filter['source'])) {
370
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
370
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
371 371
                 }
372 372
                 // Use spotter_output also ?
373 373
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
374
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
375 375
                 }
376 376
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377 377
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
378 378
                 }
379 379
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
380
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
381 381
                 }
382 382
 
383 383
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 						GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id 
397 397
 				    AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
398 398
 */
399
-			$query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
399
+			$query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
400 400
 				    FROM marine_archive 
401 401
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
402 402
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
403 403
                         	    '.$filter_query.' ORDER BY fammarine_id';
404 404
                 } else {
405 405
                         //$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
406
-                        $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
406
+                        $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
407 407
                         	    FROM marine_archive 
408 408
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
409 409
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                 try {
414 414
                         $sth = $this->db->prepare($query);
415 415
                         $sth->execute();
416
-                } catch(PDOException $e) {
416
+                } catch (PDOException $e) {
417 417
                         echo $e->getMessage();
418 418
                         die;
419 419
                 }
@@ -428,24 +428,24 @@  discard block
 block discarded – undo
428 428
         * @return Array the spotter information
429 429
         *
430 430
         */
431
-        public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
431
+        public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array())
432 432
         {
433 433
                 global $globalDBdriver, $globalLiveInterval;
434 434
                 date_default_timezone_set('UTC');
435 435
 
436 436
                 $filter_query = '';
437 437
                 if (isset($filter['source']) && !empty($filter['source'])) {
438
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
438
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
439 439
                 }
440 440
                 // Should use spotter_output also ?
441 441
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
442
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
443 443
                 }
444 444
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445 445
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
446 446
                 }
447 447
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
448
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
449 449
                 }
450 450
 
451 451
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
                     		    FROM marine_archive 
456 456
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
457 457
 			*/
458
-			$query  = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
458
+			$query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
459 459
 				    FROM marine_archive_output 
460 460
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao 
461 461
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
471 471
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
472 472
                         */
473
-                        $query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
473
+                        $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
474 474
                         	    FROM marine_archive_output 
475 475
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
476 476
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
                 try {
483 483
                         $sth = $this->db->prepare($query);
484 484
                         $sth->execute();
485
-                } catch(PDOException $e) {
485
+                } catch (PDOException $e) {
486 486
                         echo $e->getMessage();
487 487
                         die;
488 488
                 }
@@ -497,23 +497,23 @@  discard block
 block discarded – undo
497 497
         * @return Array the spotter information
498 498
         *
499 499
         */
500
-        public function getLiveMarineCount($begindate,$enddate,$filter = array())
500
+        public function getLiveMarineCount($begindate, $enddate, $filter = array())
501 501
         {
502 502
                 global $globalDBdriver, $globalLiveInterval;
503 503
                 date_default_timezone_set('UTC');
504 504
 
505 505
                 $filter_query = '';
506 506
                 if (isset($filter['source']) && !empty($filter['source'])) {
507
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
507
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
508 508
                 }
509 509
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
510
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
511 511
                 }
512 512
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513 513
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
514 514
                 }
515 515
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
516
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
517 517
                 }
518 518
 
519 519
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
                 try {
529 529
                         $sth = $this->db->prepare($query);
530 530
                         $sth->execute();
531
-                } catch(PDOException $e) {
531
+                } catch (PDOException $e) {
532 532
                         echo $e->getMessage();
533 533
                         die;
534 534
                 }
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     * @return Array the spotter information
549 549
     *
550 550
     */
551
-    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
551
+    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
552 552
     {
553 553
 	global $globalTimezone, $globalDBdriver;
554 554
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	        
571 571
 		$q_array = explode(" ", $q);
572 572
 		
573
-		foreach ($q_array as $q_item){
573
+		foreach ($q_array as $q_item) {
574 574
 		    $additional_query .= " AND (";
575 575
 		    $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
576 576
 		    $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	
603 603
 	if ($registration != "")
604 604
 	{
605
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
605
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
606 606
 	    if (!is_string($registration))
607 607
 	    {
608 608
 		return false;
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 	
614 614
 	if ($aircraft_icao != "")
615 615
 	{
616
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
616
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
617 617
 	    if (!is_string($aircraft_icao))
618 618
 	    {
619 619
 		return false;
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 	
625 625
 	if ($aircraft_manufacturer != "")
626 626
 	{
627
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
627
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
628 628
 	    if (!is_string($aircraft_manufacturer))
629 629
 	    {
630 630
 		return false;
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 	
646 646
 	if ($airline_icao != "")
647 647
 	{
648
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
648
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
649 649
 	    if (!is_string($airline_icao))
650 650
 	    {
651 651
 		return false;
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 	
657 657
 	if ($airline_country != "")
658 658
 	{
659
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
659
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
660 660
 	    if (!is_string($airline_country))
661 661
 	    {
662 662
 		return false;
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	
668 668
 	if ($airline_type != "")
669 669
 	{
670
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
670
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
671 671
 	    if (!is_string($airline_type))
672 672
 	    {
673 673
 		return false;
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 	
690 690
 	if ($airport != "")
691 691
 	{
692
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
692
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
693 693
 	    if (!is_string($airport))
694 694
 	    {
695 695
 		return false;
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	
701 701
 	if ($airport_country != "")
702 702
 	{
703
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
703
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
704 704
 	    if (!is_string($airport_country))
705 705
 	    {
706 706
 		return false;
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
     
712 712
 	if ($callsign != "")
713 713
 	{
714
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
714
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
715 715
 	    if (!is_string($callsign))
716 716
 	    {
717 717
 		return false;
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 		$translate = $Translation->ident2icao($callsign);
720 720
 		if ($translate != $callsign) {
721 721
 			$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
722
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
722
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
723 723
 		} else {
724 724
 			$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
725 725
 		}
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 
729 729
 	if ($owner != "")
730 730
 	{
731
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
731
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
732 732
 	    if (!is_string($owner))
733 733
 	    {
734 734
 		return false;
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 
740 740
 	if ($pilot_name != "")
741 741
 	{
742
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
742
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
743 743
 	    if (!is_string($pilot_name))
744 744
 	    {
745 745
 		return false;
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 	
751 751
 	if ($pilot_id != "")
752 752
 	{
753
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
753
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
754 754
 	    if (!is_string($pilot_id))
755 755
 	    {
756 756
 		return false;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	
762 762
 	if ($departure_airport_route != "")
763 763
 	{
764
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
764
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
765 765
 	    if (!is_string($departure_airport_route))
766 766
 	    {
767 767
 		return false;
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 	
773 773
 	if ($arrival_airport_route != "")
774 774
 	{
775
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
775
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
776 776
 	    if (!is_string($arrival_airport_route))
777 777
 	    {
778 778
 		return false;
@@ -785,8 +785,8 @@  discard block
 block discarded – undo
785 785
 	{
786 786
 	    $altitude_array = explode(",", $altitude);
787 787
 	    
788
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
789
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
790 790
 	    
791 791
 
792 792
 	    if ($altitude_array[1] != "")
@@ -804,8 +804,8 @@  discard block
 block discarded – undo
804 804
 	{
805 805
 	    $date_array = explode(",", $date_posted);
806 806
 	    
807
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
808
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
809 809
 	    
810 810
 	    if ($globalTimezone != '') {
811 811
 		date_default_timezone_set($globalTimezone);
@@ -837,8 +837,8 @@  discard block
 block discarded – undo
837 837
 	{
838 838
 	    $limit_array = explode(",", $limit);
839 839
 	    
840
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
841
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
842 842
 	    
843 843
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844 844
 	    {
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	
850 850
 
851 851
 	if ($origLat != "" && $origLon != "" && $dist != "") {
852
-		$dist = number_format($dist*0.621371,2,'.','');
853
-		$query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
852
+		$dist = number_format($dist*0.621371, 2, '.', '');
853
+		$query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
854 854
                           FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
855 855
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
856 856
 	} else {
@@ -867,12 +867,12 @@  discard block
 block discarded – undo
867 867
 			$additional_query .= " AND (marine_archive_output.waypoints <> '')";
868 868
 		}
869 869
 
870
-		$query  = "SELECT marine_archive_output.* FROM marine_archive_output 
870
+		$query = "SELECT marine_archive_output.* FROM marine_archive_output 
871 871
 		    WHERE marine_archive_output.ident <> '' 
872 872
 		    ".$additional_query."
873 873
 		    ".$filter_query.$orderby_query;
874 874
 	}
875
-	$spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
875
+	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
876 876
 
877 877
 	return $spotter_array;
878 878
     }
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
                 try {
890 890
                         $sth = $this->db->prepare($query);
891 891
                         $sth->execute();
892
-                } catch(PDOException $e) {
892
+                } catch (PDOException $e) {
893 893
                         return "error";
894 894
                 }
895 895
 	}
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 	{
927 927
 	    $limit_array = explode(",", $limit);
928 928
 	    
929
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
930
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
931 931
 	    
932 932
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933 933
 	    {
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 	$query_values = array();
969 969
 	$limit_query = '';
970 970
 	$additional_query = '';
971
-	$filter_query = $this->getFilter($filter,true,true);
971
+	$filter_query = $this->getFilter($filter, true, true);
972 972
 	
973 973
 	if ($owner != "")
974 974
 	{
@@ -985,8 +985,8 @@  discard block
 block discarded – undo
985 985
 	{
986 986
 	    $limit_array = explode(",", $limit);
987 987
 	    
988
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
989
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991 991
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992 992
 	    {
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 	$query_values = array();
1027 1027
 	$limit_query = '';
1028 1028
 	$additional_query = '';
1029
-	$filter_query = $this->getFilter($filter,true,true);
1029
+	$filter_query = $this->getFilter($filter, true, true);
1030 1030
 	
1031 1031
 	if ($pilot != "")
1032 1032
 	{
@@ -1038,8 +1038,8 @@  discard block
 block discarded – undo
1038 1038
 	{
1039 1039
 	    $limit_array = explode(",", $limit);
1040 1040
 	    
1041
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1042
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1043 1043
 	    
1044 1044
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045 1045
 	    {
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
     * @return Array the airline country list
1070 1070
     *
1071 1071
     */
1072
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1072
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1073 1073
     {
1074 1074
 	global $globalDBdriver;
1075 1075
 	/*
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 	$flight_array = array();
1099 1099
 	$temp_array = array();
1100 1100
         
1101
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1101
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1102 1102
 	{
1103 1103
 	    $temp_array['flight_count'] = $row['nb'];
1104 1104
 	    $temp_array['flight_country'] = $row['name'];
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
     * @return Array the airline country list
1116 1116
     *
1117 1117
     */
1118
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1118
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1119 1119
     {
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 	$flight_array = array();
1145 1145
 	$temp_array = array();
1146 1146
         
1147
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1147
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149 1149
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1150 1150
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1162,14 +1162,14 @@  discard block
 block discarded – undo
1162 1162
     * @return Array the spotter information
1163 1163
     *
1164 1164
     */
1165
-    public function getDateArchiveMarineDataById($id,$date)
1165
+    public function getDateArchiveMarineDataById($id, $date)
1166 1166
     {
1167 1167
 	$Marine = new Marine($this->db);
1168 1168
 	date_default_timezone_set('UTC');
1169 1169
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1170 1170
 	$query  = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';
1171
-	$date = date('c',$date);
1172
-	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1171
+	$date = date('c', $date);
1172
+	$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1173 1173
 	return $spotter_array;
1174 1174
     }
1175 1175
 
@@ -1179,14 +1179,14 @@  discard block
 block discarded – undo
1179 1179
     * @return Array the spotter information
1180 1180
     *
1181 1181
     */
1182
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1182
+    public function getDateArchiveMarineDataByIdent($ident, $date)
1183 1183
     {
1184 1184
 	$Marine = new Marine($this->db);
1185 1185
 	date_default_timezone_set('UTC');
1186 1186
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1187 1187
 	$query  = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';
1188
-	$date = date('c',$date);
1189
-	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1188
+	$date = date('c', $date);
1189
+	$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1190 1190
 	return $spotter_array;
1191 1191
     }
1192 1192
 
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
     * @return Array the spotter information
1197 1197
     *
1198 1198
     */
1199
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1199
+    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1200 1200
     {
1201 1201
 	global $global_query;
1202 1202
 	$Marine = new Marine();
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 	$query_values = array();
1205 1205
 	$limit_query = '';
1206 1206
 	$additional_query = '';
1207
-	$filter_query = $this->getFilter($filters,true,true);
1207
+	$filter_query = $this->getFilter($filters, true, true);
1208 1208
 	
1209 1209
 	if ($airport != "")
1210 1210
 	{
@@ -1221,8 +1221,8 @@  discard block
 block discarded – undo
1221 1221
 	{
1222 1222
 	    $limit_array = explode(",", $limit);
1223 1223
 	    
1224
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1225
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1226 1226
 	    
1227 1227
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228 1228
 	    {
Please login to merge, or discard this patch.
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		if (isset($filter[0]['source'])) {
27 27
 			$filters = array_merge($filters,$filter);
28 28
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) {
30
+			$filter = array_merge($filter,$globalFilter);
31
+		}
30 32
 		$filter_query_join = '';
31 33
 		$filter_query_where = '';
32 34
 		foreach($filters as $flt) {
@@ -72,8 +74,11 @@  discard block
 block discarded – undo
72 74
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
73 75
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74 76
 		}
75
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
77
+		if ($filter_query_where == '' && $where) {
78
+			$filter_query_where = ' WHERE';
79
+		} elseif ($filter_query_where != '' && $and) {
80
+			$filter_query_where .= ' AND';
81
+		}
77 82
 		if ($filter_query_where != '') {
78 83
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
79 84
 		}
@@ -88,9 +93,14 @@  discard block
 block discarded – undo
88 93
 		if ($over_country == '') {
89 94
 			$Marine = new Marine($this->db);
90 95
 			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude);
91
-			if (!empty($data_country)) $country = $data_country['iso2'];
92
-			else $country = '';
93
-		} else $country = $over_country;
96
+			if (!empty($data_country)) {
97
+				$country = $data_country['iso2'];
98
+			} else {
99
+				$country = '';
100
+			}
101
+		} else {
102
+			$country = $over_country;
103
+		}
94 104
 		
95 105
 		//$country = $over_country;
96 106
 		// Route is not added in marine_archive
@@ -593,7 +603,9 @@  discard block
 block discarded – undo
593 603
 		    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
594 604
 		    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
595 605
 		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
606
+		    if ($translate != $q_item) {
607
+		    	$additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
608
+		    }
597 609
 		    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
598 610
 		    $additional_query .= ")";
599 611
 		}
@@ -811,7 +823,9 @@  discard block
 block discarded – undo
811 823
 		date_default_timezone_set($globalTimezone);
812 824
 		$datetime = new DateTime();
813 825
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
826
+	    } else {
827
+	    	$offset = '+00:00';
828
+	    }
815 829
 
816 830
 
817 831
 	    if ($date_array[1] != "")
@@ -1087,9 +1101,13 @@  discard block
 block discarded – undo
1087 1101
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1102
 			}
1089 1103
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1104
+                if ($sincedate != '') {
1105
+                	$query .= "AND date > '".$sincedate."' ";
1106
+                }
1091 1107
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092
-	if ($limit) $query .= " LIMIT 0,10";
1108
+	if ($limit) {
1109
+		$query .= " LIMIT 0,10";
1110
+	}
1093 1111
       
1094 1112
 	
1095 1113
 	$sth = $this->db->prepare($query);
@@ -1133,9 +1151,13 @@  discard block
 block discarded – undo
1133 1151
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1152
 			}
1135 1153
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1154
+                if ($sincedate != '') {
1155
+                	$query .= "AND s.date > '".$sincedate."' ";
1156
+                }
1137 1157
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138
-	if ($limit) $query .= " LIMIT 0,10";
1158
+	if ($limit) {
1159
+		$query .= " LIMIT 0,10";
1160
+	}
1139 1161
       
1140 1162
 	
1141 1163
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
install/class.update_db.php 4 patches
Doc Comments   +42 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@  discard block
 block discarded – undo
10 10
 class update_db {
11 11
 	public static $db_sqlite;
12 12
 
13
+	/**
14
+	 * @param string $file
15
+	 */
13 16
 	public static function download($url, $file, $referer = '') {
14 17
 		//$file = str_replace('/',DIRECTORY_SEPARATOR,$file);
15 18
 		$fp = fopen($file, 'w+');
@@ -25,6 +28,9 @@  discard block
 block discarded – undo
25 28
 		fclose($fp);
26 29
 	}
27 30
 
31
+	/**
32
+	 * @param string $in_file
33
+	 */
28 34
 	public static function gunzip($in_file,$out_file_name = '') {
29 35
 		//echo $in_file.' -> '.$out_file_name."\n";
30 36
 		$buffer_size = 4096; // read 4kb at a time
@@ -46,6 +52,9 @@  discard block
 block discarded – undo
46 52
 		}
47 53
 	}
48 54
 
55
+	/**
56
+	 * @param string $in_file
57
+	 */
49 58
 	public static function unzip($in_file) {
50 59
 		if ($in_file != '' && file_exists($in_file)) {
51 60
 			$path = pathinfo(realpath($in_file), PATHINFO_DIRNAME);
@@ -67,6 +76,9 @@  discard block
 block discarded – undo
67 76
 		}
68 77
 	}
69 78
 	
79
+	/**
80
+	 * @param string $database_file
81
+	 */
70 82
 	public static function retrieve_route_sqlite_to_dest($database_file) {
71 83
 		global $globalDebug, $globalTransaction;
72 84
 		//$query = 'TRUNCATE TABLE routes';
@@ -109,6 +121,10 @@  discard block
 block discarded – undo
109 121
 		}
110 122
                 return '';
111 123
 	}
124
+
125
+	/**
126
+	 * @param string $database_file
127
+	 */
112 128
 	public static function retrieve_route_oneworld($database_file) {
113 129
 		global $globalDebug, $globalTransaction;
114 130
 		//$query = 'TRUNCATE TABLE routes';
@@ -150,6 +166,9 @@  discard block
 block discarded – undo
150 166
                 return '';
151 167
 	}
152 168
 	
169
+	/**
170
+	 * @param string $database_file
171
+	 */
153 172
 	public static function retrieve_route_skyteam($database_file) {
154 173
 		global $globalDebug, $globalTransaction;
155 174
 		//$query = 'TRUNCATE TABLE routes';
@@ -192,6 +211,10 @@  discard block
 block discarded – undo
192 211
 		}
193 212
                 return '';
194 213
 	}
214
+
215
+	/**
216
+	 * @param string $database_file
217
+	 */
195 218
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
196 219
 		global $globalTransaction;
197 220
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -258,6 +281,9 @@  discard block
 block discarded – undo
258 281
 		return '';
259 282
 	}
260 283
 
284
+	/**
285
+	 * @param string $database_file
286
+	 */
261 287
 	public static function retrieve_modes_flarmnet($database_file) {
262 288
 		global $globalTransaction;
263 289
 		$Common = new Common();
@@ -328,6 +354,9 @@  discard block
 block discarded – undo
328 354
 		return '';
329 355
 	}
330 356
 
357
+	/**
358
+	 * @param string $database_file
359
+	 */
331 360
 	public static function retrieve_modes_ogn($database_file) {
332 361
 		global $globalTransaction;
333 362
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -396,6 +425,9 @@  discard block
 block discarded – undo
396 425
 		return '';
397 426
 	}
398 427
 
428
+	/**
429
+	 * @param string $database_file
430
+	 */
399 431
 	public static function retrieve_owner($database_file,$country = 'F') {
400 432
 		global $globalTransaction, $globalMasterSource;
401 433
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -1276,6 +1308,10 @@  discard block
 block discarded – undo
1276 1308
 		return '';
1277 1309
         }
1278 1310
 
1311
+	/**
1312
+	 * @param string $filename
1313
+	 * @param string $tletype
1314
+	 */
1279 1315
 	public static function tle($filename,$tletype) {
1280 1316
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1281 1317
 		global $tmp_dir, $globalTransaction;
@@ -1408,6 +1444,9 @@  discard block
 block discarded – undo
1408 1444
 
1409 1445
 	}
1410 1446
 */
1447
+	/**
1448
+	 * @param string $filename
1449
+	 */
1411 1450
 	public static function waypoints($filename) {
1412 1451
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1413 1452
 		global $tmp_dir, $globalTransaction;
@@ -1455,6 +1494,9 @@  discard block
 block discarded – undo
1455 1494
 		return '';
1456 1495
         }
1457 1496
 
1497
+	/**
1498
+	 * @param string $filename
1499
+	 */
1458 1500
 	public static function ivao_airlines($filename) {
1459 1501
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1460 1502
 		global $tmp_dir, $globalTransaction;
Please login to merge, or discard this patch.
Indentation   +462 added lines, -462 removed lines patch added patch discarded remove patch
@@ -76,38 +76,38 @@  discard block
 block discarded – undo
76 76
 		try {
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79
-                        $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
81
-                        return "error : ".$e->getMessage();
82
-                }
79
+						$sth->execute(array(':source' => $database_file));
80
+				} catch(PDOException $e) {
81
+						return "error : ".$e->getMessage();
82
+				}
83 83
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
85
-    		update_db::connect_sqlite($database_file);
84
+			if ($globalDebug) echo " - Add routes to DB -";
85
+			update_db::connect_sqlite($database_file);
86 86
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
87 87
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
88 88
 		try {
89
-                        $sth = update_db::$db_sqlite->prepare($query);
90
-                        $sth->execute();
91
-                } catch(PDOException $e) {
92
-                        return "error : ".$e->getMessage();
93
-                }
89
+						$sth = update_db::$db_sqlite->prepare($query);
90
+						$sth->execute();
91
+				} catch(PDOException $e) {
92
+						return "error : ".$e->getMessage();
93
+				}
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
96 96
 		$Connection = new Connection();
97 97
 		$sth_dest = $Connection->db->prepare($query_dest);
98 98
 		try {
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 102
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104
-            		}
104
+					}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106 106
 		} catch(PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
110
-                return '';
110
+				return '';
111 111
 	}
112 112
 	public static function retrieve_route_oneworld($database_file) {
113 113
 		global $globalDebug, $globalTransaction;
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 		try {
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121
-                        $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
123
-                        return "error : ".$e->getMessage();
124
-                }
121
+						$sth->execute(array(':source' => 'oneworld'));
122
+				} catch(PDOException $e) {
123
+						return "error : ".$e->getMessage();
124
+				}
125 125
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
126
+			if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129 129
 		if ($fh = fopen($database_file,"r")) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			}
148 148
 			if ($globalTransaction) $Connection->db->commit();
149 149
 		}
150
-                return '';
150
+				return '';
151 151
 	}
152 152
 	
153 153
 	public static function retrieve_route_skyteam($database_file) {
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 		try {
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162
-                        $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
164
-                        return "error : ".$e->getMessage();
165
-                }
162
+						$sth->execute(array(':source' => 'skyteam'));
163
+				} catch(PDOException $e) {
164
+						return "error : ".$e->getMessage();
165
+				}
166 166
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
167
+			if ($globalDebug) echo " - Add routes to DB -";
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
192 192
 		}
193
-                return '';
193
+				return '';
194 194
 	}
195 195
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
196 196
 		global $globalTransaction;
@@ -199,27 +199,27 @@  discard block
 block discarded – undo
199 199
 		try {
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202
-                        $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
204
-                        return "error : ".$e->getMessage();
205
-                }
202
+						$sth->execute(array(':source' => $database_file));
203
+				} catch(PDOException $e) {
204
+						return "error : ".$e->getMessage();
205
+				}
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
207 207
 		try {
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210
-                        $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
212
-                        return "error : ".$e->getMessage();
213
-                }
210
+						$sth->execute(array(':source' => $database_file));
211
+				} catch(PDOException $e) {
212
+						return "error : ".$e->getMessage();
213
+				}
214 214
 
215
-    		update_db::connect_sqlite($database_file);
215
+			update_db::connect_sqlite($database_file);
216 216
 		$query = 'select * from Aircraft';
217 217
 		try {
218
-                        $sth = update_db::$db_sqlite->prepare($query);
219
-                        $sth->execute();
220
-                } catch(PDOException $e) {
221
-                        return "error : ".$e->getMessage();
222
-                }
218
+						$sth = update_db::$db_sqlite->prepare($query);
219
+						$sth->execute();
220
+				} catch(PDOException $e) {
221
+						return "error : ".$e->getMessage();
222
+				}
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
224 224
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
225 225
 		
@@ -230,17 +230,17 @@  discard block
 block discarded – undo
230 230
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 231
 		try {
232 232
 			if ($globalTransaction) $Connection->db->beginTransaction();
233
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237 237
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
-				    $sth_dest_owner->execute($query_dest_owner_values);
240
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
+					$sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243
-            		}
243
+					}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245 245
 		} catch(PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 		try {
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254
-                        $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
256
-                        return "error : ".$e->getMessage();
257
-                }
254
+						$sth->execute(array(':source' => $database_file));
255
+				} catch(PDOException $e) {
256
+						return "error : ".$e->getMessage();
257
+				}
258 258
 		return '';
259 259
 	}
260 260
 
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 		try {
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269
-                        $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
271
-                        return "error : ".$e->getMessage();
272
-                }
269
+						$sth->execute(array(':source' => $database_file));
270
+				} catch(PDOException $e) {
271
+						return "error : ".$e->getMessage();
272
+				}
273 273
 		
274 274
 		if ($fh = fopen($database_file,"r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -279,26 +279,26 @@  discard block
 block discarded – undo
279 279
 			$sth_dest = $Connection->db->prepare($query_dest);
280 280
 			try {
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282
-            			while (!feof($fh)) {
283
-            				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
282
+						while (!feof($fh)) {
283
+							$values = array();
284
+							$line = $Common->hex2str(fgets($fh,9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
289
-            				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
291
-            				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
-            				$sth_search = $Connection->db->prepare($query_search);
286
+							$values['ModeS'] = substr($line,0,6);
287
+							$values['Registration'] = trim(substr($line,69,6));
288
+							$aircraft_name = trim(substr($line,48,6));
289
+							// Check if we can find ICAO, else set it to GLID
290
+							$aircraft_name_split = explode(' ',$aircraft_name);
291
+							$search_more = '';
292
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
+							$sth_search = $Connection->db->prepare($query_search);
295 295
 					try {
296
-                                    		$sth_search->execute();
297
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
-	            				//if (count($result) > 0) {
299
-	            				if (isset($result['icao']) && $result['icao'] != '') {
300
-	            				    $values['ICAOTypeCode'] = $result['icao'];
301
-	            				} 
296
+											$sth_search->execute();
297
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
+								//if (count($result) > 0) {
299
+								if (isset($result['icao']) && $result['icao'] != '') {
300
+									$values['ICAOTypeCode'] = $result['icao'];
301
+								} 
302 302
 					} catch(PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 		try {
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324
-                        $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
326
-                        return "error : ".$e->getMessage();
327
-                }
324
+						$sth->execute(array(':source' => $database_file));
325
+				} catch(PDOException $e) {
326
+						return "error : ".$e->getMessage();
327
+				}
328 328
 		return '';
329 329
 	}
330 330
 
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 		try {
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338
-                        $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
340
-                        return "error : ".$e->getMessage();
341
-                }
338
+						$sth->execute(array(':source' => $database_file));
339
+				} catch(PDOException $e) {
340
+						return "error : ".$e->getMessage();
341
+				}
342 342
 		
343 343
 		if ($fh = fopen($database_file,"r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -349,25 +349,25 @@  discard block
 block discarded – undo
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351 351
 				$tmp = fgetcsv($fh,9999,',',"'");
352
-            			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
352
+						while (!feof($fh)) {
353
+							$line = fgetcsv($fh,9999,',',"'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
357
-            				$values['ModeS'] = $line[1];
358
-            				$values['Registration'] = $line[3];
359
-            				$values['ICAOTypeCode'] = '';
360
-            				$aircraft_name = $line[2];
361
-            				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
363
-            				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
-            				$sth_search = $Connection->db->prepare($query_search);
357
+							$values['ModeS'] = $line[1];
358
+							$values['Registration'] = $line[3];
359
+							$values['ICAOTypeCode'] = '';
360
+							$aircraft_name = $line[2];
361
+							// Check if we can find ICAO, else set it to GLID
362
+							$aircraft_name_split = explode(' ',$aircraft_name);
363
+							$search_more = '';
364
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
+							$sth_search = $Connection->db->prepare($query_search);
367 367
 					try {
368
-                                    		$sth_search->execute();
369
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
368
+											$sth_search->execute();
369
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371 371
 					} catch(PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
 		try {
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393
-                        $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
395
-                        return "error : ".$e->getMessage();
396
-                }
393
+						$sth->execute(array(':source' => $database_file));
394
+				} catch(PDOException $e) {
395
+						return "error : ".$e->getMessage();
396
+				}
397 397
 		return '';
398 398
 	}
399 399
 
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
 		try {
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407
-                        $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
409
-                        return "error : ".$e->getMessage();
410
-                }
407
+						$sth->execute(array(':source' => $database_file));
408
+				} catch(PDOException $e) {
409
+						return "error : ".$e->getMessage();
410
+				}
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413 413
 		if ($fh = fopen($database_file,"r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
416
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
417 417
 		        
418 418
 			$Connection = new Connection();
419 419
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -421,126 +421,126 @@  discard block
 block discarded – undo
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423 423
 				$tmp = fgetcsv($fh,9999,',','"');
424
-            			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
426
-            				$values = array();
427
-            				//print_r($line);
428
-            				if ($country == 'F') {
429
-            				    $values['registration'] = $line[0];
430
-            				    $values['base'] = $line[4];
431
-            				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
-					    $values['cancel'] = $line[7];
424
+						while (!feof($fh)) {
425
+							$line = fgetcsv($fh,9999,',','"');
426
+							$values = array();
427
+							//print_r($line);
428
+							if ($country == 'F') {
429
+								$values['registration'] = $line[0];
430
+								$values['base'] = $line[4];
431
+								$values['owner'] = $line[5];
432
+								if ($line[6] == '') $values['date_first_reg'] = null;
433
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
+						$values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436
-					    // TODO : add modeS & reg to aircraft_modes
437
-            				    $values['registration'] = $line[0];
438
-            				    $values['base'] = $line[3];
439
-            				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
-					    $values['cancel'] = '';
443
-					    $values['modes'] = $line[7];
444
-					    $values['icao'] = $line[8];
436
+						// TODO : add modeS & reg to aircraft_modes
437
+								$values['registration'] = $line[0];
438
+								$values['base'] = $line[3];
439
+								$values['owner'] = $line[2];
440
+								if ($line[1] == '') $values['date_first_reg'] = null;
441
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
+						$values['cancel'] = '';
443
+						$values['modes'] = $line[7];
444
+						$values['icao'] = $line[8];
445 445
 					    
446 446
 					} elseif ($country == 'HB') {
447
-					    // TODO : add modeS & reg to aircraft_modes
448
-            				    $values['registration'] = $line[0];
449
-            				    $values['base'] = null;
450
-            				    $values['owner'] = $line[5];
451
-            				    $values['date_first_reg'] = null;
452
-					    $values['cancel'] = '';
453
-					    $values['modes'] = $line[4];
454
-					    $values['icao'] = $line[7];
447
+						// TODO : add modeS & reg to aircraft_modes
448
+								$values['registration'] = $line[0];
449
+								$values['base'] = null;
450
+								$values['owner'] = $line[5];
451
+								$values['date_first_reg'] = null;
452
+						$values['cancel'] = '';
453
+						$values['modes'] = $line[4];
454
+						$values['icao'] = $line[7];
455 455
 					} elseif ($country == 'OK') {
456
-					    // TODO : add modeS & reg to aircraft_modes
457
-            				    $values['registration'] = $line[3];
458
-            				    $values['base'] = null;
459
-            				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
-					    $values['cancel'] = '';
456
+						// TODO : add modeS & reg to aircraft_modes
457
+								$values['registration'] = $line[3];
458
+								$values['base'] = null;
459
+								$values['owner'] = $line[5];
460
+								if ($line[18] == '') $values['date_first_reg'] = null;
461
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
+						$values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464
-					    // TODO : add modeS & reg to aircraft_modes
465
-            				    $values['registration'] = $line[0];
466
-            				    $values['base'] = null;
467
-            				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
-
471
-					    $values['cancel'] = $line[39];
464
+						// TODO : add modeS & reg to aircraft_modes
465
+								$values['registration'] = $line[0];
466
+								$values['base'] = null;
467
+								$values['owner'] = $line[12];
468
+								if ($line[28] == '') $values['date_first_reg'] = null;
469
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
+
471
+						$values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
473
-            				    $values['registration'] = $line[0];
474
-            				    $values['base'] = null;
475
-            				    $values['owner'] = $line[4];
476
-            				    $values['date_first_reg'] = null;
477
-					    $values['cancel'] = '';
473
+								$values['registration'] = $line[0];
474
+								$values['base'] = null;
475
+								$values['owner'] = $line[4];
476
+								$values['date_first_reg'] = null;
477
+						$values['cancel'] = '';
478 478
 					} elseif ($country == 'CC') {
479
-            				    $values['registration'] = $line[0];
480
-            				    $values['base'] = null;
481
-            				    $values['owner'] = $line[6];
482
-            				    $values['date_first_reg'] = null;
483
-					    $values['cancel'] = '';
479
+								$values['registration'] = $line[0];
480
+								$values['base'] = null;
481
+								$values['owner'] = $line[6];
482
+								$values['date_first_reg'] = null;
483
+						$values['cancel'] = '';
484 484
 					} elseif ($country == 'HJ') {
485
-            				    $values['registration'] = $line[0];
486
-            				    $values['base'] = null;
487
-            				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
-					    $values['cancel'] = '';
485
+								$values['registration'] = $line[0];
486
+								$values['base'] = null;
487
+								$values['owner'] = $line[8];
488
+								if ($line[7] == '') $values['date_first_reg'] = null;
489
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
+						$values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492
-            				    $values['registration'] = $line[0];
493
-            				    $values['base'] = null;
494
-            				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
-					    $values['cancel'] = $line[7];
492
+								$values['registration'] = $line[0];
493
+								$values['base'] = null;
494
+								$values['owner'] = $line[4];
495
+								if ($line[6] == '') $values['date_first_reg'] = null;
496
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+						$values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499
-            				    $values['registration'] = $line[0];
500
-            				    $values['base'] = null;
501
-            				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
-					    $values['cancel'] = '';
499
+								$values['registration'] = $line[0];
500
+								$values['base'] = null;
501
+								$values['owner'] = $line[4];
502
+								if ($line[5] == '') $values['date_first_reg'] = null;
503
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
+						$values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506
-            				    $values['registration'] = $line[0];
507
-            				    $values['base'] = null;
508
-            				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
-					    $values['cancel'] = '';
506
+								$values['registration'] = $line[0];
507
+								$values['base'] = null;
508
+								$values['owner'] = $line[3];
509
+								if ($line[7] == '') $values['date_first_reg'] = null;
510
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
+						$values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513
-            				    $values['registration'] = $line[0];
514
-            				    $values['base'] = null;
515
-            				    $values['owner'] = $line[3];
516
-            				    $values['date_first_reg'] = null;
517
-					    $values['cancel'] = '';
518
-					    $values['modes'] = $line[5];
519
-					    $values['icao'] = $line[9];
513
+								$values['registration'] = $line[0];
514
+								$values['base'] = null;
515
+								$values['owner'] = $line[3];
516
+								$values['date_first_reg'] = null;
517
+						$values['cancel'] = '';
518
+						$values['modes'] = $line[5];
519
+						$values['icao'] = $line[9];
520 520
 					} elseif ($country == 'M') {
521
-            				    $values['registration'] = $line[0];
522
-            				    $values['base'] = null;
523
-            				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
-					    $values['modes'] = $line[4];
527
-					    $values['icao'] = $line[10];
521
+								$values['registration'] = $line[0];
522
+								$values['base'] = null;
523
+								$values['owner'] = $line[6];
524
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
+						$values['modes'] = $line[4];
527
+						$values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529
-            				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
-					    $values['modes'] = $line[5];
532
-					    $values['icao'] = $line[6];
529
+								$values['registration'] = $line[0];
530
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
+						$values['modes'] = $line[5];
532
+						$values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534
-            				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
-					    $values['modes'] = $line[4];
537
-					    $values['icao'] = $line[5];
534
+								$values['registration'] = $line[0];
535
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
+						$values['modes'] = $line[4];
537
+						$values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
539
-            				    $values['registration'] = $line[0];
540
-            				    $values['base'] = null;
541
-            				    $values['owner'] = $line[3];
542
-            				    $values['date_first_reg'] = null;
543
-					    $values['cancel'] = '';
539
+								$values['registration'] = $line[0];
540
+								$values['base'] = null;
541
+								$values['owner'] = $line[3];
542
+								$values['date_first_reg'] = null;
543
+						$values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546 546
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
                         return "error : ".$e->getMessage();
674 674
                 }
675 675
                 */
676
-                /*
676
+				/*
677 677
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
678 678
 		try {
679 679
 			$Connection = new Connection();
@@ -918,10 +918,10 @@  discard block
 block discarded – undo
918 918
 		try {
919 919
 			$Connection = new Connection();
920 920
 			$sth = $Connection->db->prepare($query);
921
-                        $sth->execute(array(':source' => 'translation.csv'));
922
-                } catch(PDOException $e) {
923
-                        return "error : ".$e->getMessage();
924
-                }
921
+						$sth->execute(array(':source' => 'translation.csv'));
922
+				} catch(PDOException $e) {
923
+						return "error : ".$e->getMessage();
924
+				}
925 925
 
926 926
 		
927 927
 		//update_db::unzip($out_file);
@@ -940,21 +940,21 @@  discard block
 block discarded – undo
940 940
 					$data = $row;
941 941
 					$operator = $data[2];
942 942
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
943
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
944
-                                                //echo substr($operator, 0, 2)."\n";;
945
-                                                if (count($airline_array) > 0) {
943
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
944
+												//echo substr($operator, 0, 2)."\n";;
945
+												if (count($airline_array) > 0) {
946 946
 							//print_r($airline_array);
947 947
 							$operator = $airline_array[0]['icao'].substr($operator,2);
948
-                                                }
949
-                                        }
948
+												}
949
+										}
950 950
 					
951 951
 					$operator_correct = $data[3];
952 952
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
953
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954
-                                                if (count($airline_array) > 0) {
955
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
956
-                                            	}
957
-                                        }
953
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954
+												if (count($airline_array) > 0) {
955
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
956
+												}
957
+										}
958 958
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
959 959
 					try {
960 960
 						$sth = $Connection->db->prepare($query);
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 			//$Connection->db->commit();
969 969
 		}
970 970
 		return '';
971
-        }
971
+		}
972 972
 	
973 973
 	public static function translation_fam() {
974 974
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -978,10 +978,10 @@  discard block
 block discarded – undo
978 978
 		try {
979 979
 			$Connection = new Connection();
980 980
 			$sth = $Connection->db->prepare($query);
981
-                        $sth->execute(array(':source' => 'website_fam'));
982
-                } catch(PDOException $e) {
983
-                        return "error : ".$e->getMessage();
984
-                }
981
+						$sth->execute(array(':source' => 'website_fam'));
982
+				} catch(PDOException $e) {
983
+						return "error : ".$e->getMessage();
984
+				}
985 985
 
986 986
 		
987 987
 		//update_db::unzip($out_file);
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 			//$Connection->db->commit();
1011 1011
 		}
1012 1012
 		return '';
1013
-        }
1013
+		}
1014 1014
 
1015 1015
 	/*
1016 1016
 	* This function use FAA public data.
@@ -1022,19 +1022,19 @@  discard block
 block discarded – undo
1022 1022
 		try {
1023 1023
 			$Connection = new Connection();
1024 1024
 			$sth = $Connection->db->prepare($query);
1025
-                        $sth->execute(array(':source' => 'website_faa'));
1026
-                } catch(PDOException $e) {
1027
-                        return "error : ".$e->getMessage();
1028
-                }
1025
+						$sth->execute(array(':source' => 'website_faa'));
1026
+				} catch(PDOException $e) {
1027
+						return "error : ".$e->getMessage();
1028
+				}
1029 1029
 
1030 1030
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1031 1031
 		try {
1032 1032
 			$Connection = new Connection();
1033 1033
 			$sth = $Connection->db->prepare($query);
1034
-                        $sth->execute(array(':source' => 'website_faa'));
1035
-                } catch(PDOException $e) {
1036
-                        return "error : ".$e->getMessage();
1037
-                }
1034
+						$sth->execute(array(':source' => 'website_faa'));
1035
+				} catch(PDOException $e) {
1036
+						return "error : ".$e->getMessage();
1037
+				}
1038 1038
 
1039 1039
 		$delimiter = ",";
1040 1040
 		$mfr = array();
@@ -1110,17 +1110,17 @@  discard block
 block discarded – undo
1110 1110
 		}
1111 1111
 		print_r($mfr);
1112 1112
 		return '';
1113
-        }
1113
+		}
1114 1114
 	public static function modes_fam() {
1115 1115
 		global $tmp_dir, $globalTransaction;
1116 1116
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1117 1117
 		try {
1118 1118
 			$Connection = new Connection();
1119 1119
 			$sth = $Connection->db->prepare($query);
1120
-                        $sth->execute(array(':source' => 'website_fam'));
1121
-                } catch(PDOException $e) {
1122
-                        return "error : ".$e->getMessage();
1123
-                }
1120
+						$sth->execute(array(':source' => 'website_fam'));
1121
+				} catch(PDOException $e) {
1122
+						return "error : ".$e->getMessage();
1123
+				}
1124 1124
 
1125 1125
 		
1126 1126
 		//update_db::unzip($out_file);
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 			if ($globalTransaction) $Connection->db->commit();
1151 1151
 		}
1152 1152
 		return '';
1153
-        }
1153
+		}
1154 1154
         
1155 1155
 	public static function owner_fam() {
1156 1156
 		global $tmp_dir, $globalTransaction;
@@ -1158,10 +1158,10 @@  discard block
 block discarded – undo
1158 1158
 		try {
1159 1159
 			$Connection = new Connection();
1160 1160
 			$sth = $Connection->db->prepare($query);
1161
-                        $sth->execute(array(':source' => 'website_fam'));
1162
-                } catch(PDOException $e) {
1163
-                        return "error : ".$e->getMessage();
1164
-                }
1161
+						$sth->execute(array(':source' => 'website_fam'));
1162
+				} catch(PDOException $e) {
1163
+						return "error : ".$e->getMessage();
1164
+				}
1165 1165
 
1166 1166
 		$delimiter = "\t";
1167 1167
 		$Connection = new Connection();
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 			if ($globalTransaction) $Connection->db->commit();
1188 1188
 		}
1189 1189
 		return '';
1190
-        }
1190
+		}
1191 1191
 
1192 1192
 	public static function routes_fam() {
1193 1193
 		global $tmp_dir, $globalTransaction;
@@ -1195,10 +1195,10 @@  discard block
 block discarded – undo
1195 1195
 		try {
1196 1196
 			$Connection = new Connection();
1197 1197
 			$sth = $Connection->db->prepare($query);
1198
-                        $sth->execute(array(':source' => 'website_fam'));
1199
-                } catch(PDOException $e) {
1200
-                        return "error : ".$e->getMessage();
1201
-                }
1198
+						$sth->execute(array(':source' => 'website_fam'));
1199
+				} catch(PDOException $e) {
1200
+						return "error : ".$e->getMessage();
1201
+				}
1202 1202
 
1203 1203
 		
1204 1204
 		//update_db::unzip($out_file);
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 			if ($globalTransaction) $Connection->db->commit();
1228 1228
 		}
1229 1229
 		return '';
1230
-        }
1230
+		}
1231 1231
 
1232 1232
 	public static function marine_identity_fam() {
1233 1233
 		global $tmp_dir, $globalTransaction;
@@ -1235,10 +1235,10 @@  discard block
 block discarded – undo
1235 1235
 		try {
1236 1236
 			$Connection = new Connection();
1237 1237
 			$sth = $Connection->db->prepare($query);
1238
-                        $sth->execute();
1239
-                } catch(PDOException $e) {
1240
-                        return "error : ".$e->getMessage();
1241
-                }
1238
+						$sth->execute();
1239
+				} catch(PDOException $e) {
1240
+						return "error : ".$e->getMessage();
1241
+				}
1242 1242
 
1243 1243
 		
1244 1244
 		//update_db::unzip($out_file);
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 			if ($globalTransaction) $Connection->db->commit();
1269 1269
 		}
1270 1270
 		return '';
1271
-        }
1271
+		}
1272 1272
 
1273 1273
 	public static function banned_fam() {
1274 1274
 		global $tmp_dir, $globalTransaction;
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
 			if ($globalTransaction) $Connection->db->commit();
1303 1303
 		}
1304 1304
 		return '';
1305
-        }
1305
+		}
1306 1306
 
1307 1307
 	public static function tle($filename,$tletype) {
1308 1308
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1313,10 +1313,10 @@  discard block
 block discarded – undo
1313 1313
 		try {
1314 1314
 			$Connection = new Connection();
1315 1315
 			$sth = $Connection->db->prepare($query);
1316
-                        $sth->execute(array(':source' => $filename));
1317
-                } catch(PDOException $e) {
1318
-                        return "error : ".$e->getMessage();
1319
-                }
1316
+						$sth->execute(array(':source' => $filename));
1317
+				} catch(PDOException $e) {
1318
+						return "error : ".$e->getMessage();
1319
+				}
1320 1320
 		
1321 1321
 		$Connection = new Connection();
1322 1322
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1351,54 +1351,54 @@  discard block
 block discarded – undo
1351 1351
 			//$Connection->db->commit();
1352 1352
 		}
1353 1353
 		return '';
1354
-        }
1354
+		}
1355 1355
 
1356 1356
 	/**
1357
-        * Convert a HTML table to an array
1358
-        * @param String $data HTML page
1359
-        * @return Array array of the tables in HTML page
1360
-        */
1361
-        private static function table2array($data) {
1362
-                $html = str_get_html($data);
1363
-                $tabledata=array();
1364
-                foreach($html->find('tr') as $element)
1365
-                {
1366
-                        $td = array();
1367
-                        foreach( $element->find('th') as $row)
1368
-                        {
1369
-                                $td [] = trim($row->plaintext);
1370
-                        }
1371
-                        $td=array_filter($td);
1372
-                        $tabledata[] = $td;
1373
-
1374
-                        $td = array();
1375
-                        $tdi = array();
1376
-                        foreach( $element->find('td') as $row)
1377
-                        {
1378
-                                $td [] = trim($row->plaintext);
1379
-                                $tdi [] = trim($row->innertext);
1380
-                        }
1381
-                        $td=array_filter($td);
1382
-                        $tdi=array_filter($tdi);
1383
-                    //    $tabledata[]=array_merge($td,$tdi);
1384
-                        $tabledata[]=$td;
1385
-                }
1386
-                return(array_filter($tabledata));
1387
-        }
1388
-
1389
-       /**
1390
-        * Get data from form result
1391
-        * @param String $url form URL
1392
-        * @return String the result
1393
-        */
1394
-        private static function getData($url) {
1395
-                $ch = curl_init();
1396
-                curl_setopt($ch, CURLOPT_URL, $url);
1397
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1398
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1399
-                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');
1400
-                return curl_exec($ch);
1401
-        }
1357
+	 * Convert a HTML table to an array
1358
+	 * @param String $data HTML page
1359
+	 * @return Array array of the tables in HTML page
1360
+	 */
1361
+		private static function table2array($data) {
1362
+				$html = str_get_html($data);
1363
+				$tabledata=array();
1364
+				foreach($html->find('tr') as $element)
1365
+				{
1366
+						$td = array();
1367
+						foreach( $element->find('th') as $row)
1368
+						{
1369
+								$td [] = trim($row->plaintext);
1370
+						}
1371
+						$td=array_filter($td);
1372
+						$tabledata[] = $td;
1373
+
1374
+						$td = array();
1375
+						$tdi = array();
1376
+						foreach( $element->find('td') as $row)
1377
+						{
1378
+								$td [] = trim($row->plaintext);
1379
+								$tdi [] = trim($row->innertext);
1380
+						}
1381
+						$td=array_filter($td);
1382
+						$tdi=array_filter($tdi);
1383
+					//    $tabledata[]=array_merge($td,$tdi);
1384
+						$tabledata[]=$td;
1385
+				}
1386
+				return(array_filter($tabledata));
1387
+		}
1388
+
1389
+	   /**
1390
+	    * Get data from form result
1391
+	    * @param String $url form URL
1392
+	    * @return String the result
1393
+	    */
1394
+		private static function getData($url) {
1395
+				$ch = curl_init();
1396
+				curl_setopt($ch, CURLOPT_URL, $url);
1397
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1398
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1399
+				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');
1400
+				return curl_exec($ch);
1401
+		}
1402 1402
 /*
1403 1403
 	public static function waypoints() {
1404 1404
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
 			if ($globalTransaction) $Connection->db->commit();
1482 1482
 		}
1483 1483
 		return '';
1484
-        }
1484
+		}
1485 1485
 
1486 1486
 	public static function ivao_airlines($filename) {
1487 1487
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1491,10 +1491,10 @@  discard block
 block discarded – undo
1491 1491
 		try {
1492 1492
 			$Connection = new Connection();
1493 1493
 			$sth = $Connection->db->prepare($query);
1494
-                        $sth->execute();
1495
-                } catch(PDOException $e) {
1496
-                        return "error : ".$e->getMessage();
1497
-                }
1494
+						$sth->execute();
1495
+				} catch(PDOException $e) {
1496
+						return "error : ".$e->getMessage();
1497
+				}
1498 1498
 
1499 1499
 		$header = NULL;
1500 1500
 		$delimiter = ':';
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
 			if ($globalTransaction) $Connection->db->commit();
1519 1519
 		}
1520 1520
 		return '';
1521
-        }
1521
+		}
1522 1522
 	
1523 1523
 	public static function update_airspace() {
1524 1524
 		global $tmp_dir, $globalDBdriver;
@@ -1528,11 +1528,11 @@  discard block
 block discarded – undo
1528 1528
 			$query = 'DROP TABLE airspace';
1529 1529
 			try {
1530 1530
 				$sth = $Connection->db->prepare($query);
1531
-                    		$sth->execute();
1532
-	                } catch(PDOException $e) {
1531
+							$sth->execute();
1532
+					} catch(PDOException $e) {
1533 1533
 				return "error : ".$e->getMessage();
1534
-	                }
1535
-	        }
1534
+					}
1535
+			}
1536 1536
 
1537 1537
 
1538 1538
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1587,10 +1587,10 @@  discard block
 block discarded – undo
1587 1587
 			$query = 'DROP TABLE countries';
1588 1588
 			try {
1589 1589
 				$sth = $Connection->db->prepare($query);
1590
-            	        	$sth->execute();
1591
-	                } catch(PDOException $e) {
1592
-    	                	echo "error : ".$e->getMessage();
1593
-	                }
1590
+							$sth->execute();
1591
+					} catch(PDOException $e) {
1592
+							echo "error : ".$e->getMessage();
1593
+					}
1594 1594
 		}
1595 1595
 		if ($globalDBdriver == 'mysql') {
1596 1596
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2119,11 +2119,11 @@  discard block
 block discarded – undo
2119 2119
 						$query = 'DROP TABLE airspace';
2120 2120
 						try {
2121 2121
 							$sth = $Connection->db->prepare($query);
2122
-    	    	    					$sth->execute();
2123
-			            		} catch(PDOException $e) {
2122
+										$sth->execute();
2123
+								} catch(PDOException $e) {
2124 2124
 							return "error : ".$e->getMessage();
2125
-		            			}
2126
-		    			}
2125
+								}
2126
+						}
2127 2127
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2128 2128
 					update_db::insert_airspace_version($airspace_md5);
2129 2129
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -2303,12 +2303,12 @@  discard block
 block discarded – undo
2303 2303
 		echo $data;
2304 2304
 		*/
2305 2305
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2306
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2307
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2308
-		    $result = fread($fh,100000000);
2309
-		    //echo $result;
2310
-		    //var_dump(str_get_html($result));
2311
-		    //print_r(self::table2array($result));
2306
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2307
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2308
+			$result = fread($fh,100000000);
2309
+			//echo $result;
2310
+			//var_dump(str_get_html($result));
2311
+			//print_r(self::table2array($result));
2312 2312
 		}
2313 2313
 
2314 2314
 	}
@@ -2322,10 +2322,10 @@  discard block
 block discarded – undo
2322 2322
 		try {
2323 2323
 			$Connection = new Connection();
2324 2324
 			$sth = $Connection->db->prepare($query);
2325
-                        $sth->execute();
2326
-                } catch(PDOException $e) {
2327
-                        return "error : ".$e->getMessage();
2328
-                }
2325
+						$sth->execute();
2326
+				} catch(PDOException $e) {
2327
+						return "error : ".$e->getMessage();
2328
+				}
2329 2329
 
2330 2330
 		$error = '';
2331 2331
 		if ($globalDebug) echo "Notam : Download...";
@@ -2381,8 +2381,8 @@  discard block
 block discarded – undo
2381 2381
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2382 2382
 					$data['permanent'] = 0;
2383 2383
 				} else {
2384
-				    $data['date_end'] = NULL;
2385
-				    $data['permanent'] = 1;
2384
+					$data['date_end'] = NULL;
2385
+					$data['permanent'] = 1;
2386 2386
 				}
2387 2387
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2388 2388
 				$NOTAM = new NOTAM();
@@ -2456,13 +2456,13 @@  discard block
 block discarded – undo
2456 2456
 		try {
2457 2457
 			$Connection = new Connection();
2458 2458
 			$sth = $Connection->db->prepare($query);
2459
-                        $sth->execute();
2460
-                } catch(PDOException $e) {
2461
-                        return "error : ".$e->getMessage();
2462
-                }
2463
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2464
-                if ($row['nb'] > 0) return false;
2465
-                else return true;
2459
+						$sth->execute();
2460
+				} catch(PDOException $e) {
2461
+						return "error : ".$e->getMessage();
2462
+				}
2463
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2464
+				if ($row['nb'] > 0) return false;
2465
+				else return true;
2466 2466
 	}
2467 2467
 
2468 2468
 	public static function insert_last_update() {
@@ -2471,10 +2471,10 @@  discard block
 block discarded – undo
2471 2471
 		try {
2472 2472
 			$Connection = new Connection();
2473 2473
 			$sth = $Connection->db->prepare($query);
2474
-                        $sth->execute();
2475
-                } catch(PDOException $e) {
2476
-                        return "error : ".$e->getMessage();
2477
-                }
2474
+						$sth->execute();
2475
+				} catch(PDOException $e) {
2476
+						return "error : ".$e->getMessage();
2477
+				}
2478 2478
 	}
2479 2479
 
2480 2480
 	public static function check_airspace_version($version) {
@@ -2482,13 +2482,13 @@  discard block
 block discarded – undo
2482 2482
 		try {
2483 2483
 			$Connection = new Connection();
2484 2484
 			$sth = $Connection->db->prepare($query);
2485
-                        $sth->execute(array(':version' => $version));
2486
-                } catch(PDOException $e) {
2487
-                        return "error : ".$e->getMessage();
2488
-                }
2489
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2490
-                if ($row['nb'] > 0) return true;
2491
-                else return false;
2485
+						$sth->execute(array(':version' => $version));
2486
+				} catch(PDOException $e) {
2487
+						return "error : ".$e->getMessage();
2488
+				}
2489
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2490
+				if ($row['nb'] > 0) return true;
2491
+				else return false;
2492 2492
 	}
2493 2493
 
2494 2494
 	public static function check_geoid_version($version) {
@@ -2496,13 +2496,13 @@  discard block
 block discarded – undo
2496 2496
 		try {
2497 2497
 			$Connection = new Connection();
2498 2498
 			$sth = $Connection->db->prepare($query);
2499
-                        $sth->execute(array(':version' => $version));
2500
-                } catch(PDOException $e) {
2501
-                        return "error : ".$e->getMessage();
2502
-                }
2503
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2504
-                if ($row['nb'] > 0) return true;
2505
-                else return false;
2499
+						$sth->execute(array(':version' => $version));
2500
+				} catch(PDOException $e) {
2501
+						return "error : ".$e->getMessage();
2502
+				}
2503
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2504
+				if ($row['nb'] > 0) return true;
2505
+				else return false;
2506 2506
 	}
2507 2507
 
2508 2508
 	public static function check_marine_identity_version($version) {
@@ -2510,13 +2510,13 @@  discard block
 block discarded – undo
2510 2510
 		try {
2511 2511
 			$Connection = new Connection();
2512 2512
 			$sth = $Connection->db->prepare($query);
2513
-                        $sth->execute(array(':version' => $version));
2514
-                } catch(PDOException $e) {
2515
-                        return "error : ".$e->getMessage();
2516
-                }
2517
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2518
-                if ($row['nb'] > 0) return true;
2519
-                else return false;
2513
+						$sth->execute(array(':version' => $version));
2514
+				} catch(PDOException $e) {
2515
+						return "error : ".$e->getMessage();
2516
+				}
2517
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2518
+				if ($row['nb'] > 0) return true;
2519
+				else return false;
2520 2520
 	}
2521 2521
 
2522 2522
 
@@ -2538,10 +2538,10 @@  discard block
 block discarded – undo
2538 2538
 		try {
2539 2539
 			$Connection = new Connection();
2540 2540
 			$sth = $Connection->db->prepare($query);
2541
-                        $sth->execute(array(':version' => $version));
2542
-                } catch(PDOException $e) {
2543
-                        return "error : ".$e->getMessage();
2544
-                }
2541
+						$sth->execute(array(':version' => $version));
2542
+				} catch(PDOException $e) {
2543
+						return "error : ".$e->getMessage();
2544
+				}
2545 2545
 	}
2546 2546
 
2547 2547
 	public static function insert_marine_identity_version($version) {
@@ -2550,10 +2550,10 @@  discard block
 block discarded – undo
2550 2550
 		try {
2551 2551
 			$Connection = new Connection();
2552 2552
 			$sth = $Connection->db->prepare($query);
2553
-                        $sth->execute(array(':version' => $version));
2554
-                } catch(PDOException $e) {
2555
-                        return "error : ".$e->getMessage();
2556
-                }
2553
+						$sth->execute(array(':version' => $version));
2554
+				} catch(PDOException $e) {
2555
+						return "error : ".$e->getMessage();
2556
+				}
2557 2557
 	}
2558 2558
 
2559 2559
 	public static function check_last_notam_update() {
@@ -2566,13 +2566,13 @@  discard block
 block discarded – undo
2566 2566
 		try {
2567 2567
 			$Connection = new Connection();
2568 2568
 			$sth = $Connection->db->prepare($query);
2569
-                        $sth->execute();
2570
-                } catch(PDOException $e) {
2571
-                        return "error : ".$e->getMessage();
2572
-                }
2573
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2574
-                if ($row['nb'] > 0) return false;
2575
-                else return true;
2569
+						$sth->execute();
2570
+				} catch(PDOException $e) {
2571
+						return "error : ".$e->getMessage();
2572
+				}
2573
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2574
+				if ($row['nb'] > 0) return false;
2575
+				else return true;
2576 2576
 	}
2577 2577
 
2578 2578
 	public static function insert_last_notam_update() {
@@ -2581,10 +2581,10 @@  discard block
 block discarded – undo
2581 2581
 		try {
2582 2582
 			$Connection = new Connection();
2583 2583
 			$sth = $Connection->db->prepare($query);
2584
-                        $sth->execute();
2585
-                } catch(PDOException $e) {
2586
-                        return "error : ".$e->getMessage();
2587
-                }
2584
+						$sth->execute();
2585
+				} catch(PDOException $e) {
2586
+						return "error : ".$e->getMessage();
2587
+				}
2588 2588
 	}
2589 2589
 
2590 2590
 	public static function check_last_airspace_update() {
@@ -2597,13 +2597,13 @@  discard block
 block discarded – undo
2597 2597
 		try {
2598 2598
 			$Connection = new Connection();
2599 2599
 			$sth = $Connection->db->prepare($query);
2600
-                        $sth->execute();
2601
-                } catch(PDOException $e) {
2602
-                        return "error : ".$e->getMessage();
2603
-                }
2604
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2605
-                if ($row['nb'] > 0) return false;
2606
-                else return true;
2600
+						$sth->execute();
2601
+				} catch(PDOException $e) {
2602
+						return "error : ".$e->getMessage();
2603
+				}
2604
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2605
+				if ($row['nb'] > 0) return false;
2606
+				else return true;
2607 2607
 	}
2608 2608
 
2609 2609
 	public static function insert_last_airspace_update() {
@@ -2612,10 +2612,10 @@  discard block
 block discarded – undo
2612 2612
 		try {
2613 2613
 			$Connection = new Connection();
2614 2614
 			$sth = $Connection->db->prepare($query);
2615
-                        $sth->execute();
2616
-                } catch(PDOException $e) {
2617
-                        return "error : ".$e->getMessage();
2618
-                }
2615
+						$sth->execute();
2616
+				} catch(PDOException $e) {
2617
+						return "error : ".$e->getMessage();
2618
+				}
2619 2619
 	}
2620 2620
 
2621 2621
 	public static function check_last_geoid_update() {
@@ -2628,13 +2628,13 @@  discard block
 block discarded – undo
2628 2628
 		try {
2629 2629
 			$Connection = new Connection();
2630 2630
 			$sth = $Connection->db->prepare($query);
2631
-                        $sth->execute();
2632
-                } catch(PDOException $e) {
2633
-                        return "error : ".$e->getMessage();
2634
-                }
2635
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2636
-                if ($row['nb'] > 0) return false;
2637
-                else return true;
2631
+						$sth->execute();
2632
+				} catch(PDOException $e) {
2633
+						return "error : ".$e->getMessage();
2634
+				}
2635
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2636
+				if ($row['nb'] > 0) return false;
2637
+				else return true;
2638 2638
 	}
2639 2639
 
2640 2640
 	public static function insert_last_geoid_update() {
@@ -2643,10 +2643,10 @@  discard block
 block discarded – undo
2643 2643
 		try {
2644 2644
 			$Connection = new Connection();
2645 2645
 			$sth = $Connection->db->prepare($query);
2646
-                        $sth->execute();
2647
-                } catch(PDOException $e) {
2648
-                        return "error : ".$e->getMessage();
2649
-                }
2646
+						$sth->execute();
2647
+				} catch(PDOException $e) {
2648
+						return "error : ".$e->getMessage();
2649
+				}
2650 2650
 	}
2651 2651
 
2652 2652
 	public static function check_last_owner_update() {
@@ -2659,13 +2659,13 @@  discard block
 block discarded – undo
2659 2659
 		try {
2660 2660
 			$Connection = new Connection();
2661 2661
 			$sth = $Connection->db->prepare($query);
2662
-                        $sth->execute();
2663
-                } catch(PDOException $e) {
2664
-                        return "error : ".$e->getMessage();
2665
-                }
2666
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2667
-                if ($row['nb'] > 0) return false;
2668
-                else return true;
2662
+						$sth->execute();
2663
+				} catch(PDOException $e) {
2664
+						return "error : ".$e->getMessage();
2665
+				}
2666
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2667
+				if ($row['nb'] > 0) return false;
2668
+				else return true;
2669 2669
 	}
2670 2670
 
2671 2671
 	public static function insert_last_owner_update() {
@@ -2674,10 +2674,10 @@  discard block
 block discarded – undo
2674 2674
 		try {
2675 2675
 			$Connection = new Connection();
2676 2676
 			$sth = $Connection->db->prepare($query);
2677
-                        $sth->execute();
2678
-                } catch(PDOException $e) {
2679
-                        return "error : ".$e->getMessage();
2680
-                }
2677
+						$sth->execute();
2678
+				} catch(PDOException $e) {
2679
+						return "error : ".$e->getMessage();
2680
+				}
2681 2681
 	}
2682 2682
 	public static function check_last_schedules_update() {
2683 2683
 		global $globalDBdriver;
@@ -2689,13 +2689,13 @@  discard block
 block discarded – undo
2689 2689
 		try {
2690 2690
 			$Connection = new Connection();
2691 2691
 			$sth = $Connection->db->prepare($query);
2692
-                        $sth->execute();
2693
-                } catch(PDOException $e) {
2694
-                        return "error : ".$e->getMessage();
2695
-                }
2696
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2697
-                if ($row['nb'] > 0) return false;
2698
-                else return true;
2692
+						$sth->execute();
2693
+				} catch(PDOException $e) {
2694
+						return "error : ".$e->getMessage();
2695
+				}
2696
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2697
+				if ($row['nb'] > 0) return false;
2698
+				else return true;
2699 2699
 	}
2700 2700
 
2701 2701
 	public static function insert_last_schedules_update() {
@@ -2704,10 +2704,10 @@  discard block
 block discarded – undo
2704 2704
 		try {
2705 2705
 			$Connection = new Connection();
2706 2706
 			$sth = $Connection->db->prepare($query);
2707
-                        $sth->execute();
2708
-                } catch(PDOException $e) {
2709
-                        return "error : ".$e->getMessage();
2710
-                }
2707
+						$sth->execute();
2708
+				} catch(PDOException $e) {
2709
+						return "error : ".$e->getMessage();
2710
+				}
2711 2711
 	}
2712 2712
 	public static function check_last_tle_update() {
2713 2713
 		global $globalDBdriver;
@@ -2719,13 +2719,13 @@  discard block
 block discarded – undo
2719 2719
 		try {
2720 2720
 			$Connection = new Connection();
2721 2721
 			$sth = $Connection->db->prepare($query);
2722
-                        $sth->execute();
2723
-                } catch(PDOException $e) {
2724
-                        return "error : ".$e->getMessage();
2725
-                }
2726
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2727
-                if ($row['nb'] > 0) return false;
2728
-                else return true;
2722
+						$sth->execute();
2723
+				} catch(PDOException $e) {
2724
+						return "error : ".$e->getMessage();
2725
+				}
2726
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2727
+				if ($row['nb'] > 0) return false;
2728
+				else return true;
2729 2729
 	}
2730 2730
 
2731 2731
 	public static function insert_last_tle_update() {
@@ -2734,10 +2734,10 @@  discard block
 block discarded – undo
2734 2734
 		try {
2735 2735
 			$Connection = new Connection();
2736 2736
 			$sth = $Connection->db->prepare($query);
2737
-                        $sth->execute();
2738
-                } catch(PDOException $e) {
2739
-                        return "error : ".$e->getMessage();
2740
-                }
2737
+						$sth->execute();
2738
+				} catch(PDOException $e) {
2739
+						return "error : ".$e->getMessage();
2740
+				}
2741 2741
 	}
2742 2742
 	public static function check_last_marine_identity_update() {
2743 2743
 		global $globalDBdriver;
@@ -2749,13 +2749,13 @@  discard block
 block discarded – undo
2749 2749
 		try {
2750 2750
 			$Connection = new Connection();
2751 2751
 			$sth = $Connection->db->prepare($query);
2752
-                        $sth->execute();
2753
-                } catch(PDOException $e) {
2754
-                        return "error : ".$e->getMessage();
2755
-                }
2756
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2757
-                if ($row['nb'] > 0) return false;
2758
-                else return true;
2752
+						$sth->execute();
2753
+				} catch(PDOException $e) {
2754
+						return "error : ".$e->getMessage();
2755
+				}
2756
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2757
+				if ($row['nb'] > 0) return false;
2758
+				else return true;
2759 2759
 	}
2760 2760
 
2761 2761
 	public static function insert_last_marine_identity_update() {
@@ -2764,10 +2764,10 @@  discard block
 block discarded – undo
2764 2764
 		try {
2765 2765
 			$Connection = new Connection();
2766 2766
 			$sth = $Connection->db->prepare($query);
2767
-                        $sth->execute();
2768
-                } catch(PDOException $e) {
2769
-                        return "error : ".$e->getMessage();
2770
-                }
2767
+						$sth->execute();
2768
+				} catch(PDOException $e) {
2769
+						return "error : ".$e->getMessage();
2770
+				}
2771 2771
 	}
2772 2772
 	public static function delete_duplicatemodes() {
2773 2773
 		global $globalDBdriver;
@@ -2779,10 +2779,10 @@  discard block
 block discarded – undo
2779 2779
 		try {
2780 2780
 			$Connection = new Connection();
2781 2781
 			$sth = $Connection->db->prepare($query);
2782
-                        $sth->execute();
2783
-                } catch(PDOException $e) {
2784
-                        return "error : ".$e->getMessage();
2785
-                }
2782
+						$sth->execute();
2783
+				} catch(PDOException $e) {
2784
+						return "error : ".$e->getMessage();
2785
+				}
2786 2786
 	}
2787 2787
 	public static function delete_duplicateowner() {
2788 2788
 		global $globalDBdriver;
@@ -2794,10 +2794,10 @@  discard block
 block discarded – undo
2794 2794
 		try {
2795 2795
 			$Connection = new Connection();
2796 2796
 			$sth = $Connection->db->prepare($query);
2797
-                        $sth->execute();
2798
-                } catch(PDOException $e) {
2799
-                        return "error : ".$e->getMessage();
2800
-                }
2797
+						$sth->execute();
2798
+				} catch(PDOException $e) {
2799
+						return "error : ".$e->getMessage();
2800
+				}
2801 2801
 	}
2802 2802
 	
2803 2803
 	public static function update_all() {
Please login to merge, or discard this patch.
Spacing   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
 		fclose($fp);
26 26
 	}
27 27
 
28
-	public static function gunzip($in_file,$out_file_name = '') {
28
+	public static function gunzip($in_file, $out_file_name = '') {
29 29
 		//echo $in_file.' -> '.$out_file_name."\n";
30 30
 		$buffer_size = 4096; // read 4kb at a time
31 31
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32 32
 		if ($in_file != '' && file_exists($in_file)) {
33 33
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
34
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
35
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
36 36
 			else {
37 37
 				echo 'gzopen not available';
38 38
 				die;
39 39
 			}
40 40
 			$out_file = fopen($out_file_name, 'wb'); 
41
-			while(!gzeof($file)) {
41
+			while (!gzeof($file)) {
42 42
 				fwrite($out_file, gzread($file, $buffer_size));
43 43
 			}  
44 44
 			fclose($out_file);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		try {
63 63
 			self::$db_sqlite = new PDO('sqlite:'.$database);
64 64
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
65
-		} catch(PDOException $e) {
65
+		} catch (PDOException $e) {
66 66
 			return "error : ".$e->getMessage();
67 67
 		}
68 68
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79 79
                         $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
80
+                } catch (PDOException $e) {
81 81
                         return "error : ".$e->getMessage();
82 82
                 }
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		try {
89 89
                         $sth = update_db::$db_sqlite->prepare($query);
90 90
                         $sth->execute();
91
-                } catch(PDOException $e) {
91
+                } catch (PDOException $e) {
92 92
                         return "error : ".$e->getMessage();
93 93
                 }
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100 100
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104 104
             		}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
@@ -119,26 +119,26 @@  discard block
 block discarded – undo
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121 121
                         $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
122
+                } catch (PDOException $e) {
123 123
                         return "error : ".$e->getMessage();
124 124
                 }
125 125
 
126 126
     		if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129
-		if ($fh = fopen($database_file,"r")) {
129
+		if ($fh = fopen($database_file, "r")) {
130 130
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 131
 			$Connection = new Connection();
132 132
 			$sth_dest = $Connection->db->prepare($query_dest);
133 133
 			if ($globalTransaction) $Connection->db->beginTransaction();
134 134
 			while (!feof($fh)) {
135
-				$line = fgetcsv($fh,9999,',');
135
+				$line = fgetcsv($fh, 9999, ',');
136 136
 				if ($line[0] != '') {
137 137
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
138 138
 						try {
139
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
140 140
 							$sth_dest->execute($query_dest_values);
141
-						} catch(PDOException $e) {
141
+						} catch (PDOException $e) {
142 142
 							if ($globalTransaction) $Connection->db->rollBack(); 
143 143
 							return "error : ".$e->getMessage();
144 144
 						}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162 162
                         $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
163
+                } catch (PDOException $e) {
164 164
                         return "error : ".$e->getMessage();
165 165
                 }
166 166
 
@@ -168,24 +168,24 @@  discard block
 block discarded – undo
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
171
-		if ($fh = fopen($database_file,"r")) {
171
+		if ($fh = fopen($database_file, "r")) {
172 172
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
173 173
 			$Connection = new Connection();
174 174
 			$sth_dest = $Connection->db->prepare($query_dest);
175 175
 			try {
176 176
 				if ($globalTransaction) $Connection->db->beginTransaction();
177 177
 				while (!feof($fh)) {
178
-					$line = fgetcsv($fh,9999,',');
178
+					$line = fgetcsv($fh, 9999, ',');
179 179
 					if ($line[0] != '') {
180
-						$datebe = explode('  -  ',$line[2]);
180
+						$datebe = explode('  -  ', $line[2]);
181 181
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
182
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
182
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
183 183
 							$sth_dest->execute($query_dest_values);
184 184
 						}
185 185
 					}
186 186
 				}
187 187
 				if ($globalTransaction) $Connection->db->commit();
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				if ($globalTransaction) $Connection->db->rollBack(); 
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202 202
                         $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
203
+                } catch (PDOException $e) {
204 204
                         return "error : ".$e->getMessage();
205 205
                 }
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210 210
                         $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
211
+                } catch (PDOException $e) {
212 212
                         return "error : ".$e->getMessage();
213 213
                 }
214 214
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		try {
218 218
                         $sth = update_db::$db_sqlite->prepare($query);
219 219
                         $sth->execute();
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
241 241
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243 243
             		}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245
-		} catch(PDOException $e) {
245
+		} catch (PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
247 247
 		}
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254 254
                         $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
255
+                } catch (PDOException $e) {
256 256
                         return "error : ".$e->getMessage();
257 257
                 }
258 258
 		return '';
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269 269
                         $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
270
+                } catch (PDOException $e) {
271 271
                         return "error : ".$e->getMessage();
272 272
                 }
273 273
 		
274
-		if ($fh = fopen($database_file,"r")) {
274
+		if ($fh = fopen($database_file, "r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
276 276
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
277 277
 		
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282 282
             			while (!feof($fh)) {
283 283
             				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
284
+            				$line = $Common->hex2str(fgets($fh, 9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
286
+            				$values['ModeS'] = substr($line, 0, 6);
287
+            				$values['Registration'] = trim(substr($line, 69, 6));
288
+            				$aircraft_name = trim(substr($line, 48, 6));
289 289
             				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
+            				$aircraft_name_split = explode(' ', $aircraft_name);
291 291
             				$search_more = '';
292 292
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293 293
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 	            				if (isset($result['icao']) && $result['icao'] != '') {
300 300
 	            				    $values['ICAOTypeCode'] = $result['icao'];
301 301
 	            				} 
302
-					} catch(PDOException $e) {
302
+					} catch (PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
305 305
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
306 306
 					// Add data to db
307 307
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 308
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
309
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
309
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
310 310
 						//print_r($query_dest_values);
311 311
 						$sth_dest->execute($query_dest_values);
312 312
 					}
313 313
 				}
314 314
 				if ($globalTransaction) $Connection->db->commit();
315
-			} catch(PDOException $e) {
315
+			} catch (PDOException $e) {
316 316
 				return "error : ".$e->getMessage();
317 317
 			}
318 318
 		}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324 324
                         $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
325
+                } catch (PDOException $e) {
326 326
                         return "error : ".$e->getMessage();
327 327
                 }
328 328
 		return '';
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338 338
                         $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
339
+                } catch (PDOException $e) {
340 340
                         return "error : ".$e->getMessage();
341 341
                 }
342 342
 		
343
-		if ($fh = fopen($database_file,"r")) {
343
+		if ($fh = fopen($database_file, "r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
345 345
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
346 346
 		
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 			$sth_dest = $Connection->db->prepare($query_dest);
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351
-				$tmp = fgetcsv($fh,9999,',',"'");
351
+				$tmp = fgetcsv($fh, 9999, ',', "'");
352 352
             			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
353
+            				$line = fgetcsv($fh, 9999, ',', "'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             				$values['ICAOTypeCode'] = '';
360 360
             				$aircraft_name = $line[2];
361 361
             				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
362
+            				$aircraft_name_split = explode(' ', $aircraft_name);
363 363
             				$search_more = '';
364 364
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365 365
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -368,20 +368,20 @@  discard block
 block discarded – undo
368 368
                                     		$sth_search->execute();
369 369
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370 370
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371
-					} catch(PDOException $e) {
371
+					} catch (PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
374 374
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
375 375
 					// Add data to db
376 376
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
377 377
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
378
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
378
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
379 379
 						//print_r($query_dest_values);
380 380
 						$sth_dest->execute($query_dest_values);
381 381
 					}
382 382
 				}
383 383
 				if ($globalTransaction) $Connection->db->commit();
384
-			} catch(PDOException $e) {
384
+			} catch (PDOException $e) {
385 385
 				return "error : ".$e->getMessage();
386 386
 			}
387 387
 		}
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393 393
                         $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
394
+                } catch (PDOException $e) {
395 395
                         return "error : ".$e->getMessage();
396 396
                 }
397 397
 		return '';
398 398
 	}
399 399
 
400
-	public static function retrieve_owner($database_file,$country = 'F') {
400
+	public static function retrieve_owner($database_file, $country = 'F') {
401 401
 		global $globalTransaction, $globalMasterSource;
402 402
 		//$query = 'TRUNCATE TABLE aircraft_modes';
403 403
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -405,12 +405,12 @@  discard block
 block discarded – undo
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407 407
                         $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
408
+                } catch (PDOException $e) {
409 409
                         return "error : ".$e->getMessage();
410 410
                 }
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413
-		if ($fh = fopen($database_file,"r")) {
413
+		if ($fh = fopen($database_file, "r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416 416
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 			$sth_modes = $Connection->db->prepare($query_modes);
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423
-				$tmp = fgetcsv($fh,9999,',','"');
423
+				$tmp = fgetcsv($fh, 9999, ',', '"');
424 424
             			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
425
+            				$line = fgetcsv($fh, 9999, ',', '"');
426 426
             				$values = array();
427 427
             				//print_r($line);
428 428
             				if ($country == 'F') {
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
             				    $values['base'] = $line[4];
431 431
             				    $values['owner'] = $line[5];
432 432
             				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
433
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
434 434
 					    $values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436 436
 					    // TODO : add modeS & reg to aircraft_modes
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             				    $values['base'] = $line[3];
439 439
             				    $values['owner'] = $line[2];
440 440
             				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
441
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
442 442
 					    $values['cancel'] = '';
443 443
 					    $values['modes'] = $line[7];
444 444
 					    $values['icao'] = $line[8];
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
             				    $values['base'] = null;
459 459
             				    $values['owner'] = $line[5];
460 460
             				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
461
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
462 462
 					    $values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464 464
 					    // TODO : add modeS & reg to aircraft_modes
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             				    $values['base'] = null;
467 467
             				    $values['owner'] = $line[12];
468 468
             				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
469
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
470 470
 
471 471
 					    $values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -486,28 +486,28 @@  discard block
 block discarded – undo
486 486
             				    $values['base'] = null;
487 487
             				    $values['owner'] = $line[8];
488 488
             				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
489
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
490 490
 					    $values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492 492
             				    $values['registration'] = $line[0];
493 493
             				    $values['base'] = null;
494 494
             				    $values['owner'] = $line[4];
495 495
             				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
497 497
 					    $values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499 499
             				    $values['registration'] = $line[0];
500 500
             				    $values['base'] = null;
501 501
             				    $values['owner'] = $line[4];
502 502
             				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
503
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
504 504
 					    $values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506 506
             				    $values['registration'] = $line[0];
507 507
             				    $values['base'] = null;
508 508
             				    $values['owner'] = $line[3];
509 509
             				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
510
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
511 511
 					    $values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513 513
             				    $values['registration'] = $line[0];
@@ -521,18 +521,18 @@  discard block
 block discarded – undo
521 521
             				    $values['registration'] = $line[0];
522 522
             				    $values['base'] = null;
523 523
             				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
525
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
526 526
 					    $values['modes'] = $line[4];
527 527
 					    $values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529 529
             				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
530
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
531 531
 					    $values['modes'] = $line[5];
532 532
 					    $values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534 534
             				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
535
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
536 536
 					    $values['modes'] = $line[4];
537 537
 					    $values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -543,17 +543,17 @@  discard block
 block discarded – undo
543 543
 					    $values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
546
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
547 547
 						$sth_dest->execute($query_dest_values);
548 548
 					}
549 549
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
550 550
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
551
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
551
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
552 552
 						$sth_modes->execute($query_modes_values);
553 553
 					}
554 554
 				}
555 555
 				if ($globalTransaction) $Connection->db->commit();
556
-			} catch(PDOException $e) {
556
+			} catch (PDOException $e) {
557 557
 				return "error : ".$e->getMessage();
558 558
 			}
559 559
 		}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		if ($globalTransaction) $Connection->db->beginTransaction();
692 692
   
693 693
 		$i = 0;
694
-		while($row = sparql_fetch_array($result))
694
+		while ($row = sparql_fetch_array($result))
695 695
 		{
696 696
 			if ($i >= 1) {
697 697
 			//print_r($row);
@@ -711,33 +711,33 @@  discard block
 block discarded – undo
711 711
 				$row['image'] = '';
712 712
 				$row['image_thumb'] = '';
713 713
 			} else {
714
-				$image = str_replace(' ','_',$row['image']);
714
+				$image = str_replace(' ', '_', $row['image']);
715 715
 				$digest = md5($image);
716
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
717
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
718
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
719
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
716
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
717
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
718
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
719
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
720 720
 			}
721 721
 			
722
-			$country = explode('-',$row['country']);
722
+			$country = explode('-', $row['country']);
723 723
 			$row['country'] = $country[0];
724 724
 			
725 725
 			$row['type'] = trim($row['type']);
726
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
726
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
727 727
 				$row['type'] = 'military';
728 728
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
729 729
 				$row['type'] = 'small_airport';
730 730
 			}
731 731
 			
732
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
733
-			$query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
732
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
733
+			$query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
734 734
 			//print_r($query_dest_values);
735 735
 			
736 736
 			if ($row['icao'] != '') {
737 737
 				try {
738 738
 					$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
739 739
 					$sth->execute(array(':icao' => $row['icao']));
740
-				} catch(PDOException $e) {
740
+				} catch (PDOException $e) {
741 741
 					return "error : ".$e->getMessage();
742 742
 				}
743 743
 					if ($sth->fetchColumn() > 0) {
@@ -745,15 +745,15 @@  discard block
 block discarded – undo
745 745
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
746 746
 						try {
747 747
 							$sth = $Connection->db->prepare($query);
748
-							$sth->execute(array(':icao' => $row['icao'],':type' => $row['type']));
749
-						} catch(PDOException $e) {
748
+							$sth->execute(array(':icao' => $row['icao'], ':type' => $row['type']));
749
+						} catch (PDOException $e) {
750 750
 							return "error : ".$e->getMessage();
751 751
 						}
752 752
 						echo $row['icao'].' : '.$row['type']."\n";
753 753
 					} else {
754 754
 						try {
755 755
 							$sth_dest->execute($query_dest_values);
756
-						} catch(PDOException $e) {
756
+						} catch (PDOException $e) {
757 757
 							return "error : ".$e->getMessage();
758 758
 						}
759 759
 					}
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 		echo "Download data from ourairports.com...\n";
805 805
 		$delimiter = ',';
806 806
 		$out_file = $tmp_dir.'airports.csv';
807
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
807
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
808 808
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
809 809
 		echo "Add data from ourairports.com...\n";
810 810
 
@@ -815,33 +815,33 @@  discard block
 block discarded – undo
815 815
 			//$Connection->db->beginTransaction();
816 816
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
817 817
 			{
818
-				if(!$header) $header = $row;
818
+				if (!$header) $header = $row;
819 819
 				else {
820 820
 					$data = array();
821 821
 					$data = array_combine($header, $row);
822 822
 					try {
823 823
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
824 824
 						$sth->execute(array(':icao' => $data['ident']));
825
-					} catch(PDOException $e) {
825
+					} catch (PDOException $e) {
826 826
 						return "error : ".$e->getMessage();
827 827
 					}
828 828
 					if ($sth->fetchColumn() > 0) {
829 829
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
830 830
 						try {
831 831
 							$sth = $Connection->db->prepare($query);
832
-							$sth->execute(array(':icao' => $data['ident'],':type' => $data['type']));
833
-						} catch(PDOException $e) {
832
+							$sth->execute(array(':icao' => $data['ident'], ':type' => $data['type']));
833
+						} catch (PDOException $e) {
834 834
 							return "error : ".$e->getMessage();
835 835
 						}
836 836
 					} else {
837 837
 						if ($data['gps_code'] == $data['ident']) {
838 838
 						$query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link)
839 839
 						    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
840
-						$query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
840
+						$query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
841 841
 						try {
842 842
 							$sth = $Connection->db->prepare($query);
843 843
 							$sth->execute($query_values);
844
-						} catch(PDOException $e) {
844
+						} catch (PDOException $e) {
845 845
 							return "error : ".$e->getMessage();
846 846
 						}
847 847
 						$i++;
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 		
857 857
 		echo "Download data from another free database...\n";
858 858
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
859
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
859
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
860 860
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
861 861
 		update_db::unzip($out_file);
862 862
 		$header = NULL;
@@ -868,15 +868,15 @@  discard block
 block discarded – undo
868 868
 			//$Connection->db->beginTransaction();
869 869
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 870
 			{
871
-				if(!$header) $header = $row;
871
+				if (!$header) $header = $row;
872 872
 				else {
873 873
 					$data = $row;
874 874
 
875 875
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
876 876
 					try {
877 877
 						$sth = $Connection->db->prepare($query);
878
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
879
-					} catch(PDOException $e) {
878
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
879
+					} catch (PDOException $e) {
880 880
 						return "error : ".$e->getMessage();
881 881
 					}
882 882
 				}
@@ -890,15 +890,15 @@  discard block
 block discarded – undo
890 890
 		try {
891 891
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'");
892 892
 			$sth->execute();
893
-		} catch(PDOException $e) {
893
+		} catch (PDOException $e) {
894 894
 			return "error : ".$e->getMessage();
895 895
 		}
896 896
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
897 897
 			$query2 = 'UPDATE airport SET type = :type WHERE icao = :icao';
898 898
 			try {
899 899
 				$sth2 = $Connection->db->prepare($query2);
900
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
901
-			} catch(PDOException $e) {
900
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
901
+			} catch (PDOException $e) {
902 902
 				return "error : ".$e->getMessage();
903 903
 			}
904 904
 		}
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 			$Connection = new Connection();
920 920
 			$sth = $Connection->db->prepare($query);
921 921
                         $sth->execute(array(':source' => 'translation.csv'));
922
-                } catch(PDOException $e) {
922
+                } catch (PDOException $e) {
923 923
                         return "error : ".$e->getMessage();
924 924
                 }
925 925
 
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
937 937
 			{
938 938
 				$i++;
939
-				if($i > 12) {
939
+				if ($i > 12) {
940 940
 					$data = $row;
941 941
 					$operator = $data[2];
942 942
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
                                                 //echo substr($operator, 0, 2)."\n";;
945 945
                                                 if (count($airline_array) > 0) {
946 946
 							//print_r($airline_array);
947
-							$operator = $airline_array[0]['icao'].substr($operator,2);
947
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
948 948
                                                 }
949 949
                                         }
950 950
 					
@@ -952,14 +952,14 @@  discard block
 block discarded – undo
952 952
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
953 953
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954 954
                                                 if (count($airline_array) > 0) {
955
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
955
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
956 956
                                             	}
957 957
                                         }
958 958
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
959 959
 					try {
960 960
 						$sth = $Connection->db->prepare($query);
961
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
962
-					} catch(PDOException $e) {
961
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
962
+					} catch (PDOException $e) {
963 963
 						return "error : ".$e->getMessage();
964 964
 					}
965 965
 				}
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 			$Connection = new Connection();
980 980
 			$sth = $Connection->db->prepare($query);
981 981
                         $sth->execute(array(':source' => 'website_fam'));
982
-                } catch(PDOException $e) {
982
+                } catch (PDOException $e) {
983 983
                         return "error : ".$e->getMessage();
984 984
                 }
985 985
 
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
1000 1000
 					try {
1001 1001
 						$sth = $Connection->db->prepare($query);
1002
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
1003
-					} catch(PDOException $e) {
1002
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
1003
+					} catch (PDOException $e) {
1004 1004
 						return "error : ".$e->getMessage();
1005 1005
 					}
1006 1006
 				}
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 			$Connection = new Connection();
1024 1024
 			$sth = $Connection->db->prepare($query);
1025 1025
                         $sth->execute(array(':source' => 'website_faa'));
1026
-                } catch(PDOException $e) {
1026
+                } catch (PDOException $e) {
1027 1027
                         return "error : ".$e->getMessage();
1028 1028
                 }
1029 1029
 
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 			$Connection = new Connection();
1033 1033
 			$sth = $Connection->db->prepare($query);
1034 1034
                         $sth->execute(array(':source' => 'website_faa'));
1035
-                } catch(PDOException $e) {
1035
+                } catch (PDOException $e) {
1036 1036
                         return "error : ".$e->getMessage();
1037 1037
                 }
1038 1038
 
@@ -1049,8 +1049,8 @@  discard block
 block discarded – undo
1049 1049
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1050 1050
 					try {
1051 1051
 						$sths = $Connection->db->prepare($query_search);
1052
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1053
-					} catch(PDOException $e) {
1052
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1053
+					} catch (PDOException $e) {
1054 1054
 						return "error s : ".$e->getMessage();
1055 1055
 					}
1056 1056
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1063,8 +1063,8 @@  discard block
 block discarded – undo
1063 1063
 							//}
1064 1064
 						try {
1065 1065
 							$sthi = $Connection->db->prepare($queryi);
1066
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1067
-						} catch(PDOException $e) {
1066
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1067
+						} catch (PDOException $e) {
1068 1068
 							return "error u : ".$e->getMessage();
1069 1069
 						}
1070 1070
 					} else {
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 						try {
1073 1073
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1074 1074
 							$sthsm->execute(array(':mfr' => $data[2]));
1075
-						} catch(PDOException $e) {
1075
+						} catch (PDOException $e) {
1076 1076
 							return "error mfr : ".$e->getMessage();
1077 1077
 						}
1078 1078
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1082,8 +1082,8 @@  discard block
 block discarded – undo
1082 1082
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1083 1083
 							try {
1084 1084
 								$sthf = $Connection->db->prepare($queryf);
1085
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1086
-							} catch(PDOException $e) {
1085
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1086
+							} catch (PDOException $e) {
1087 1087
 								return "error f : ".$e->getMessage();
1088 1088
 							}
1089 1089
 						}
@@ -1093,13 +1093,13 @@  discard block
 block discarded – undo
1093 1093
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1094 1094
 						try {
1095 1095
 							$sth = $Connection->db->prepare($query);
1096
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1097
-						} catch(PDOException $e) {
1096
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1097
+						} catch (PDOException $e) {
1098 1098
 							return "error i : ".$e->getMessage();
1099 1099
 						}
1100 1100
 					}
1101 1101
 				}
1102
-				if ($i % 90 == 0) {
1102
+				if ($i%90 == 0) {
1103 1103
 					if ($globalTransaction) $Connection->db->commit();
1104 1104
 					if ($globalTransaction) $Connection->db->beginTransaction();
1105 1105
 				}
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 			$Connection = new Connection();
1119 1119
 			$sth = $Connection->db->prepare($query);
1120 1120
                         $sth->execute(array(':source' => 'website_fam'));
1121
-                } catch(PDOException $e) {
1121
+                } catch (PDOException $e) {
1122 1122
                         return "error : ".$e->getMessage();
1123 1123
                 }
1124 1124
 
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1140
 					try {
1141 1141
 						$sth = $Connection->db->prepare($query);
1142
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1143
-					} catch(PDOException $e) {
1142
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1143
+					} catch (PDOException $e) {
1144 1144
 						return "error : ".$e->getMessage();
1145 1145
 					}
1146 1146
 				}
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 			$Connection = new Connection();
1160 1160
 			$sth = $Connection->db->prepare($query);
1161 1161
                         $sth->execute(array(':source' => 'website_fam'));
1162
-                } catch(PDOException $e) {
1162
+                } catch (PDOException $e) {
1163 1163
                         return "error : ".$e->getMessage();
1164 1164
                 }
1165 1165
 
@@ -1175,8 +1175,8 @@  discard block
 block discarded – undo
1175 1175
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1176 1176
 					try {
1177 1177
 						$sth = $Connection->db->prepare($query);
1178
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1179
-					} catch(PDOException $e) {
1178
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1179
+					} catch (PDOException $e) {
1180 1180
 						print_r($data);
1181 1181
 						return "error : ".$e->getMessage();
1182 1182
 					}
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 			$Connection = new Connection();
1197 1197
 			$sth = $Connection->db->prepare($query);
1198 1198
                         $sth->execute(array(':source' => 'website_fam'));
1199
-                } catch(PDOException $e) {
1199
+                } catch (PDOException $e) {
1200 1200
                         return "error : ".$e->getMessage();
1201 1201
                 }
1202 1202
 
@@ -1216,8 +1216,8 @@  discard block
 block discarded – undo
1216 1216
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1217 1217
 					try {
1218 1218
 						$sth = $Connection->db->prepare($query);
1219
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1220
-					} catch(PDOException $e) {
1219
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1220
+					} catch (PDOException $e) {
1221 1221
 						return "error : ".$e->getMessage();
1222 1222
 					}
1223 1223
 				}
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 			$Connection = new Connection();
1237 1237
 			$sth = $Connection->db->prepare($query);
1238 1238
                         $sth->execute();
1239
-                } catch(PDOException $e) {
1239
+                } catch (PDOException $e) {
1240 1240
                         return "error : ".$e->getMessage();
1241 1241
                 }
1242 1242
 
@@ -1257,8 +1257,8 @@  discard block
 block discarded – undo
1257 1257
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1258 1258
 					try {
1259 1259
 						$sth = $Connection->db->prepare($query);
1260
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1261
-					} catch(PDOException $e) {
1260
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1261
+					} catch (PDOException $e) {
1262 1262
 						return "error : ".$e->getMessage();
1263 1263
 					}
1264 1264
 				}
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 			$Connection = new Connection();
1278 1278
 			$sth = $Connection->db->prepare($query);
1279 1279
 			$sth->execute();
1280
-		} catch(PDOException $e) {
1280
+		} catch (PDOException $e) {
1281 1281
 			return "error : ".$e->getMessage();
1282 1282
 		}
1283 1283
 
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 					try {
1294 1294
 						$sth = $Connection->db->prepare($query);
1295 1295
 						$sth->execute(array(':icao' => $icao));
1296
-					} catch(PDOException $e) {
1296
+					} catch (PDOException $e) {
1297 1297
 						return "error : ".$e->getMessage();
1298 1298
 					}
1299 1299
 				}
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
 		return '';
1305 1305
         }
1306 1306
 
1307
-	public static function tle($filename,$tletype) {
1307
+	public static function tle($filename, $tletype) {
1308 1308
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1309 1309
 		global $tmp_dir, $globalTransaction;
1310 1310
 		//$Spotter = new Spotter();
@@ -1314,7 +1314,7 @@  discard block
 block discarded – undo
1314 1314
 			$Connection = new Connection();
1315 1315
 			$sth = $Connection->db->prepare($query);
1316 1316
                         $sth->execute(array(':source' => $filename));
1317
-                } catch(PDOException $e) {
1317
+                } catch (PDOException $e) {
1318 1318
                         return "error : ".$e->getMessage();
1319 1319
                 }
1320 1320
 		
@@ -1339,8 +1339,8 @@  discard block
 block discarded – undo
1339 1339
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1340 1340
 					try {
1341 1341
 						$sth = $Connection->db->prepare($query);
1342
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1343
-					} catch(PDOException $e) {
1342
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1343
+					} catch (PDOException $e) {
1344 1344
 						return "error : ".$e->getMessage();
1345 1345
 					}
1346 1346
 
@@ -1360,28 +1360,28 @@  discard block
 block discarded – undo
1360 1360
         */
1361 1361
         private static function table2array($data) {
1362 1362
                 $html = str_get_html($data);
1363
-                $tabledata=array();
1364
-                foreach($html->find('tr') as $element)
1363
+                $tabledata = array();
1364
+                foreach ($html->find('tr') as $element)
1365 1365
                 {
1366 1366
                         $td = array();
1367
-                        foreach( $element->find('th') as $row)
1367
+                        foreach ($element->find('th') as $row)
1368 1368
                         {
1369 1369
                                 $td [] = trim($row->plaintext);
1370 1370
                         }
1371
-                        $td=array_filter($td);
1371
+                        $td = array_filter($td);
1372 1372
                         $tabledata[] = $td;
1373 1373
 
1374 1374
                         $td = array();
1375 1375
                         $tdi = array();
1376
-                        foreach( $element->find('td') as $row)
1376
+                        foreach ($element->find('td') as $row)
1377 1377
                         {
1378 1378
                                 $td [] = trim($row->plaintext);
1379 1379
                                 $tdi [] = trim($row->innertext);
1380 1380
                         }
1381
-                        $td=array_filter($td);
1382
-                        $tdi=array_filter($tdi);
1381
+                        $td = array_filter($td);
1382
+                        $tdi = array_filter($tdi);
1383 1383
                     //    $tabledata[]=array_merge($td,$tdi);
1384
-                        $tabledata[]=$td;
1384
+                        $tabledata[] = $td;
1385 1385
                 }
1386 1386
                 return(array_filter($tabledata));
1387 1387
         }
@@ -1454,13 +1454,13 @@  discard block
 block discarded – undo
1454 1454
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1455 1455
 			{
1456 1456
 				$i++;
1457
-				if($i > 3 && count($row) > 2) {
1457
+				if ($i > 3 && count($row) > 2) {
1458 1458
 					$data = array_values(array_filter($row));
1459 1459
 					$cntdata = count($data);
1460 1460
 					if ($cntdata > 10) {
1461 1461
 						$value = $data[9];
1462 1462
 						
1463
-						for ($i =10;$i < $cntdata;$i++) {
1463
+						for ($i = 10; $i < $cntdata; $i++) {
1464 1464
 							$value .= ' '.$data[$i];
1465 1465
 						}
1466 1466
 						$data[9] = $value;
@@ -1470,8 +1470,8 @@  discard block
 block discarded – undo
1470 1470
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1471 1471
 						try {
1472 1472
 							$sth = $Connection->db->prepare($query);
1473
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1474
-						} catch(PDOException $e) {
1473
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1474
+						} catch (PDOException $e) {
1475 1475
 							return "error : ".$e->getMessage();
1476 1476
 						}
1477 1477
 					}
@@ -1492,7 +1492,7 @@  discard block
 block discarded – undo
1492 1492
 			$Connection = new Connection();
1493 1493
 			$sth = $Connection->db->prepare($query);
1494 1494
                         $sth->execute();
1495
-                } catch(PDOException $e) {
1495
+                } catch (PDOException $e) {
1496 1496
                         return "error : ".$e->getMessage();
1497 1497
                 }
1498 1498
 
@@ -1504,12 +1504,12 @@  discard block
 block discarded – undo
1504 1504
 			if ($globalTransaction) $Connection->db->beginTransaction();
1505 1505
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1506 1506
 			{
1507
-				if(count($row) > 1) {
1507
+				if (count($row) > 1) {
1508 1508
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1509 1509
 					try {
1510 1510
 						$sth = $Connection->db->prepare($query);
1511
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1512
-					} catch(PDOException $e) {
1511
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1512
+					} catch (PDOException $e) {
1513 1513
 						return "error : ".$e->getMessage();
1514 1514
 					}
1515 1515
 				}
@@ -1529,21 +1529,21 @@  discard block
 block discarded – undo
1529 1529
 			try {
1530 1530
 				$sth = $Connection->db->prepare($query);
1531 1531
                     		$sth->execute();
1532
-	                } catch(PDOException $e) {
1532
+	                } catch (PDOException $e) {
1533 1533
 				return "error : ".$e->getMessage();
1534 1534
 	                }
1535 1535
 	        }
1536 1536
 
1537 1537
 
1538
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1538
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1539 1539
 		else {
1540
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1540
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1541 1541
 			$query = "CREATE EXTENSION postgis";
1542
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1542
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1543 1543
 			try {
1544 1544
 				$sth = $Connection->db->prepare($query);
1545 1545
 				$sth->execute();
1546
-			} catch(PDOException $e) {
1546
+			} catch (PDOException $e) {
1547 1547
 				return "error : ".$e->getMessage();
1548 1548
 			}
1549 1549
 		}
@@ -1556,7 +1556,7 @@  discard block
 block discarded – undo
1556 1556
 		include_once('class.create_db.php');
1557 1557
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1558 1558
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1559
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1559
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1560 1560
 		$error = '';
1561 1561
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1562 1562
 			if ($globalDebug) echo "Gunzip...";
@@ -1588,14 +1588,14 @@  discard block
 block discarded – undo
1588 1588
 			try {
1589 1589
 				$sth = $Connection->db->prepare($query);
1590 1590
             	        	$sth->execute();
1591
-	                } catch(PDOException $e) {
1591
+	                } catch (PDOException $e) {
1592 1592
     	                	echo "error : ".$e->getMessage();
1593 1593
 	                }
1594 1594
 		}
1595 1595
 		if ($globalDBdriver == 'mysql') {
1596
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1596
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1597 1597
 		} else {
1598
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1598
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1599 1599
 		}
1600 1600
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1601 1601
 		return $error;
@@ -1608,7 +1608,7 @@  discard block
 block discarded – undo
1608 1608
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1609 1609
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1610 1610
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1611
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1611
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
1612 1612
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1613 1613
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1614 1614
 		return $error;
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1629 1629
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1630 1630
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1631
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1631
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1632 1632
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1633 1633
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1634 1634
 		if ($error != '') {
@@ -1641,7 +1641,7 @@  discard block
 block discarded – undo
1641 1641
 		global $tmp_dir, $globalDebug;
1642 1642
 		$error = '';
1643 1643
 		if ($globalDebug) echo "Routes : Download...";
1644
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1644
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1645 1645
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1646 1646
 			if ($globalDebug) echo "Gunzip...";
1647 1647
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1657,7 +1657,7 @@  discard block
 block discarded – undo
1657 1657
 		global $tmp_dir, $globalDebug;
1658 1658
 		$error = '';
1659 1659
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1660
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1660
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1661 1661
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1662 1662
 			if ($globalDebug) echo "Gunzip...";
1663 1663
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1673,7 +1673,7 @@  discard block
 block discarded – undo
1673 1673
 		global $tmp_dir, $globalDebug;
1674 1674
 		$error = '';
1675 1675
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1676
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1676
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1677 1677
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1678 1678
 			if ($globalDebug) echo "Gunzip...";
1679 1679
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1701,7 +1701,7 @@  discard block
 block discarded – undo
1701 1701
 */
1702 1702
 		if ($globalDebug) echo "Modes : Download...";
1703 1703
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1704
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1704
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1705 1705
 
1706 1706
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1707 1707
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 	public static function update_ModeS_faa() {
1722 1722
 		global $tmp_dir, $globalDebug;
1723 1723
 		if ($globalDebug) echo "Modes FAA: Download...";
1724
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1724
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1725 1725
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1726 1726
 			if ($globalDebug) echo "Unzip...";
1727 1727
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
 	public static function update_ModeS_flarm() {
1738 1738
 		global $tmp_dir, $globalDebug;
1739 1739
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1740
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1740
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1741 1741
 		if (file_exists($tmp_dir.'data.fln')) {
1742 1742
 			if ($globalDebug) echo "Add to DB...";
1743 1743
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1751,7 +1751,7 @@  discard block
 block discarded – undo
1751 1751
 	public static function update_ModeS_ogn() {
1752 1752
 		global $tmp_dir, $globalDebug;
1753 1753
 		if ($globalDebug) echo "Modes OGN: Download...";
1754
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1754
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1755 1755
 		if (file_exists($tmp_dir.'ogn.csv')) {
1756 1756
 			if ($globalDebug) echo "Add to DB...";
1757 1757
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1766,201 +1766,201 @@  discard block
 block discarded – undo
1766 1766
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1767 1767
 		
1768 1768
 		if ($globalDebug) echo "Owner France: Download...";
1769
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1769
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1770 1770
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1771 1771
 			if ($globalDebug) echo "Add to DB...";
1772
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1772
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1773 1773
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1774 1774
 		if ($error != '') {
1775 1775
 			return $error;
1776 1776
 		} elseif ($globalDebug) echo "Done\n";
1777 1777
 		
1778 1778
 		if ($globalDebug) echo "Owner Ireland: Download...";
1779
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1779
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1780 1780
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1781 1781
 			if ($globalDebug) echo "Add to DB...";
1782
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1782
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1783 1783
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1784 1784
 		if ($error != '') {
1785 1785
 			return $error;
1786 1786
 		} elseif ($globalDebug) echo "Done\n";
1787 1787
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1788
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1788
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1789 1789
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1790 1790
 			if ($globalDebug) echo "Add to DB...";
1791
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1791
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1792 1792
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1793 1793
 		if ($error != '') {
1794 1794
 			return $error;
1795 1795
 		} elseif ($globalDebug) echo "Done\n";
1796 1796
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1797
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1797
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1798 1798
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1799 1799
 			if ($globalDebug) echo "Add to DB...";
1800
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1800
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1801 1801
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1802 1802
 		if ($error != '') {
1803 1803
 			return $error;
1804 1804
 		} elseif ($globalDebug) echo "Done\n";
1805 1805
 		if ($globalDebug) echo "Owner Australia: Download...";
1806
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1806
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1807 1807
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1808 1808
 			if ($globalDebug) echo "Add to DB...";
1809
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1809
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1810 1810
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1811 1811
 		if ($error != '') {
1812 1812
 			return $error;
1813 1813
 		} elseif ($globalDebug) echo "Done\n";
1814 1814
 		if ($globalDebug) echo "Owner Austria: Download...";
1815
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1815
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1816 1816
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1817 1817
 			if ($globalDebug) echo "Add to DB...";
1818
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1818
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1819 1819
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1820 1820
 		if ($error != '') {
1821 1821
 			return $error;
1822 1822
 		} elseif ($globalDebug) echo "Done\n";
1823 1823
 		if ($globalDebug) echo "Owner Chile: Download...";
1824
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1824
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1825 1825
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1826 1826
 			if ($globalDebug) echo "Add to DB...";
1827
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1827
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1828 1828
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1829 1829
 		if ($error != '') {
1830 1830
 			return $error;
1831 1831
 		} elseif ($globalDebug) echo "Done\n";
1832 1832
 		if ($globalDebug) echo "Owner Colombia: Download...";
1833
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1833
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1834 1834
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1835 1835
 			if ($globalDebug) echo "Add to DB...";
1836
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1836
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1837 1837
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1838 1838
 		if ($error != '') {
1839 1839
 			return $error;
1840 1840
 		} elseif ($globalDebug) echo "Done\n";
1841 1841
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1842
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1842
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1843 1843
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1844 1844
 			if ($globalDebug) echo "Add to DB...";
1845
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1845
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1846 1846
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1847 1847
 		if ($error != '') {
1848 1848
 			return $error;
1849 1849
 		} elseif ($globalDebug) echo "Done\n";
1850 1850
 		if ($globalDebug) echo "Owner Brazil: Download...";
1851
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1851
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1852 1852
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1853 1853
 			if ($globalDebug) echo "Add to DB...";
1854
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1854
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1855 1855
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1856 1856
 		if ($error != '') {
1857 1857
 			return $error;
1858 1858
 		} elseif ($globalDebug) echo "Done\n";
1859 1859
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1860
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1860
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1861 1861
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1862 1862
 			if ($globalDebug) echo "Add to DB...";
1863
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1863
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1864 1864
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1865 1865
 		if ($error != '') {
1866 1866
 			return $error;
1867 1867
 		} elseif ($globalDebug) echo "Done\n";
1868 1868
 		if ($globalDebug) echo "Owner Croatia: Download...";
1869
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1869
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1870 1870
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1871 1871
 			if ($globalDebug) echo "Add to DB...";
1872
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1872
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1873 1873
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1874 1874
 		if ($error != '') {
1875 1875
 			return $error;
1876 1876
 		} elseif ($globalDebug) echo "Done\n";
1877 1877
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1878
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1878
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1879 1879
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1880 1880
 			if ($globalDebug) echo "Add to DB...";
1881
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1881
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1882 1882
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1883 1883
 		if ($error != '') {
1884 1884
 			return $error;
1885 1885
 		} elseif ($globalDebug) echo "Done\n";
1886 1886
 		if ($globalDebug) echo "Owner Maldives: Download...";
1887
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1887
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1888 1888
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1889 1889
 			if ($globalDebug) echo "Add to DB...";
1890
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1890
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1891 1891
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1892 1892
 		if ($error != '') {
1893 1893
 			return $error;
1894 1894
 		} elseif ($globalDebug) echo "Done\n";
1895 1895
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1896
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1896
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1897 1897
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1898 1898
 			if ($globalDebug) echo "Add to DB...";
1899
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1899
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1900 1900
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1901 1901
 		if ($error != '') {
1902 1902
 			return $error;
1903 1903
 		} elseif ($globalDebug) echo "Done\n";
1904 1904
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1905
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1905
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1906 1906
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1907 1907
 			if ($globalDebug) echo "Add to DB...";
1908
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1908
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1909 1909
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1910 1910
 		if ($error != '') {
1911 1911
 			return $error;
1912 1912
 		} elseif ($globalDebug) echo "Done\n";
1913 1913
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1914
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1914
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1915 1915
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1916 1916
 			if ($globalDebug) echo "Add to DB...";
1917
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1917
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1918 1918
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1919 1919
 		if ($error != '') {
1920 1920
 			return $error;
1921 1921
 		} elseif ($globalDebug) echo "Done\n";
1922 1922
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1923
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1923
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1924 1924
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1925 1925
 			if ($globalDebug) echo "Add to DB...";
1926
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1926
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1927 1927
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1928 1928
 		if ($error != '') {
1929 1929
 			return $error;
1930 1930
 		} elseif ($globalDebug) echo "Done\n";
1931 1931
 		if ($globalDebug) echo "Owner Iceland: Download...";
1932
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1932
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1933 1933
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1934 1934
 			if ($globalDebug) echo "Add to DB...";
1935
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1935
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1936 1936
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1937 1937
 		if ($error != '') {
1938 1938
 			return $error;
1939 1939
 		} elseif ($globalDebug) echo "Done\n";
1940 1940
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
1941
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1941
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
1942 1942
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1943 1943
 			if ($globalDebug) echo "Add to DB...";
1944
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1944
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
1945 1945
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
1946 1946
 		if ($error != '') {
1947 1947
 			return $error;
1948 1948
 		} elseif ($globalDebug) echo "Done\n";
1949 1949
 		if ($globalMasterSource) {
1950 1950
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
1951
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1951
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
1952 1952
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1953 1953
 				if ($globalDebug) echo "Add to DB...";
1954
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1954
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
1955 1955
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
1956 1956
 			if ($error != '') {
1957 1957
 				return $error;
1958 1958
 			} elseif ($globalDebug) echo "Done\n";
1959 1959
 			if ($globalDebug) echo "ModeS Denmark: Download...";
1960
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1960
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
1961 1961
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1962 1962
 				if ($globalDebug) echo "Add to DB...";
1963
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1963
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
1964 1964
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
1965 1965
 			if ($error != '') {
1966 1966
 				return $error;
@@ -1973,7 +1973,7 @@  discard block
 block discarded – undo
1973 1973
 		global $tmp_dir, $globalDebug;
1974 1974
 		$error = '';
1975 1975
 		if ($globalDebug) echo "Translation : Download...";
1976
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1976
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1977 1977
 		if (file_exists($tmp_dir.'translation.zip')) {
1978 1978
 			if ($globalDebug) echo "Unzip...";
1979 1979
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1989,7 +1989,7 @@  discard block
 block discarded – undo
1989 1989
 	public static function update_translation_fam() {
1990 1990
 		global $tmp_dir, $globalDebug;
1991 1991
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1992
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1992
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1993 1993
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1994 1994
 			if ($globalDebug) echo "Gunzip...";
1995 1995
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -2004,7 +2004,7 @@  discard block
 block discarded – undo
2004 2004
 	public static function update_ModeS_fam() {
2005 2005
 		global $tmp_dir, $globalDebug;
2006 2006
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2007
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2007
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2008 2008
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
2009 2009
 			if ($globalDebug) echo "Gunzip...";
2010 2010
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -2020,9 +2020,9 @@  discard block
 block discarded – undo
2020 2020
 		global $tmp_dir, $globalDebug, $globalOwner;
2021 2021
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2022 2022
 		if ($globalOwner === TRUE) {
2023
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2023
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2024 2024
 		} else {
2025
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2025
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2026 2026
 		}
2027 2027
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2028 2028
 			if ($globalDebug) echo "Gunzip...";
@@ -2038,7 +2038,7 @@  discard block
 block discarded – undo
2038 2038
 	public static function update_routes_fam() {
2039 2039
 		global $tmp_dir, $globalDebug;
2040 2040
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2041
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2041
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2042 2042
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2043 2043
 			if ($globalDebug) echo "Gunzip...";
2044 2044
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -2052,13 +2052,13 @@  discard block
 block discarded – undo
2052 2052
 	}
2053 2053
 	public static function update_marine_identity_fam() {
2054 2054
 		global $tmp_dir, $globalDebug;
2055
-		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2055
+		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2056 2056
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2057
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2057
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2058 2058
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2059 2059
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2060 2060
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2061
-				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2061
+				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2062 2062
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2063 2063
 					if ($globalDebug) echo "Gunzip...";
2064 2064
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
 	public static function update_banned_fam() {
2079 2079
 		global $tmp_dir, $globalDebug;
2080 2080
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2081
-		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2081
+		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2082 2082
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2083 2083
 			//if ($globalDebug) echo "Gunzip...";
2084 2084
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2097,18 +2097,18 @@  discard block
 block discarded – undo
2097 2097
 		$error = '';
2098 2098
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2099 2099
 		if ($globalDBdriver == 'mysql') {
2100
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2100
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2101 2101
 		} else {
2102
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2102
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2103 2103
 		}
2104 2104
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2105
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2105
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2106 2106
 			$airspace_md5 = $airspace_md5_file[0];
2107 2107
 			if (!update_db::check_airspace_version($airspace_md5)) {
2108 2108
 				if ($globalDBdriver == 'mysql') {
2109
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2109
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2110 2110
 				} else {
2111
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2111
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2112 2112
 				}
2113 2113
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2114 2114
 					if ($globalDebug) echo "Gunzip...";
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
 						try {
2121 2121
 							$sth = $Connection->db->prepare($query);
2122 2122
     	    	    					$sth->execute();
2123
-			            		} catch(PDOException $e) {
2123
+			            		} catch (PDOException $e) {
2124 2124
 							return "error : ".$e->getMessage();
2125 2125
 		            			}
2126 2126
 		    			}
@@ -2139,15 +2139,15 @@  discard block
 block discarded – undo
2139 2139
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2140 2140
 		$error = '';
2141 2141
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2142
-		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2142
+		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2143 2143
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2144
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2144
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2145 2145
 			$geoid_md5 = $geoid_md5_file[0];
2146 2146
 			if (!update_db::check_geoid_version($geoid_md5)) {
2147
-				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2147
+				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2148 2148
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2149 2149
 					if ($globalDebug) echo "Gunzip...";
2150
-					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2150
+					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2151 2151
 					if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2152 2152
 						update_db::insert_geoid_version($geoid_md5);
2153 2153
 					}
@@ -2163,15 +2163,15 @@  discard block
 block discarded – undo
2163 2163
 	public static function update_tle() {
2164 2164
 		global $tmp_dir, $globalDebug;
2165 2165
 		if ($globalDebug) echo "Download TLE : Download...";
2166
-		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2167
-		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2168
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2166
+		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt',
2167
+		'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt',
2168
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
2169 2169
 		foreach ($alltle as $filename) {
2170 2170
 			if ($globalDebug) echo "downloading ".$filename.'...';
2171
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2171
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2172 2172
 			if (file_exists($tmp_dir.$filename)) {
2173 2173
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2174
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2174
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2175 2175
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2176 2176
 			if ($error != '') {
2177 2177
 				echo $error."\n";
@@ -2184,32 +2184,32 @@  discard block
 block discarded – undo
2184 2184
 		global $tmp_dir, $globalDebug;
2185 2185
 		$error = '';
2186 2186
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2187
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2187
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2188 2188
 		if (file_exists($tmp_dir.'models.md5sum')) {
2189 2189
 			if ($globalDebug) echo "Check files...\n";
2190 2190
 			$newmodelsdb = array();
2191
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2192
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2191
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2192
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2193 2193
 					$model = trim($row[2]);
2194 2194
 					$newmodelsdb[$model] = trim($row[0]);
2195 2195
 				}
2196 2196
 			}
2197 2197
 			$modelsdb = array();
2198 2198
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2199
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2200
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2199
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2200
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2201 2201
 						$model = trim($row[2]);
2202 2202
 						$modelsdb[$model] = trim($row[0]);
2203 2203
 					}
2204 2204
 				}
2205 2205
 			}
2206
-			$diff = array_diff($newmodelsdb,$modelsdb);
2206
+			$diff = array_diff($newmodelsdb, $modelsdb);
2207 2207
 			foreach ($diff as $key => $value) {
2208 2208
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2209
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2209
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2210 2210
 				
2211 2211
 			}
2212
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2212
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2213 2213
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2214 2214
 		if ($error != '') {
2215 2215
 			return $error;
@@ -2221,32 +2221,32 @@  discard block
 block discarded – undo
2221 2221
 		global $tmp_dir, $globalDebug;
2222 2222
 		$error = '';
2223 2223
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2224
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2224
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2225 2225
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2226 2226
 			if ($globalDebug) echo "Check files...\n";
2227 2227
 			$newmodelsdb = array();
2228
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2229
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2228
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2229
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2230 2230
 					$model = trim($row[2]);
2231 2231
 					$newmodelsdb[$model] = trim($row[0]);
2232 2232
 				}
2233 2233
 			}
2234 2234
 			$modelsdb = array();
2235 2235
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2236
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2237
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2236
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2237
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2238 2238
 						$model = trim($row[2]);
2239 2239
 						$modelsdb[$model] = trim($row[0]);
2240 2240
 					}
2241 2241
 				}
2242 2242
 			}
2243
-			$diff = array_diff($newmodelsdb,$modelsdb);
2243
+			$diff = array_diff($newmodelsdb, $modelsdb);
2244 2244
 			foreach ($diff as $key => $value) {
2245 2245
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2246
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2246
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2247 2247
 				
2248 2248
 			}
2249
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2249
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2250 2250
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2251 2251
 		if ($error != '') {
2252 2252
 			return $error;
@@ -2258,32 +2258,32 @@  discard block
 block discarded – undo
2258 2258
 		global $tmp_dir, $globalDebug;
2259 2259
 		$error = '';
2260 2260
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2261
-		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2261
+		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2262 2262
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2263 2263
 			if ($globalDebug) echo "Check files...\n";
2264 2264
 			$newmodelsdb = array();
2265
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2266
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2265
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2266
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2267 2267
 					$model = trim($row[2]);
2268 2268
 					$newmodelsdb[$model] = trim($row[0]);
2269 2269
 				}
2270 2270
 			}
2271 2271
 			$modelsdb = array();
2272 2272
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2273
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2274
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2273
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2274
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2275 2275
 						$model = trim($row[2]);
2276 2276
 						$modelsdb[$model] = trim($row[0]);
2277 2277
 					}
2278 2278
 				}
2279 2279
 			}
2280
-			$diff = array_diff($newmodelsdb,$modelsdb);
2280
+			$diff = array_diff($newmodelsdb, $modelsdb);
2281 2281
 			foreach ($diff as $key => $value) {
2282 2282
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2283
-				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2283
+				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2284 2284
 				
2285 2285
 			}
2286
-			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2286
+			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2287 2287
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2288 2288
 		if ($error != '') {
2289 2289
 			return $error;
@@ -2306,8 +2306,8 @@  discard block
 block discarded – undo
2306 2306
 		*/
2307 2307
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2308 2308
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2309
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2310
-		    $result = fread($fh,100000000);
2309
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2310
+		    $result = fread($fh, 100000000);
2311 2311
 		    //echo $result;
2312 2312
 		    //var_dump(str_get_html($result));
2313 2313
 		    //print_r(self::table2array($result));
@@ -2325,23 +2325,23 @@  discard block
 block discarded – undo
2325 2325
 			$Connection = new Connection();
2326 2326
 			$sth = $Connection->db->prepare($query);
2327 2327
                         $sth->execute();
2328
-                } catch(PDOException $e) {
2328
+                } catch (PDOException $e) {
2329 2329
                         return "error : ".$e->getMessage();
2330 2330
                 }
2331 2331
 
2332 2332
 		$error = '';
2333 2333
 		if ($globalDebug) echo "Notam : Download...";
2334
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2334
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2335 2335
 		if (file_exists($tmp_dir.'notam.rss')) {
2336
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2336
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2337 2337
 			foreach ($notams['channel']['item'] as $notam) {
2338
-				$title = explode(':',$notam['title']);
2338
+				$title = explode(':', $notam['title']);
2339 2339
 				$data['ref'] = trim($title[0]);
2340 2340
 				unset($title[0]);
2341
-				$data['title'] = trim(implode(':',$title));
2342
-				$description = strip_tags($notam['description'],'<pre>');
2343
-				preg_match(':^(.*?)<pre>:',$description,$match);
2344
-				$q = explode('/',$match[1]);
2341
+				$data['title'] = trim(implode(':', $title));
2342
+				$description = strip_tags($notam['description'], '<pre>');
2343
+				preg_match(':^(.*?)<pre>:', $description, $match);
2344
+				$q = explode('/', $match[1]);
2345 2345
 				$data['fir'] = $q[0];
2346 2346
 				$data['code'] = $q[1];
2347 2347
 				$ifrvfr = $q[2];
@@ -2357,30 +2357,30 @@  discard block
 block discarded – undo
2357 2357
 				$data['lower_limit'] = $q[5];
2358 2358
 				$data['upper_limit'] = $q[6];
2359 2359
 				$latlonrad = $q[7];
2360
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2361
-				$latitude = $Common->convertDec($las,'latitude');
2362
-				$longitude = $Common->convertDec($lns,'longitude');
2360
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2361
+				$latitude = $Common->convertDec($las, 'latitude');
2362
+				$longitude = $Common->convertDec($lns, 'longitude');
2363 2363
 				if ($lac == 'S') $latitude = '-'.$latitude;
2364 2364
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2365 2365
 				$data['center_latitude'] = $latitude;
2366 2366
 				$data['center_longitude'] = $longitude;
2367 2367
 				$data['radius'] = intval($radius);
2368 2368
 				
2369
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2369
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2370 2370
 				$data['text'] = $match[1];
2371
-				preg_match(':</pre>(.*?)$:',$description,$match);
2371
+				preg_match(':</pre>(.*?)$:', $description, $match);
2372 2372
 				$fromto = $match[1];
2373
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2373
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2374 2374
 				$fromall = trim($match[1]);
2375
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2375
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2376 2376
 				$from = trim($match[1]);
2377
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2378
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2377
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2378
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2379 2379
 				$toall = trim($match[1]);
2380
-				if (!preg_match(':Permanent:',$toall)) {
2381
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2380
+				if (!preg_match(':Permanent:', $toall)) {
2381
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2382 2382
 					$to = trim($match[1]);
2383
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2383
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2384 2384
 					$data['permanent'] = 0;
2385 2385
 				} else {
2386 2386
 				    $data['date_end'] = NULL;
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
 				}
2389 2389
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2390 2390
 				$NOTAM = new NOTAM();
2391
-				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2391
+				$NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
2392 2392
 				unset($data);
2393 2393
 			} 
2394 2394
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2411,16 +2411,16 @@  discard block
 block discarded – undo
2411 2411
 				$Connection = new Connection();
2412 2412
 				$sth = $Connection->db->prepare($query);
2413 2413
 				$sth->execute();
2414
-			} catch(PDOException $e) {
2414
+			} catch (PDOException $e) {
2415 2415
 				return "error : ".$e->getMessage();
2416 2416
 			}
2417 2417
 		}
2418 2418
 		$Common = new Common();
2419 2419
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2420
-		$airspace_json = json_decode($airspace_lst,true);
2420
+		$airspace_json = json_decode($airspace_lst, true);
2421 2421
 		foreach ($airspace_json['records'] as $airspace) {
2422 2422
 			if ($globalDebug) echo $airspace['name']."...\n";
2423
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2423
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2424 2424
 			if (file_exists($tmp_dir.$airspace['name'])) {
2425 2425
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2426 2426
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2442,7 +2442,7 @@  discard block
 block discarded – undo
2442 2442
 				$Connection = new Connection();
2443 2443
 				$sth = $Connection->db->prepare($query);
2444 2444
 				$sth->execute(array(':new' => $new, ':old' => $old));
2445
-			} catch(PDOException $e) {
2445
+			} catch (PDOException $e) {
2446 2446
 				return "error : ".$e->getMessage();
2447 2447
 			}
2448 2448
 		}
@@ -2459,7 +2459,7 @@  discard block
 block discarded – undo
2459 2459
 			$Connection = new Connection();
2460 2460
 			$sth = $Connection->db->prepare($query);
2461 2461
                         $sth->execute();
2462
-                } catch(PDOException $e) {
2462
+                } catch (PDOException $e) {
2463 2463
                         return "error : ".$e->getMessage();
2464 2464
                 }
2465 2465
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2474,7 +2474,7 @@  discard block
 block discarded – undo
2474 2474
 			$Connection = new Connection();
2475 2475
 			$sth = $Connection->db->prepare($query);
2476 2476
                         $sth->execute();
2477
-                } catch(PDOException $e) {
2477
+                } catch (PDOException $e) {
2478 2478
                         return "error : ".$e->getMessage();
2479 2479
                 }
2480 2480
 	}
@@ -2485,7 +2485,7 @@  discard block
 block discarded – undo
2485 2485
 			$Connection = new Connection();
2486 2486
 			$sth = $Connection->db->prepare($query);
2487 2487
                         $sth->execute(array(':version' => $version));
2488
-                } catch(PDOException $e) {
2488
+                } catch (PDOException $e) {
2489 2489
                         return "error : ".$e->getMessage();
2490 2490
                 }
2491 2491
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2499,7 +2499,7 @@  discard block
 block discarded – undo
2499 2499
 			$Connection = new Connection();
2500 2500
 			$sth = $Connection->db->prepare($query);
2501 2501
                         $sth->execute(array(':version' => $version));
2502
-                } catch(PDOException $e) {
2502
+                } catch (PDOException $e) {
2503 2503
                         return "error : ".$e->getMessage();
2504 2504
                 }
2505 2505
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2513,7 +2513,7 @@  discard block
 block discarded – undo
2513 2513
 			$Connection = new Connection();
2514 2514
 			$sth = $Connection->db->prepare($query);
2515 2515
                         $sth->execute(array(':version' => $version));
2516
-                } catch(PDOException $e) {
2516
+                } catch (PDOException $e) {
2517 2517
                         return "error : ".$e->getMessage();
2518 2518
                 }
2519 2519
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2529,7 +2529,7 @@  discard block
 block discarded – undo
2529 2529
 			$Connection = new Connection();
2530 2530
 			$sth = $Connection->db->prepare($query);
2531 2531
 			$sth->execute(array(':version' => $version));
2532
-		} catch(PDOException $e) {
2532
+		} catch (PDOException $e) {
2533 2533
 			return "error : ".$e->getMessage();
2534 2534
 		}
2535 2535
 	}
@@ -2541,7 +2541,7 @@  discard block
 block discarded – undo
2541 2541
 			$Connection = new Connection();
2542 2542
 			$sth = $Connection->db->prepare($query);
2543 2543
                         $sth->execute(array(':version' => $version));
2544
-                } catch(PDOException $e) {
2544
+                } catch (PDOException $e) {
2545 2545
                         return "error : ".$e->getMessage();
2546 2546
                 }
2547 2547
 	}
@@ -2553,7 +2553,7 @@  discard block
 block discarded – undo
2553 2553
 			$Connection = new Connection();
2554 2554
 			$sth = $Connection->db->prepare($query);
2555 2555
                         $sth->execute(array(':version' => $version));
2556
-                } catch(PDOException $e) {
2556
+                } catch (PDOException $e) {
2557 2557
                         return "error : ".$e->getMessage();
2558 2558
                 }
2559 2559
 	}
@@ -2569,7 +2569,7 @@  discard block
 block discarded – undo
2569 2569
 			$Connection = new Connection();
2570 2570
 			$sth = $Connection->db->prepare($query);
2571 2571
                         $sth->execute();
2572
-                } catch(PDOException $e) {
2572
+                } catch (PDOException $e) {
2573 2573
                         return "error : ".$e->getMessage();
2574 2574
                 }
2575 2575
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2584,7 +2584,7 @@  discard block
 block discarded – undo
2584 2584
 			$Connection = new Connection();
2585 2585
 			$sth = $Connection->db->prepare($query);
2586 2586
                         $sth->execute();
2587
-                } catch(PDOException $e) {
2587
+                } catch (PDOException $e) {
2588 2588
                         return "error : ".$e->getMessage();
2589 2589
                 }
2590 2590
 	}
@@ -2600,7 +2600,7 @@  discard block
 block discarded – undo
2600 2600
 			$Connection = new Connection();
2601 2601
 			$sth = $Connection->db->prepare($query);
2602 2602
                         $sth->execute();
2603
-                } catch(PDOException $e) {
2603
+                } catch (PDOException $e) {
2604 2604
                         return "error : ".$e->getMessage();
2605 2605
                 }
2606 2606
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2615,7 +2615,7 @@  discard block
 block discarded – undo
2615 2615
 			$Connection = new Connection();
2616 2616
 			$sth = $Connection->db->prepare($query);
2617 2617
                         $sth->execute();
2618
-                } catch(PDOException $e) {
2618
+                } catch (PDOException $e) {
2619 2619
                         return "error : ".$e->getMessage();
2620 2620
                 }
2621 2621
 	}
@@ -2631,7 +2631,7 @@  discard block
 block discarded – undo
2631 2631
 			$Connection = new Connection();
2632 2632
 			$sth = $Connection->db->prepare($query);
2633 2633
                         $sth->execute();
2634
-                } catch(PDOException $e) {
2634
+                } catch (PDOException $e) {
2635 2635
                         return "error : ".$e->getMessage();
2636 2636
                 }
2637 2637
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2646,7 +2646,7 @@  discard block
 block discarded – undo
2646 2646
 			$Connection = new Connection();
2647 2647
 			$sth = $Connection->db->prepare($query);
2648 2648
                         $sth->execute();
2649
-                } catch(PDOException $e) {
2649
+                } catch (PDOException $e) {
2650 2650
                         return "error : ".$e->getMessage();
2651 2651
                 }
2652 2652
 	}
@@ -2662,7 +2662,7 @@  discard block
 block discarded – undo
2662 2662
 			$Connection = new Connection();
2663 2663
 			$sth = $Connection->db->prepare($query);
2664 2664
                         $sth->execute();
2665
-                } catch(PDOException $e) {
2665
+                } catch (PDOException $e) {
2666 2666
                         return "error : ".$e->getMessage();
2667 2667
                 }
2668 2668
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2677,7 +2677,7 @@  discard block
 block discarded – undo
2677 2677
 			$Connection = new Connection();
2678 2678
 			$sth = $Connection->db->prepare($query);
2679 2679
                         $sth->execute();
2680
-                } catch(PDOException $e) {
2680
+                } catch (PDOException $e) {
2681 2681
                         return "error : ".$e->getMessage();
2682 2682
                 }
2683 2683
 	}
@@ -2692,7 +2692,7 @@  discard block
 block discarded – undo
2692 2692
 			$Connection = new Connection();
2693 2693
 			$sth = $Connection->db->prepare($query);
2694 2694
                         $sth->execute();
2695
-                } catch(PDOException $e) {
2695
+                } catch (PDOException $e) {
2696 2696
                         return "error : ".$e->getMessage();
2697 2697
                 }
2698 2698
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2707,7 +2707,7 @@  discard block
 block discarded – undo
2707 2707
 			$Connection = new Connection();
2708 2708
 			$sth = $Connection->db->prepare($query);
2709 2709
                         $sth->execute();
2710
-                } catch(PDOException $e) {
2710
+                } catch (PDOException $e) {
2711 2711
                         return "error : ".$e->getMessage();
2712 2712
                 }
2713 2713
 	}
@@ -2722,7 +2722,7 @@  discard block
 block discarded – undo
2722 2722
 			$Connection = new Connection();
2723 2723
 			$sth = $Connection->db->prepare($query);
2724 2724
                         $sth->execute();
2725
-                } catch(PDOException $e) {
2725
+                } catch (PDOException $e) {
2726 2726
                         return "error : ".$e->getMessage();
2727 2727
                 }
2728 2728
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2737,7 +2737,7 @@  discard block
 block discarded – undo
2737 2737
 			$Connection = new Connection();
2738 2738
 			$sth = $Connection->db->prepare($query);
2739 2739
                         $sth->execute();
2740
-                } catch(PDOException $e) {
2740
+                } catch (PDOException $e) {
2741 2741
                         return "error : ".$e->getMessage();
2742 2742
                 }
2743 2743
 	}
@@ -2752,7 +2752,7 @@  discard block
 block discarded – undo
2752 2752
 			$Connection = new Connection();
2753 2753
 			$sth = $Connection->db->prepare($query);
2754 2754
                         $sth->execute();
2755
-                } catch(PDOException $e) {
2755
+                } catch (PDOException $e) {
2756 2756
                         return "error : ".$e->getMessage();
2757 2757
                 }
2758 2758
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2767,7 +2767,7 @@  discard block
 block discarded – undo
2767 2767
 			$Connection = new Connection();
2768 2768
 			$sth = $Connection->db->prepare($query);
2769 2769
                         $sth->execute();
2770
-                } catch(PDOException $e) {
2770
+                } catch (PDOException $e) {
2771 2771
                         return "error : ".$e->getMessage();
2772 2772
                 }
2773 2773
 	}
@@ -2782,7 +2782,7 @@  discard block
 block discarded – undo
2782 2782
 			$Connection = new Connection();
2783 2783
 			$sth = $Connection->db->prepare($query);
2784 2784
                         $sth->execute();
2785
-                } catch(PDOException $e) {
2785
+                } catch (PDOException $e) {
2786 2786
                         return "error : ".$e->getMessage();
2787 2787
                 }
2788 2788
 	}
@@ -2797,7 +2797,7 @@  discard block
 block discarded – undo
2797 2797
 			$Connection = new Connection();
2798 2798
 			$sth = $Connection->db->prepare($query);
2799 2799
                         $sth->execute();
2800
-                } catch(PDOException $e) {
2800
+                } catch (PDOException $e) {
2801 2801
                         return "error : ".$e->getMessage();
2802 2802
                 }
2803 2803
 	}
Please login to merge, or discard this patch.
Braces   +953 added lines, -330 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19 19
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
20
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
20
+		if ($referer != '') {
21
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
22
+		}
21 23
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
22 24
 		curl_setopt($ch, CURLOPT_FILE, $fp);
23 25
 		curl_exec($ch);
@@ -28,12 +30,16 @@  discard block
 block discarded – undo
28 30
 	public static function gunzip($in_file,$out_file_name = '') {
29 31
 		//echo $in_file.' -> '.$out_file_name."\n";
30 32
 		$buffer_size = 4096; // read 4kb at a time
31
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
33
+		if ($out_file_name == '') {
34
+			$out_file_name = str_replace('.gz', '', $in_file);
35
+		}
32 36
 		if ($in_file != '' && file_exists($in_file)) {
33 37
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
36
-			else {
38
+			if (function_exists('gzopen')) {
39
+				$file = gzopen($in_file,'rb');
40
+			} elseif (function_exists('gzopen64')) {
41
+				$file = gzopen64($in_file,'rb');
42
+			} else {
37 43
 				echo 'gzopen not available';
38 44
 				die;
39 45
 			}
@@ -54,8 +60,12 @@  discard block
 block discarded – undo
54 60
 			if ($res === TRUE) {
55 61
 				$zip->extractTo($path);
56 62
 				$zip->close();
57
-			} else return false;
58
-		} else return false;
63
+			} else {
64
+				return false;
65
+			}
66
+		} else {
67
+			return false;
68
+		}
59 69
 	}
60 70
 	
61 71
 	public static function connect_sqlite($database) {
@@ -70,7 +80,9 @@  discard block
 block discarded – undo
70 80
 	public static function retrieve_route_sqlite_to_dest($database_file) {
71 81
 		global $globalDebug, $globalTransaction;
72 82
 		//$query = 'TRUNCATE TABLE routes';
73
-		if ($globalDebug) echo " - Delete previous routes from DB -";
83
+		if ($globalDebug) {
84
+			echo " - Delete previous routes from DB -";
85
+		}
74 86
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
75 87
 		$Connection = new Connection();
76 88
 		try {
@@ -81,7 +93,9 @@  discard block
 block discarded – undo
81 93
                         return "error : ".$e->getMessage();
82 94
                 }
83 95
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
96
+    		if ($globalDebug) {
97
+    			echo " - Add routes to DB -";
98
+    		}
85 99
     		update_db::connect_sqlite($database_file);
86 100
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
87 101
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -96,15 +110,21 @@  discard block
 block discarded – undo
96 110
 		$Connection = new Connection();
97 111
 		$sth_dest = $Connection->db->prepare($query_dest);
98 112
 		try {
99
-			if ($globalTransaction) $Connection->db->beginTransaction();
113
+			if ($globalTransaction) {
114
+				$Connection->db->beginTransaction();
115
+			}
100 116
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 117
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
103 119
 				$sth_dest->execute($query_dest_values);
104 120
             		}
105
-			if ($globalTransaction) $Connection->db->commit();
121
+			if ($globalTransaction) {
122
+				$Connection->db->commit();
123
+			}
106 124
 		} catch(PDOException $e) {
107
-			if ($globalTransaction) $Connection->db->rollBack(); 
125
+			if ($globalTransaction) {
126
+				$Connection->db->rollBack();
127
+			}
108 128
 			return "error : ".$e->getMessage();
109 129
 		}
110 130
                 return '';
@@ -112,7 +132,9 @@  discard block
 block discarded – undo
112 132
 	public static function retrieve_route_oneworld($database_file) {
113 133
 		global $globalDebug, $globalTransaction;
114 134
 		//$query = 'TRUNCATE TABLE routes';
115
-		if ($globalDebug) echo " - Delete previous routes from DB -";
135
+		if ($globalDebug) {
136
+			echo " - Delete previous routes from DB -";
137
+		}
116 138
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
117 139
 		$Connection = new Connection();
118 140
 		try {
@@ -123,14 +145,18 @@  discard block
 block discarded – undo
123 145
                         return "error : ".$e->getMessage();
124 146
                 }
125 147
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
148
+    		if ($globalDebug) {
149
+    			echo " - Add routes to DB -";
150
+    		}
127 151
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 152
 		$Spotter = new Spotter();
129 153
 		if ($fh = fopen($database_file,"r")) {
130 154
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 155
 			$Connection = new Connection();
132 156
 			$sth_dest = $Connection->db->prepare($query_dest);
133
-			if ($globalTransaction) $Connection->db->beginTransaction();
157
+			if ($globalTransaction) {
158
+				$Connection->db->beginTransaction();
159
+			}
134 160
 			while (!feof($fh)) {
135 161
 				$line = fgetcsv($fh,9999,',');
136 162
 				if ($line[0] != '') {
@@ -139,13 +165,17 @@  discard block
 block discarded – undo
139 165
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
140 166
 							$sth_dest->execute($query_dest_values);
141 167
 						} catch(PDOException $e) {
142
-							if ($globalTransaction) $Connection->db->rollBack(); 
168
+							if ($globalTransaction) {
169
+								$Connection->db->rollBack();
170
+							}
143 171
 							return "error : ".$e->getMessage();
144 172
 						}
145 173
 					}
146 174
 				}
147 175
 			}
148
-			if ($globalTransaction) $Connection->db->commit();
176
+			if ($globalTransaction) {
177
+				$Connection->db->commit();
178
+			}
149 179
 		}
150 180
                 return '';
151 181
 	}
@@ -153,7 +183,9 @@  discard block
 block discarded – undo
153 183
 	public static function retrieve_route_skyteam($database_file) {
154 184
 		global $globalDebug, $globalTransaction;
155 185
 		//$query = 'TRUNCATE TABLE routes';
156
-		if ($globalDebug) echo " - Delete previous routes from DB -";
186
+		if ($globalDebug) {
187
+			echo " - Delete previous routes from DB -";
188
+		}
157 189
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
158 190
 		$Connection = new Connection();
159 191
 		try {
@@ -164,7 +196,9 @@  discard block
 block discarded – undo
164 196
                         return "error : ".$e->getMessage();
165 197
                 }
166 198
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
199
+    		if ($globalDebug) {
200
+    			echo " - Add routes to DB -";
201
+    		}
168 202
 
169 203
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 204
 		$Spotter = new Spotter();
@@ -173,7 +207,9 @@  discard block
 block discarded – undo
173 207
 			$Connection = new Connection();
174 208
 			$sth_dest = $Connection->db->prepare($query_dest);
175 209
 			try {
176
-				if ($globalTransaction) $Connection->db->beginTransaction();
210
+				if ($globalTransaction) {
211
+					$Connection->db->beginTransaction();
212
+				}
177 213
 				while (!feof($fh)) {
178 214
 					$line = fgetcsv($fh,9999,',');
179 215
 					if ($line[0] != '') {
@@ -184,9 +220,13 @@  discard block
 block discarded – undo
184 220
 						}
185 221
 					}
186 222
 				}
187
-				if ($globalTransaction) $Connection->db->commit();
223
+				if ($globalTransaction) {
224
+					$Connection->db->commit();
225
+				}
188 226
 			} catch(PDOException $e) {
189
-				if ($globalTransaction) $Connection->db->rollBack(); 
227
+				if ($globalTransaction) {
228
+					$Connection->db->rollBack();
229
+				}
190 230
 				return "error : ".$e->getMessage();
191 231
 			}
192 232
 		}
@@ -229,11 +269,16 @@  discard block
 block discarded – undo
229 269
 		$sth_dest = $Connection->db->prepare($query_dest);
230 270
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 271
 		try {
232
-			if ($globalTransaction) $Connection->db->beginTransaction();
272
+			if ($globalTransaction) {
273
+				$Connection->db->beginTransaction();
274
+			}
233 275
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 276
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235
-				if ($values['UserString4'] == 'M') $type = 'military';
236
-				else $type = null;
277
+				if ($values['UserString4'] == 'M') {
278
+					$type = 'military';
279
+				} else {
280
+					$type = null;
281
+				}
237 282
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 283
 				$sth_dest->execute($query_dest_values);
239 284
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -241,7 +286,9 @@  discard block
 block discarded – undo
241 286
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 287
 				}
243 288
             		}
244
-			if ($globalTransaction) $Connection->db->commit();
289
+			if ($globalTransaction) {
290
+				$Connection->db->commit();
291
+			}
245 292
 		} catch(PDOException $e) {
246 293
 			return "error : ".$e->getMessage();
247 294
 		}
@@ -278,7 +325,9 @@  discard block
 block discarded – undo
278 325
 			$Connection = new Connection();
279 326
 			$sth_dest = $Connection->db->prepare($query_dest);
280 327
 			try {
281
-				if ($globalTransaction) $Connection->db->beginTransaction();
328
+				if ($globalTransaction) {
329
+					$Connection->db->beginTransaction();
330
+				}
282 331
             			while (!feof($fh)) {
283 332
             				$values = array();
284 333
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -289,7 +338,9 @@  discard block
 block discarded – undo
289 338
             				// Check if we can find ICAO, else set it to GLID
290 339
             				$aircraft_name_split = explode(' ',$aircraft_name);
291 340
             				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
341
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
342
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
343
+            				}
293 344
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294 345
             				$sth_search = $Connection->db->prepare($query_search);
295 346
 					try {
@@ -302,7 +353,9 @@  discard block
 block discarded – undo
302 353
 					} catch(PDOException $e) {
303 354
 						return "error : ".$e->getMessage();
304 355
 					}
305
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
356
+					if (!isset($values['ICAOTypeCode'])) {
357
+						$values['ICAOTypeCode'] = 'GLID';
358
+					}
306 359
 					// Add data to db
307 360
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 361
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -311,7 +364,9 @@  discard block
 block discarded – undo
311 364
 						$sth_dest->execute($query_dest_values);
312 365
 					}
313 366
 				}
314
-				if ($globalTransaction) $Connection->db->commit();
367
+				if ($globalTransaction) {
368
+					$Connection->db->commit();
369
+				}
315 370
 			} catch(PDOException $e) {
316 371
 				return "error : ".$e->getMessage();
317 372
 			}
@@ -347,7 +402,9 @@  discard block
 block discarded – undo
347 402
 			$Connection = new Connection();
348 403
 			$sth_dest = $Connection->db->prepare($query_dest);
349 404
 			try {
350
-				if ($globalTransaction) $Connection->db->beginTransaction();
405
+				if ($globalTransaction) {
406
+					$Connection->db->beginTransaction();
407
+				}
351 408
 				$tmp = fgetcsv($fh,9999,',',"'");
352 409
             			while (!feof($fh)) {
353 410
             				$line = fgetcsv($fh,9999,',',"'");
@@ -361,13 +418,17 @@  discard block
 block discarded – undo
361 418
             				// Check if we can find ICAO, else set it to GLID
362 419
             				$aircraft_name_split = explode(' ',$aircraft_name);
363 420
             				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
422
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
423
+            				}
365 424
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366 425
             				$sth_search = $Connection->db->prepare($query_search);
367 426
 					try {
368 427
                                     		$sth_search->execute();
369 428
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
429
+	            				if (isset($result['icao']) && $result['icao'] != '') {
430
+	            					$values['ICAOTypeCode'] = $result['icao'];
431
+	            				}
371 432
 					} catch(PDOException $e) {
372 433
 						return "error : ".$e->getMessage();
373 434
 					}
@@ -380,7 +441,9 @@  discard block
 block discarded – undo
380 441
 						$sth_dest->execute($query_dest_values);
381 442
 					}
382 443
 				}
383
-				if ($globalTransaction) $Connection->db->commit();
444
+				if ($globalTransaction) {
445
+					$Connection->db->commit();
446
+				}
384 447
 			} catch(PDOException $e) {
385 448
 				return "error : ".$e->getMessage();
386 449
 			}
@@ -419,7 +482,9 @@  discard block
 block discarded – undo
419 482
 			$sth_dest = $Connection->db->prepare($query_dest);
420 483
 			$sth_modes = $Connection->db->prepare($query_modes);
421 484
 			try {
422
-				if ($globalTransaction) $Connection->db->beginTransaction();
485
+				if ($globalTransaction) {
486
+					$Connection->db->beginTransaction();
487
+				}
423 488
 				$tmp = fgetcsv($fh,9999,',','"');
424 489
             			while (!feof($fh)) {
425 490
             				$line = fgetcsv($fh,9999,',','"');
@@ -429,16 +494,22 @@  discard block
 block discarded – undo
429 494
             				    $values['registration'] = $line[0];
430 495
             				    $values['base'] = $line[4];
431 496
             				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+            				    if ($line[6] == '') {
498
+            				    	$values['date_first_reg'] = null;
499
+            				    } else {
500
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
501
+					    }
434 502
 					    $values['cancel'] = $line[7];
435 503
 					} elseif ($country == 'EI') {
436 504
 					    // TODO : add modeS & reg to aircraft_modes
437 505
             				    $values['registration'] = $line[0];
438 506
             				    $values['base'] = $line[3];
439 507
             				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
508
+            				    if ($line[1] == '') {
509
+            				    	$values['date_first_reg'] = null;
510
+            				    } else {
511
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
512
+					    }
442 513
 					    $values['cancel'] = '';
443 514
 					    $values['modes'] = $line[7];
444 515
 					    $values['icao'] = $line[8];
@@ -457,16 +528,22 @@  discard block
 block discarded – undo
457 528
             				    $values['registration'] = $line[3];
458 529
             				    $values['base'] = null;
459 530
             				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
531
+            				    if ($line[18] == '') {
532
+            				    	$values['date_first_reg'] = null;
533
+            				    } else {
534
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
535
+					    }
462 536
 					    $values['cancel'] = '';
463 537
 					} elseif ($country == 'VH') {
464 538
 					    // TODO : add modeS & reg to aircraft_modes
465 539
             				    $values['registration'] = $line[0];
466 540
             				    $values['base'] = null;
467 541
             				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
542
+            				    if ($line[28] == '') {
543
+            				    	$values['date_first_reg'] = null;
544
+            				    } else {
545
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
546
+					    }
470 547
 
471 548
 					    $values['cancel'] = $line[39];
472 549
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -485,29 +562,41 @@  discard block
 block discarded – undo
485 562
             				    $values['registration'] = $line[0];
486 563
             				    $values['base'] = null;
487 564
             				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
565
+            				    if ($line[7] == '') {
566
+            				    	$values['date_first_reg'] = null;
567
+            				    } else {
568
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
569
+					    }
490 570
 					    $values['cancel'] = '';
491 571
 					} elseif ($country == 'PP') {
492 572
             				    $values['registration'] = $line[0];
493 573
             				    $values['base'] = null;
494 574
             				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
575
+            				    if ($line[6] == '') {
576
+            				    	$values['date_first_reg'] = null;
577
+            				    } else {
578
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
579
+					    }
497 580
 					    $values['cancel'] = $line[7];
498 581
 					} elseif ($country == 'E7') {
499 582
             				    $values['registration'] = $line[0];
500 583
             				    $values['base'] = null;
501 584
             				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
585
+            				    if ($line[5] == '') {
586
+            				    	$values['date_first_reg'] = null;
587
+            				    } else {
588
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
589
+					    }
504 590
 					    $values['cancel'] = '';
505 591
 					} elseif ($country == '8Q') {
506 592
             				    $values['registration'] = $line[0];
507 593
             				    $values['base'] = null;
508 594
             				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
595
+            				    if ($line[7] == '') {
596
+            				    	$values['date_first_reg'] = null;
597
+            				    } else {
598
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
599
+					    }
511 600
 					    $values['cancel'] = '';
512 601
 					} elseif ($country == 'ZK') {
513 602
             				    $values['registration'] = $line[0];
@@ -552,7 +641,9 @@  discard block
 block discarded – undo
552 641
 						$sth_modes->execute($query_modes_values);
553 642
 					}
554 643
 				}
555
-				if ($globalTransaction) $Connection->db->commit();
644
+				if ($globalTransaction) {
645
+					$Connection->db->commit();
646
+				}
556 647
 			} catch(PDOException $e) {
557 648
 				return "error : ".$e->getMessage();
558 649
 			}
@@ -688,25 +779,45 @@  discard block
 block discarded – undo
688 779
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
689 780
 		$Connection = new Connection();
690 781
 		$sth_dest = $Connection->db->prepare($query_dest);
691
-		if ($globalTransaction) $Connection->db->beginTransaction();
782
+		if ($globalTransaction) {
783
+			$Connection->db->beginTransaction();
784
+		}
692 785
   
693 786
 		$i = 0;
694 787
 		while($row = sparql_fetch_array($result))
695 788
 		{
696 789
 			if ($i >= 1) {
697 790
 			//print_r($row);
698
-			if (!isset($row['iata'])) $row['iata'] = '';
699
-			if (!isset($row['icao'])) $row['icao'] = '';
700
-			if (!isset($row['type'])) $row['type'] = '';
701
-			if (!isset($row['altitude'])) $row['altitude'] = '';
791
+			if (!isset($row['iata'])) {
792
+				$row['iata'] = '';
793
+			}
794
+			if (!isset($row['icao'])) {
795
+				$row['icao'] = '';
796
+			}
797
+			if (!isset($row['type'])) {
798
+				$row['type'] = '';
799
+			}
800
+			if (!isset($row['altitude'])) {
801
+				$row['altitude'] = '';
802
+			}
702 803
 			if (isset($row['city_bis'])) {
703 804
 				$row['city'] = $row['city_bis'];
704 805
 			}
705
-			if (!isset($row['city'])) $row['city'] = '';
706
-			if (!isset($row['country'])) $row['country'] = '';
707
-			if (!isset($row['homepage'])) $row['homepage'] = '';
708
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
709
-			if (!isset($row['name'])) continue;
806
+			if (!isset($row['city'])) {
807
+				$row['city'] = '';
808
+			}
809
+			if (!isset($row['country'])) {
810
+				$row['country'] = '';
811
+			}
812
+			if (!isset($row['homepage'])) {
813
+				$row['homepage'] = '';
814
+			}
815
+			if (!isset($row['wikipedia_page'])) {
816
+				$row['wikipedia_page'] = '';
817
+			}
818
+			if (!isset($row['name'])) {
819
+				continue;
820
+			}
710 821
 			if (!isset($row['image'])) {
711 822
 				$row['image'] = '';
712 823
 				$row['image_thumb'] = '';
@@ -762,7 +873,9 @@  discard block
 block discarded – undo
762 873
 
763 874
 			$i++;
764 875
 		}
765
-		if ($globalTransaction) $Connection->db->commit();
876
+		if ($globalTransaction) {
877
+			$Connection->db->commit();
878
+		}
766 879
 		/*
767 880
 		echo "Delete duplicate rows...\n";
768 881
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -805,7 +918,9 @@  discard block
 block discarded – undo
805 918
 		$delimiter = ',';
806 919
 		$out_file = $tmp_dir.'airports.csv';
807 920
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
808
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
921
+		if (!file_exists($out_file) || !is_readable($out_file)) {
922
+			return FALSE;
923
+		}
809 924
 		echo "Add data from ourairports.com...\n";
810 925
 
811 926
 		$header = NULL;
@@ -815,8 +930,9 @@  discard block
 block discarded – undo
815 930
 			//$Connection->db->beginTransaction();
816 931
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
817 932
 			{
818
-				if(!$header) $header = $row;
819
-				else {
933
+				if(!$header) {
934
+					$header = $row;
935
+				} else {
820 936
 					$data = array();
821 937
 					$data = array_combine($header, $row);
822 938
 					try {
@@ -857,7 +973,9 @@  discard block
 block discarded – undo
857 973
 		echo "Download data from another free database...\n";
858 974
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
859 975
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
860
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
976
+		if (!file_exists($out_file) || !is_readable($out_file)) {
977
+			return FALSE;
978
+		}
861 979
 		update_db::unzip($out_file);
862 980
 		$header = NULL;
863 981
 		echo "Add data from another free database...\n";
@@ -868,8 +986,9 @@  discard block
 block discarded – undo
868 986
 			//$Connection->db->beginTransaction();
869 987
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 988
 			{
871
-				if(!$header) $header = $row;
872
-				else {
989
+				if(!$header) {
990
+					$header = $row;
991
+				} else {
873 992
 					$data = $row;
874 993
 
875 994
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1042,7 +1161,9 @@  discard block
 block discarded – undo
1042 1161
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1043 1162
 		{
1044 1163
 			$i = 0;
1045
-			if ($globalTransaction) $Connection->db->beginTransaction();
1164
+			if ($globalTransaction) {
1165
+				$Connection->db->beginTransaction();
1166
+			}
1046 1167
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1047 1168
 			{
1048 1169
 				if ($i > 0) {
@@ -1055,7 +1176,9 @@  discard block
 block discarded – undo
1055 1176
 					}
1056 1177
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1057 1178
 					if (!empty($result_search)) {
1058
-						if ($globalDebug) echo '.';
1179
+						if ($globalDebug) {
1180
+							echo '.';
1181
+						}
1059 1182
 							//if ($globalDBdriver == 'mysql') {
1060 1183
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1061 1184
 							//} else {
@@ -1077,8 +1200,12 @@  discard block
 block discarded – undo
1077 1200
 						}
1078 1201
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1079 1202
 						if (!empty($result_search_mfr)) {
1080
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1081
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1203
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1204
+								$data[16] = $data[23];
1205
+							}
1206
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1207
+								$data[16] = $data[15];
1208
+							}
1082 1209
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1083 1210
 							try {
1084 1211
 								$sthf = $Connection->db->prepare($queryf);
@@ -1089,7 +1216,9 @@  discard block
 block discarded – undo
1089 1216
 						}
1090 1217
 					}
1091 1218
 					if (strtotime($data[29]) > time()) {
1092
-						if ($globalDebug) echo 'i';
1219
+						if ($globalDebug) {
1220
+							echo 'i';
1221
+						}
1093 1222
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1094 1223
 						try {
1095 1224
 							$sth = $Connection->db->prepare($query);
@@ -1100,13 +1229,19 @@  discard block
 block discarded – undo
1100 1229
 					}
1101 1230
 				}
1102 1231
 				if ($i % 90 == 0) {
1103
-					if ($globalTransaction) $Connection->db->commit();
1104
-					if ($globalTransaction) $Connection->db->beginTransaction();
1232
+					if ($globalTransaction) {
1233
+						$Connection->db->commit();
1234
+					}
1235
+					if ($globalTransaction) {
1236
+						$Connection->db->beginTransaction();
1237
+					}
1105 1238
 				}
1106 1239
 				$i++;
1107 1240
 			}
1108 1241
 			fclose($handle);
1109
-			if ($globalTransaction) $Connection->db->commit();
1242
+			if ($globalTransaction) {
1243
+				$Connection->db->commit();
1244
+			}
1110 1245
 		}
1111 1246
 		print_r($mfr);
1112 1247
 		return '';
@@ -1131,11 +1266,15 @@  discard block
 block discarded – undo
1131 1266
 			$i = 0;
1132 1267
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1133 1268
 			//$Connection->db->beginTransaction();
1134
-			if ($globalTransaction) $Connection->db->beginTransaction();
1269
+			if ($globalTransaction) {
1270
+				$Connection->db->beginTransaction();
1271
+			}
1135 1272
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1136 1273
 			{
1137 1274
 				if ($i > 0) {
1138
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1275
+					if ($data[1] == 'NULL') {
1276
+						$data[1] = $data[0];
1277
+					}
1139 1278
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1279
 					try {
1141 1280
 						$sth = $Connection->db->prepare($query);
@@ -1147,7 +1286,9 @@  discard block
 block discarded – undo
1147 1286
 				$i++;
1148 1287
 			}
1149 1288
 			fclose($handle);
1150
-			if ($globalTransaction) $Connection->db->commit();
1289
+			if ($globalTransaction) {
1290
+				$Connection->db->commit();
1291
+			}
1151 1292
 		}
1152 1293
 		return '';
1153 1294
         }
@@ -1168,7 +1309,9 @@  discard block
 block discarded – undo
1168 1309
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1169 1310
 		{
1170 1311
 			$i = 0;
1171
-			if ($globalTransaction) $Connection->db->beginTransaction();
1312
+			if ($globalTransaction) {
1313
+				$Connection->db->beginTransaction();
1314
+			}
1172 1315
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1173 1316
 			{
1174 1317
 				if ($i > 0) {
@@ -1184,7 +1327,9 @@  discard block
 block discarded – undo
1184 1327
 				$i++;
1185 1328
 			}
1186 1329
 			fclose($handle);
1187
-			if ($globalTransaction) $Connection->db->commit();
1330
+			if ($globalTransaction) {
1331
+				$Connection->db->commit();
1332
+			}
1188 1333
 		}
1189 1334
 		return '';
1190 1335
         }
@@ -1209,7 +1354,9 @@  discard block
 block discarded – undo
1209 1354
 			$i = 0;
1210 1355
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1211 1356
 			//$Connection->db->beginTransaction();
1212
-			if ($globalTransaction) $Connection->db->beginTransaction();
1357
+			if ($globalTransaction) {
1358
+				$Connection->db->beginTransaction();
1359
+			}
1213 1360
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1214 1361
 			{
1215 1362
 				if ($i > 0) {
@@ -1224,7 +1371,9 @@  discard block
 block discarded – undo
1224 1371
 				$i++;
1225 1372
 			}
1226 1373
 			fclose($handle);
1227
-			if ($globalTransaction) $Connection->db->commit();
1374
+			if ($globalTransaction) {
1375
+				$Connection->db->commit();
1376
+			}
1228 1377
 		}
1229 1378
 		return '';
1230 1379
         }
@@ -1249,7 +1398,9 @@  discard block
 block discarded – undo
1249 1398
 			$i = 0;
1250 1399
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1251 1400
 			//$Connection->db->beginTransaction();
1252
-			if ($globalTransaction) $Connection->db->beginTransaction();
1401
+			if ($globalTransaction) {
1402
+				$Connection->db->beginTransaction();
1403
+			}
1253 1404
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1254 1405
 			{
1255 1406
 				if ($i > 0) {
@@ -1265,7 +1416,9 @@  discard block
 block discarded – undo
1265 1416
 				$i++;
1266 1417
 			}
1267 1418
 			fclose($handle);
1268
-			if ($globalTransaction) $Connection->db->commit();
1419
+			if ($globalTransaction) {
1420
+				$Connection->db->commit();
1421
+			}
1269 1422
 		}
1270 1423
 		return '';
1271 1424
         }
@@ -1284,7 +1437,9 @@  discard block
 block discarded – undo
1284 1437
 		$Connection = new Connection();
1285 1438
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1286 1439
 		{
1287
-			if ($globalTransaction) $Connection->db->beginTransaction();
1440
+			if ($globalTransaction) {
1441
+				$Connection->db->beginTransaction();
1442
+			}
1288 1443
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1289 1444
 			{
1290 1445
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1299,7 +1454,9 @@  discard block
 block discarded – undo
1299 1454
 				}
1300 1455
 			}
1301 1456
 			fclose($handle);
1302
-			if ($globalTransaction) $Connection->db->commit();
1457
+			if ($globalTransaction) {
1458
+				$Connection->db->commit();
1459
+			}
1303 1460
 		}
1304 1461
 		return '';
1305 1462
         }
@@ -1450,7 +1607,9 @@  discard block
 block discarded – undo
1450 1607
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1451 1608
 		{
1452 1609
 			$i = 0;
1453
-			if ($globalTransaction) $Connection->db->beginTransaction();
1610
+			if ($globalTransaction) {
1611
+				$Connection->db->beginTransaction();
1612
+			}
1454 1613
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1455 1614
 			{
1456 1615
 				$i++;
@@ -1478,7 +1637,9 @@  discard block
 block discarded – undo
1478 1637
 				}
1479 1638
 			}
1480 1639
 			fclose($handle);
1481
-			if ($globalTransaction) $Connection->db->commit();
1640
+			if ($globalTransaction) {
1641
+				$Connection->db->commit();
1642
+			}
1482 1643
 		}
1483 1644
 		return '';
1484 1645
         }
@@ -1501,7 +1662,9 @@  discard block
 block discarded – undo
1501 1662
 		$Connection = new Connection();
1502 1663
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1503 1664
 		{
1504
-			if ($globalTransaction) $Connection->db->beginTransaction();
1665
+			if ($globalTransaction) {
1666
+				$Connection->db->beginTransaction();
1667
+			}
1505 1668
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1506 1669
 			{
1507 1670
 				if(count($row) > 1) {
@@ -1515,7 +1678,9 @@  discard block
 block discarded – undo
1515 1678
 				}
1516 1679
 			}
1517 1680
 			fclose($handle);
1518
-			if ($globalTransaction) $Connection->db->commit();
1681
+			if ($globalTransaction) {
1682
+				$Connection->db->commit();
1683
+			}
1519 1684
 		}
1520 1685
 		return '';
1521 1686
         }
@@ -1535,8 +1700,9 @@  discard block
 block discarded – undo
1535 1700
 	        }
1536 1701
 
1537 1702
 
1538
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1539
-		else {
1703
+		if ($globalDBdriver == 'mysql') {
1704
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1705
+		} else {
1540 1706
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1541 1707
 			$query = "CREATE EXTENSION postgis";
1542 1708
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1555,20 +1721,30 @@  discard block
 block discarded – undo
1555 1721
 		global $tmp_dir, $globalDebug;
1556 1722
 		include_once('class.create_db.php');
1557 1723
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1558
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1724
+		if ($globalDebug) {
1725
+			echo "NOTAM from FlightAirMap website : Download...";
1726
+		}
1559 1727
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1560 1728
 		$error = '';
1561 1729
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1562
-			if ($globalDebug) echo "Gunzip...";
1730
+			if ($globalDebug) {
1731
+				echo "Gunzip...";
1732
+			}
1563 1733
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1564
-			if ($globalDebug) echo "Add to DB...";
1734
+			if ($globalDebug) {
1735
+				echo "Add to DB...";
1736
+			}
1565 1737
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1566 1738
 			$NOTAM = new NOTAM();
1567 1739
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1568
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1740
+		} else {
1741
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1742
+		}
1569 1743
 		if ($error != '') {
1570 1744
 			return $error;
1571
-		} elseif ($globalDebug) echo "Done\n";
1745
+		} elseif ($globalDebug) {
1746
+			echo "Done\n";
1747
+		}
1572 1748
 		return '';
1573 1749
 	}
1574 1750
 
@@ -1622,67 +1798,111 @@  discard block
 block discarded – undo
1622 1798
 		//if ($globalDebug) echo "IVAO : Download...";
1623 1799
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1624 1800
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1625
-			if ($globalDebug) echo "Unzip...";
1801
+			if ($globalDebug) {
1802
+				echo "Unzip...";
1803
+			}
1626 1804
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1627
-			if ($globalDebug) echo "Add to DB...";
1805
+			if ($globalDebug) {
1806
+				echo "Add to DB...";
1807
+			}
1628 1808
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1629
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1809
+			if ($globalDebug) {
1810
+				echo "Copy airlines logos to airlines images directory...";
1811
+			}
1630 1812
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1631
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1632
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1633
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1813
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1814
+					$error = "Failed to copy airlines logo.";
1815
+				}
1816
+			} else {
1817
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1818
+			}
1819
+		} else {
1820
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1821
+		}
1634 1822
 		if ($error != '') {
1635 1823
 			return $error;
1636
-		} elseif ($globalDebug) echo "Done\n";
1824
+		} elseif ($globalDebug) {
1825
+			echo "Done\n";
1826
+		}
1637 1827
 		return '';
1638 1828
 	}
1639 1829
 
1640 1830
 	public static function update_routes() {
1641 1831
 		global $tmp_dir, $globalDebug;
1642 1832
 		$error = '';
1643
-		if ($globalDebug) echo "Routes : Download...";
1833
+		if ($globalDebug) {
1834
+			echo "Routes : Download...";
1835
+		}
1644 1836
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1645 1837
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1646
-			if ($globalDebug) echo "Gunzip...";
1838
+			if ($globalDebug) {
1839
+				echo "Gunzip...";
1840
+			}
1647 1841
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1648
-			if ($globalDebug) echo "Add to DB...";
1842
+			if ($globalDebug) {
1843
+				echo "Add to DB...";
1844
+			}
1649 1845
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1650
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1846
+		} else {
1847
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1848
+		}
1651 1849
 		if ($error != '') {
1652 1850
 			return $error;
1653
-		} elseif ($globalDebug) echo "Done\n";
1851
+		} elseif ($globalDebug) {
1852
+			echo "Done\n";
1853
+		}
1654 1854
 		return '';
1655 1855
 	}
1656 1856
 	public static function update_oneworld() {
1657 1857
 		global $tmp_dir, $globalDebug;
1658 1858
 		$error = '';
1659
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1859
+		if ($globalDebug) {
1860
+			echo "Schedules Oneworld : Download...";
1861
+		}
1660 1862
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1661 1863
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1662
-			if ($globalDebug) echo "Gunzip...";
1864
+			if ($globalDebug) {
1865
+				echo "Gunzip...";
1866
+			}
1663 1867
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1664
-			if ($globalDebug) echo "Add to DB...";
1868
+			if ($globalDebug) {
1869
+				echo "Add to DB...";
1870
+			}
1665 1871
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1666
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1872
+		} else {
1873
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1874
+		}
1667 1875
 		if ($error != '') {
1668 1876
 			return $error;
1669
-		} elseif ($globalDebug) echo "Done\n";
1877
+		} elseif ($globalDebug) {
1878
+			echo "Done\n";
1879
+		}
1670 1880
 		return '';
1671 1881
 	}
1672 1882
 	public static function update_skyteam() {
1673 1883
 		global $tmp_dir, $globalDebug;
1674 1884
 		$error = '';
1675
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1885
+		if ($globalDebug) {
1886
+			echo "Schedules Skyteam : Download...";
1887
+		}
1676 1888
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1677 1889
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1678
-			if ($globalDebug) echo "Gunzip...";
1890
+			if ($globalDebug) {
1891
+				echo "Gunzip...";
1892
+			}
1679 1893
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1680
-			if ($globalDebug) echo "Add to DB...";
1894
+			if ($globalDebug) {
1895
+				echo "Add to DB...";
1896
+			}
1681 1897
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1682
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1898
+		} else {
1899
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1900
+		}
1683 1901
 		if ($error != '') {
1684 1902
 			return $error;
1685
-		} elseif ($globalDebug) echo "Done\n";
1903
+		} elseif ($globalDebug) {
1904
+			echo "Done\n";
1905
+		}
1686 1906
 		return '';
1687 1907
 	}
1688 1908
 	public static function update_ModeS() {
@@ -1699,355 +1919,619 @@  discard block
 block discarded – undo
1699 1919
 			exit;
1700 1920
 		} elseif ($globalDebug) echo "Done\n";
1701 1921
 */
1702
-		if ($globalDebug) echo "Modes : Download...";
1703
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1922
+		if ($globalDebug) {
1923
+			echo "Modes : Download...";
1924
+		}
1925
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1704 1926
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1705 1927
 
1706 1928
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1707 1929
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1708
-			if ($globalDebug) echo "Unzip...";
1709
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1930
+			if ($globalDebug) {
1931
+				echo "Unzip...";
1932
+			}
1933
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1710 1934
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1711
-			if ($globalDebug) echo "Add to DB...";
1935
+			if ($globalDebug) {
1936
+				echo "Add to DB...";
1937
+			}
1712 1938
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1713 1939
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1714
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1940
+		} else {
1941
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1942
+		}
1715 1943
 		if ($error != '') {
1716 1944
 			return $error;
1717
-		} elseif ($globalDebug) echo "Done\n";
1945
+		} elseif ($globalDebug) {
1946
+			echo "Done\n";
1947
+		}
1718 1948
 		return '';
1719 1949
 	}
1720 1950
 
1721 1951
 	public static function update_ModeS_faa() {
1722 1952
 		global $tmp_dir, $globalDebug;
1723
-		if ($globalDebug) echo "Modes FAA: Download...";
1953
+		if ($globalDebug) {
1954
+			echo "Modes FAA: Download...";
1955
+		}
1724 1956
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1725 1957
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1726
-			if ($globalDebug) echo "Unzip...";
1958
+			if ($globalDebug) {
1959
+				echo "Unzip...";
1960
+			}
1727 1961
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1728
-			if ($globalDebug) echo "Add to DB...";
1962
+			if ($globalDebug) {
1963
+				echo "Add to DB...";
1964
+			}
1729 1965
 			$error = update_db::modes_faa();
1730
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1966
+		} else {
1967
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1968
+		}
1731 1969
 		if ($error != '') {
1732 1970
 			return $error;
1733
-		} elseif ($globalDebug) echo "Done\n";
1971
+		} elseif ($globalDebug) {
1972
+			echo "Done\n";
1973
+		}
1734 1974
 		return '';
1735 1975
 	}
1736 1976
 
1737 1977
 	public static function update_ModeS_flarm() {
1738 1978
 		global $tmp_dir, $globalDebug;
1739
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1979
+		if ($globalDebug) {
1980
+			echo "Modes Flarmnet: Download...";
1981
+		}
1740 1982
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1741 1983
 		if (file_exists($tmp_dir.'data.fln')) {
1742
-			if ($globalDebug) echo "Add to DB...";
1984
+			if ($globalDebug) {
1985
+				echo "Add to DB...";
1986
+			}
1743 1987
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1744
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1988
+		} else {
1989
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1990
+		}
1745 1991
 		if ($error != '') {
1746 1992
 			return $error;
1747
-		} elseif ($globalDebug) echo "Done\n";
1993
+		} elseif ($globalDebug) {
1994
+			echo "Done\n";
1995
+		}
1748 1996
 		return '';
1749 1997
 	}
1750 1998
 
1751 1999
 	public static function update_ModeS_ogn() {
1752 2000
 		global $tmp_dir, $globalDebug;
1753
-		if ($globalDebug) echo "Modes OGN: Download...";
2001
+		if ($globalDebug) {
2002
+			echo "Modes OGN: Download...";
2003
+		}
1754 2004
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1755 2005
 		if (file_exists($tmp_dir.'ogn.csv')) {
1756
-			if ($globalDebug) echo "Add to DB...";
2006
+			if ($globalDebug) {
2007
+				echo "Add to DB...";
2008
+			}
1757 2009
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1758
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2010
+		} else {
2011
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2012
+		}
1759 2013
 		if ($error != '') {
1760 2014
 			return $error;
1761
-		} elseif ($globalDebug) echo "Done\n";
2015
+		} elseif ($globalDebug) {
2016
+			echo "Done\n";
2017
+		}
1762 2018
 		return '';
1763 2019
 	}
1764 2020
 
1765 2021
 	public static function update_owner() {
1766 2022
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1767 2023
 		
1768
-		if ($globalDebug) echo "Owner France: Download...";
2024
+		if ($globalDebug) {
2025
+			echo "Owner France: Download...";
2026
+		}
1769 2027
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1770 2028
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1771
-			if ($globalDebug) echo "Add to DB...";
2029
+			if ($globalDebug) {
2030
+				echo "Add to DB...";
2031
+			}
1772 2032
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1773
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2033
+		} else {
2034
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2035
+		}
1774 2036
 		if ($error != '') {
1775 2037
 			return $error;
1776
-		} elseif ($globalDebug) echo "Done\n";
2038
+		} elseif ($globalDebug) {
2039
+			echo "Done\n";
2040
+		}
1777 2041
 		
1778
-		if ($globalDebug) echo "Owner Ireland: Download...";
2042
+		if ($globalDebug) {
2043
+			echo "Owner Ireland: Download...";
2044
+		}
1779 2045
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1780 2046
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1781
-			if ($globalDebug) echo "Add to DB...";
2047
+			if ($globalDebug) {
2048
+				echo "Add to DB...";
2049
+			}
1782 2050
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1783
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2051
+		} else {
2052
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2053
+		}
1784 2054
 		if ($error != '') {
1785 2055
 			return $error;
1786
-		} elseif ($globalDebug) echo "Done\n";
1787
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2056
+		} elseif ($globalDebug) {
2057
+			echo "Done\n";
2058
+		}
2059
+		if ($globalDebug) {
2060
+			echo "Owner Switzerland: Download...";
2061
+		}
1788 2062
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1789 2063
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1790
-			if ($globalDebug) echo "Add to DB...";
2064
+			if ($globalDebug) {
2065
+				echo "Add to DB...";
2066
+			}
1791 2067
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1792
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2068
+		} else {
2069
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2070
+		}
1793 2071
 		if ($error != '') {
1794 2072
 			return $error;
1795
-		} elseif ($globalDebug) echo "Done\n";
1796
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2073
+		} elseif ($globalDebug) {
2074
+			echo "Done\n";
2075
+		}
2076
+		if ($globalDebug) {
2077
+			echo "Owner Czech Republic: Download...";
2078
+		}
1797 2079
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1798 2080
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1799
-			if ($globalDebug) echo "Add to DB...";
2081
+			if ($globalDebug) {
2082
+				echo "Add to DB...";
2083
+			}
1800 2084
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1801
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2085
+		} else {
2086
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2087
+		}
1802 2088
 		if ($error != '') {
1803 2089
 			return $error;
1804
-		} elseif ($globalDebug) echo "Done\n";
1805
-		if ($globalDebug) echo "Owner Australia: Download...";
2090
+		} elseif ($globalDebug) {
2091
+			echo "Done\n";
2092
+		}
2093
+		if ($globalDebug) {
2094
+			echo "Owner Australia: Download...";
2095
+		}
1806 2096
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1807 2097
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1808
-			if ($globalDebug) echo "Add to DB...";
2098
+			if ($globalDebug) {
2099
+				echo "Add to DB...";
2100
+			}
1809 2101
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1810
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2102
+		} else {
2103
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2104
+		}
1811 2105
 		if ($error != '') {
1812 2106
 			return $error;
1813
-		} elseif ($globalDebug) echo "Done\n";
1814
-		if ($globalDebug) echo "Owner Austria: Download...";
2107
+		} elseif ($globalDebug) {
2108
+			echo "Done\n";
2109
+		}
2110
+		if ($globalDebug) {
2111
+			echo "Owner Austria: Download...";
2112
+		}
1815 2113
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1816 2114
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1817
-			if ($globalDebug) echo "Add to DB...";
2115
+			if ($globalDebug) {
2116
+				echo "Add to DB...";
2117
+			}
1818 2118
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1819
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2119
+		} else {
2120
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2121
+		}
1820 2122
 		if ($error != '') {
1821 2123
 			return $error;
1822
-		} elseif ($globalDebug) echo "Done\n";
1823
-		if ($globalDebug) echo "Owner Chile: Download...";
2124
+		} elseif ($globalDebug) {
2125
+			echo "Done\n";
2126
+		}
2127
+		if ($globalDebug) {
2128
+			echo "Owner Chile: Download...";
2129
+		}
1824 2130
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1825 2131
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1826
-			if ($globalDebug) echo "Add to DB...";
2132
+			if ($globalDebug) {
2133
+				echo "Add to DB...";
2134
+			}
1827 2135
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1828
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2136
+		} else {
2137
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2138
+		}
1829 2139
 		if ($error != '') {
1830 2140
 			return $error;
1831
-		} elseif ($globalDebug) echo "Done\n";
1832
-		if ($globalDebug) echo "Owner Colombia: Download...";
2141
+		} elseif ($globalDebug) {
2142
+			echo "Done\n";
2143
+		}
2144
+		if ($globalDebug) {
2145
+			echo "Owner Colombia: Download...";
2146
+		}
1833 2147
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1834 2148
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1835
-			if ($globalDebug) echo "Add to DB...";
2149
+			if ($globalDebug) {
2150
+				echo "Add to DB...";
2151
+			}
1836 2152
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1837
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2153
+		} else {
2154
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2155
+		}
1838 2156
 		if ($error != '') {
1839 2157
 			return $error;
1840
-		} elseif ($globalDebug) echo "Done\n";
1841
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2158
+		} elseif ($globalDebug) {
2159
+			echo "Done\n";
2160
+		}
2161
+		if ($globalDebug) {
2162
+			echo "Owner Bosnia Herzegobina: Download...";
2163
+		}
1842 2164
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1843 2165
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1844
-			if ($globalDebug) echo "Add to DB...";
2166
+			if ($globalDebug) {
2167
+				echo "Add to DB...";
2168
+			}
1845 2169
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1846
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2170
+		} else {
2171
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2172
+		}
1847 2173
 		if ($error != '') {
1848 2174
 			return $error;
1849
-		} elseif ($globalDebug) echo "Done\n";
1850
-		if ($globalDebug) echo "Owner Brazil: Download...";
2175
+		} elseif ($globalDebug) {
2176
+			echo "Done\n";
2177
+		}
2178
+		if ($globalDebug) {
2179
+			echo "Owner Brazil: Download...";
2180
+		}
1851 2181
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1852 2182
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1853
-			if ($globalDebug) echo "Add to DB...";
2183
+			if ($globalDebug) {
2184
+				echo "Add to DB...";
2185
+			}
1854 2186
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1855
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2187
+		} else {
2188
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2189
+		}
1856 2190
 		if ($error != '') {
1857 2191
 			return $error;
1858
-		} elseif ($globalDebug) echo "Done\n";
1859
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2192
+		} elseif ($globalDebug) {
2193
+			echo "Done\n";
2194
+		}
2195
+		if ($globalDebug) {
2196
+			echo "Owner Cayman Islands: Download...";
2197
+		}
1860 2198
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1861 2199
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1862
-			if ($globalDebug) echo "Add to DB...";
2200
+			if ($globalDebug) {
2201
+				echo "Add to DB...";
2202
+			}
1863 2203
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1864
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2204
+		} else {
2205
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2206
+		}
1865 2207
 		if ($error != '') {
1866 2208
 			return $error;
1867
-		} elseif ($globalDebug) echo "Done\n";
1868
-		if ($globalDebug) echo "Owner Croatia: Download...";
2209
+		} elseif ($globalDebug) {
2210
+			echo "Done\n";
2211
+		}
2212
+		if ($globalDebug) {
2213
+			echo "Owner Croatia: Download...";
2214
+		}
1869 2215
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1870 2216
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1871
-			if ($globalDebug) echo "Add to DB...";
2217
+			if ($globalDebug) {
2218
+				echo "Add to DB...";
2219
+			}
1872 2220
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1873
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2221
+		} else {
2222
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2223
+		}
1874 2224
 		if ($error != '') {
1875 2225
 			return $error;
1876
-		} elseif ($globalDebug) echo "Done\n";
1877
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2226
+		} elseif ($globalDebug) {
2227
+			echo "Done\n";
2228
+		}
2229
+		if ($globalDebug) {
2230
+			echo "Owner Luxembourg: Download...";
2231
+		}
1878 2232
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1879 2233
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1880
-			if ($globalDebug) echo "Add to DB...";
2234
+			if ($globalDebug) {
2235
+				echo "Add to DB...";
2236
+			}
1881 2237
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1882
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2238
+		} else {
2239
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2240
+		}
1883 2241
 		if ($error != '') {
1884 2242
 			return $error;
1885
-		} elseif ($globalDebug) echo "Done\n";
1886
-		if ($globalDebug) echo "Owner Maldives: Download...";
2243
+		} elseif ($globalDebug) {
2244
+			echo "Done\n";
2245
+		}
2246
+		if ($globalDebug) {
2247
+			echo "Owner Maldives: Download...";
2248
+		}
1887 2249
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1888 2250
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1889
-			if ($globalDebug) echo "Add to DB...";
2251
+			if ($globalDebug) {
2252
+				echo "Add to DB...";
2253
+			}
1890 2254
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1891
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2255
+		} else {
2256
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2257
+		}
1892 2258
 		if ($error != '') {
1893 2259
 			return $error;
1894
-		} elseif ($globalDebug) echo "Done\n";
1895
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2260
+		} elseif ($globalDebug) {
2261
+			echo "Done\n";
2262
+		}
2263
+		if ($globalDebug) {
2264
+			echo "Owner New Zealand: Download...";
2265
+		}
1896 2266
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1897 2267
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1898
-			if ($globalDebug) echo "Add to DB...";
2268
+			if ($globalDebug) {
2269
+				echo "Add to DB...";
2270
+			}
1899 2271
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1900
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2272
+		} else {
2273
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2274
+		}
1901 2275
 		if ($error != '') {
1902 2276
 			return $error;
1903
-		} elseif ($globalDebug) echo "Done\n";
1904
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2277
+		} elseif ($globalDebug) {
2278
+			echo "Done\n";
2279
+		}
2280
+		if ($globalDebug) {
2281
+			echo "Owner Papua New Guinea: Download...";
2282
+		}
1905 2283
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1906 2284
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1907
-			if ($globalDebug) echo "Add to DB...";
2285
+			if ($globalDebug) {
2286
+				echo "Add to DB...";
2287
+			}
1908 2288
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1909
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2289
+		} else {
2290
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2291
+		}
1910 2292
 		if ($error != '') {
1911 2293
 			return $error;
1912
-		} elseif ($globalDebug) echo "Done\n";
1913
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2294
+		} elseif ($globalDebug) {
2295
+			echo "Done\n";
2296
+		}
2297
+		if ($globalDebug) {
2298
+			echo "Owner Slovakia: Download...";
2299
+		}
1914 2300
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1915 2301
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1916
-			if ($globalDebug) echo "Add to DB...";
2302
+			if ($globalDebug) {
2303
+				echo "Add to DB...";
2304
+			}
1917 2305
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1918
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2306
+		} else {
2307
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2308
+		}
1919 2309
 		if ($error != '') {
1920 2310
 			return $error;
1921
-		} elseif ($globalDebug) echo "Done\n";
1922
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2311
+		} elseif ($globalDebug) {
2312
+			echo "Done\n";
2313
+		}
2314
+		if ($globalDebug) {
2315
+			echo "Owner Ecuador: Download...";
2316
+		}
1923 2317
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1924 2318
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1925
-			if ($globalDebug) echo "Add to DB...";
2319
+			if ($globalDebug) {
2320
+				echo "Add to DB...";
2321
+			}
1926 2322
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1927
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2323
+		} else {
2324
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2325
+		}
1928 2326
 		if ($error != '') {
1929 2327
 			return $error;
1930
-		} elseif ($globalDebug) echo "Done\n";
1931
-		if ($globalDebug) echo "Owner Iceland: Download...";
2328
+		} elseif ($globalDebug) {
2329
+			echo "Done\n";
2330
+		}
2331
+		if ($globalDebug) {
2332
+			echo "Owner Iceland: Download...";
2333
+		}
1932 2334
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1933 2335
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1934
-			if ($globalDebug) echo "Add to DB...";
2336
+			if ($globalDebug) {
2337
+				echo "Add to DB...";
2338
+			}
1935 2339
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1936
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2340
+		} else {
2341
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2342
+		}
1937 2343
 		if ($error != '') {
1938 2344
 			return $error;
1939
-		} elseif ($globalDebug) echo "Done\n";
1940
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2345
+		} elseif ($globalDebug) {
2346
+			echo "Done\n";
2347
+		}
2348
+		if ($globalDebug) {
2349
+			echo "Owner Isle of Man: Download...";
2350
+		}
1941 2351
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1942 2352
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1943
-			if ($globalDebug) echo "Add to DB...";
2353
+			if ($globalDebug) {
2354
+				echo "Add to DB...";
2355
+			}
1944 2356
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1945
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2357
+		} else {
2358
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2359
+		}
1946 2360
 		if ($error != '') {
1947 2361
 			return $error;
1948
-		} elseif ($globalDebug) echo "Done\n";
2362
+		} elseif ($globalDebug) {
2363
+			echo "Done\n";
2364
+		}
1949 2365
 		if ($globalMasterSource) {
1950
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2366
+			if ($globalDebug) {
2367
+				echo "ModeS Netherlands: Download...";
2368
+			}
1951 2369
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1952 2370
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1953
-				if ($globalDebug) echo "Add to DB...";
2371
+				if ($globalDebug) {
2372
+					echo "Add to DB...";
2373
+				}
1954 2374
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1955
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2375
+			} else {
2376
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2377
+			}
1956 2378
 			if ($error != '') {
1957 2379
 				return $error;
1958
-			} elseif ($globalDebug) echo "Done\n";
1959
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2380
+			} elseif ($globalDebug) {
2381
+				echo "Done\n";
2382
+			}
2383
+			if ($globalDebug) {
2384
+				echo "ModeS Denmark: Download...";
2385
+			}
1960 2386
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1961 2387
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1962
-				if ($globalDebug) echo "Add to DB...";
2388
+				if ($globalDebug) {
2389
+					echo "Add to DB...";
2390
+				}
1963 2391
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1964
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2392
+			} else {
2393
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2394
+			}
1965 2395
 			if ($error != '') {
1966 2396
 				return $error;
1967
-			} elseif ($globalDebug) echo "Done\n";
1968
-		} elseif ($globalDebug) echo "Done\n";
2397
+			} elseif ($globalDebug) {
2398
+				echo "Done\n";
2399
+			}
2400
+		} elseif ($globalDebug) {
2401
+			echo "Done\n";
2402
+		}
1969 2403
 		return '';
1970 2404
 	}
1971 2405
 
1972 2406
 	public static function update_translation() {
1973 2407
 		global $tmp_dir, $globalDebug;
1974 2408
 		$error = '';
1975
-		if ($globalDebug) echo "Translation : Download...";
2409
+		if ($globalDebug) {
2410
+			echo "Translation : Download...";
2411
+		}
1976 2412
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1977 2413
 		if (file_exists($tmp_dir.'translation.zip')) {
1978
-			if ($globalDebug) echo "Unzip...";
2414
+			if ($globalDebug) {
2415
+				echo "Unzip...";
2416
+			}
1979 2417
 			update_db::unzip($tmp_dir.'translation.zip');
1980
-			if ($globalDebug) echo "Add to DB...";
2418
+			if ($globalDebug) {
2419
+				echo "Add to DB...";
2420
+			}
1981 2421
 			$error = update_db::translation();
1982
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2422
+		} else {
2423
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2424
+		}
1983 2425
 		if ($error != '') {
1984 2426
 			return $error;
1985
-		} elseif ($globalDebug) echo "Done\n";
2427
+		} elseif ($globalDebug) {
2428
+			echo "Done\n";
2429
+		}
1986 2430
 		return '';
1987 2431
 	}
1988 2432
 
1989 2433
 	public static function update_translation_fam() {
1990 2434
 		global $tmp_dir, $globalDebug;
1991
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2435
+		if ($globalDebug) {
2436
+			echo "Translation from FlightAirMap website : Download...";
2437
+		}
1992 2438
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1993 2439
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1994
-			if ($globalDebug) echo "Gunzip...";
2440
+			if ($globalDebug) {
2441
+				echo "Gunzip...";
2442
+			}
1995 2443
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1996
-			if ($globalDebug) echo "Add to DB...";
2444
+			if ($globalDebug) {
2445
+				echo "Add to DB...";
2446
+			}
1997 2447
 			$error = update_db::translation_fam();
1998
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2448
+		} else {
2449
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2450
+		}
1999 2451
 		if ($error != '') {
2000 2452
 			return $error;
2001
-		} elseif ($globalDebug) echo "Done\n";
2453
+		} elseif ($globalDebug) {
2454
+			echo "Done\n";
2455
+		}
2002 2456
 		return '';
2003 2457
 	}
2004 2458
 	public static function update_ModeS_fam() {
2005 2459
 		global $tmp_dir, $globalDebug;
2006
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2460
+		if ($globalDebug) {
2461
+			echo "ModeS from FlightAirMap website : Download...";
2462
+		}
2007 2463
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2008 2464
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
2009
-			if ($globalDebug) echo "Gunzip...";
2465
+			if ($globalDebug) {
2466
+				echo "Gunzip...";
2467
+			}
2010 2468
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
2011
-			if ($globalDebug) echo "Add to DB...";
2469
+			if ($globalDebug) {
2470
+				echo "Add to DB...";
2471
+			}
2012 2472
 			$error = update_db::modes_fam();
2013
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2473
+		} else {
2474
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2475
+		}
2014 2476
 		if ($error != '') {
2015 2477
 			return $error;
2016
-		} elseif ($globalDebug) echo "Done\n";
2478
+		} elseif ($globalDebug) {
2479
+			echo "Done\n";
2480
+		}
2017 2481
 		return '';
2018 2482
 	}
2019 2483
 	public static function update_owner_fam() {
2020 2484
 		global $tmp_dir, $globalDebug, $globalOwner;
2021
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2485
+		if ($globalDebug) {
2486
+			echo "owner from FlightAirMap website : Download...";
2487
+		}
2022 2488
 		if ($globalOwner === TRUE) {
2023 2489
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2024 2490
 		} else {
2025 2491
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2026 2492
 		}
2027 2493
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2028
-			if ($globalDebug) echo "Gunzip...";
2494
+			if ($globalDebug) {
2495
+				echo "Gunzip...";
2496
+			}
2029 2497
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
2030
-			if ($globalDebug) echo "Add to DB...";
2498
+			if ($globalDebug) {
2499
+				echo "Add to DB...";
2500
+			}
2031 2501
 			$error = update_db::owner_fam();
2032
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2502
+		} else {
2503
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2504
+		}
2033 2505
 		if ($error != '') {
2034 2506
 			return $error;
2035
-		} elseif ($globalDebug) echo "Done\n";
2507
+		} elseif ($globalDebug) {
2508
+			echo "Done\n";
2509
+		}
2036 2510
 		return '';
2037 2511
 	}
2038 2512
 	public static function update_routes_fam() {
2039 2513
 		global $tmp_dir, $globalDebug;
2040
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2514
+		if ($globalDebug) {
2515
+			echo "Routes from FlightAirMap website : Download...";
2516
+		}
2041 2517
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2042 2518
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2043
-			if ($globalDebug) echo "Gunzip...";
2519
+			if ($globalDebug) {
2520
+				echo "Gunzip...";
2521
+			}
2044 2522
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
2045
-			if ($globalDebug) echo "Add to DB...";
2523
+			if ($globalDebug) {
2524
+				echo "Add to DB...";
2525
+			}
2046 2526
 			$error = update_db::routes_fam();
2047
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2527
+		} else {
2528
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2529
+		}
2048 2530
 		if ($error != '') {
2049 2531
 			return $error;
2050
-		} elseif ($globalDebug) echo "Done\n";
2532
+		} elseif ($globalDebug) {
2533
+			echo "Done\n";
2534
+		}
2051 2535
 		return '';
2052 2536
 	}
2053 2537
 	public static function update_marine_identity_fam() {
@@ -2057,14 +2541,22 @@  discard block
 block discarded – undo
2057 2541
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2058 2542
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2059 2543
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2060
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2544
+				if ($globalDebug) {
2545
+					echo "Marine identity from FlightAirMap website : Download...";
2546
+				}
2061 2547
 				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2062 2548
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2063
-					if ($globalDebug) echo "Gunzip...";
2549
+					if ($globalDebug) {
2550
+						echo "Gunzip...";
2551
+					}
2064 2552
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2065
-					if ($globalDebug) echo "Add to DB...";
2553
+					if ($globalDebug) {
2554
+						echo "Add to DB...";
2555
+					}
2066 2556
 					$error = update_db::marine_identity_fam();
2067
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2557
+				} else {
2558
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2559
+				}
2068 2560
 				if ($error != '') {
2069 2561
 					return $error;
2070 2562
 				} elseif ($globalDebug) {
@@ -2077,17 +2569,25 @@  discard block
 block discarded – undo
2077 2569
 	}
2078 2570
 	public static function update_banned_fam() {
2079 2571
 		global $tmp_dir, $globalDebug;
2080
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2572
+		if ($globalDebug) {
2573
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2574
+		}
2081 2575
 		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2082 2576
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2083 2577
 			//if ($globalDebug) echo "Gunzip...";
2084 2578
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2085
-			if ($globalDebug) echo "Add to DB...";
2579
+			if ($globalDebug) {
2580
+				echo "Add to DB...";
2581
+			}
2086 2582
 			$error = update_db::banned_fam();
2087
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2583
+		} else {
2584
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2585
+		}
2088 2586
 		if ($error != '') {
2089 2587
 			return $error;
2090
-		} elseif ($globalDebug) echo "Done\n";
2588
+		} elseif ($globalDebug) {
2589
+			echo "Done\n";
2590
+		}
2091 2591
 		return '';
2092 2592
 	}
2093 2593
 
@@ -2095,7 +2595,9 @@  discard block
 block discarded – undo
2095 2595
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2096 2596
 		include_once('class.create_db.php');
2097 2597
 		$error = '';
2098
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2598
+		if ($globalDebug) {
2599
+			echo "Airspace from FlightAirMap website : Download...";
2600
+		}
2099 2601
 		if ($globalDBdriver == 'mysql') {
2100 2602
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2101 2603
 		} else {
@@ -2111,9 +2613,13 @@  discard block
 block discarded – undo
2111 2613
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2112 2614
 				}
2113 2615
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2114
-					if ($globalDebug) echo "Gunzip...";
2616
+					if ($globalDebug) {
2617
+						echo "Gunzip...";
2618
+					}
2115 2619
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
2116
-					if ($globalDebug) echo "Add to DB...";
2620
+					if ($globalDebug) {
2621
+						echo "Add to DB...";
2622
+					}
2117 2623
 					$Connection = new Connection();
2118 2624
 					if ($Connection->tableExists('airspace')) {
2119 2625
 						$query = 'DROP TABLE airspace';
@@ -2126,19 +2632,27 @@  discard block
 block discarded – undo
2126 2632
 		    			}
2127 2633
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2128 2634
 					update_db::insert_airspace_version($airspace_md5);
2129
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2635
+				} else {
2636
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2637
+				}
2130 2638
 			}
2131
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2639
+		} else {
2640
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2641
+		}
2132 2642
 		if ($error != '') {
2133 2643
 			return $error;
2134
-		} elseif ($globalDebug) echo "Done\n";
2644
+		} elseif ($globalDebug) {
2645
+			echo "Done\n";
2646
+		}
2135 2647
 		return '';
2136 2648
 	}
2137 2649
 
2138 2650
 	public static function update_geoid_fam() {
2139 2651
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2140 2652
 		$error = '';
2141
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2653
+		if ($globalDebug) {
2654
+			echo "Geoid from FlightAirMap website : Download...";
2655
+		}
2142 2656
 		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2143 2657
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2144 2658
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2146,36 +2660,54 @@  discard block
 block discarded – undo
2146 2660
 			if (!update_db::check_geoid_version($geoid_md5)) {
2147 2661
 				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2148 2662
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2149
-					if ($globalDebug) echo "Gunzip...";
2663
+					if ($globalDebug) {
2664
+						echo "Gunzip...";
2665
+					}
2150 2666
 					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2151 2667
 					if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2152 2668
 						update_db::insert_geoid_version($geoid_md5);
2153 2669
 					}
2154
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2670
+				} else {
2671
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2672
+				}
2155 2673
 			}
2156
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
2674
+		} else {
2675
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
2676
+		}
2157 2677
 		if ($error != '') {
2158 2678
 			return $error;
2159
-		} elseif ($globalDebug) echo "Done\n";
2679
+		} elseif ($globalDebug) {
2680
+			echo "Done\n";
2681
+		}
2160 2682
 		return '';
2161 2683
 	}
2162 2684
 
2163 2685
 	public static function update_tle() {
2164 2686
 		global $tmp_dir, $globalDebug;
2165
-		if ($globalDebug) echo "Download TLE : Download...";
2687
+		if ($globalDebug) {
2688
+			echo "Download TLE : Download...";
2689
+		}
2166 2690
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2167 2691
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2168 2692
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2169 2693
 		foreach ($alltle as $filename) {
2170
-			if ($globalDebug) echo "downloading ".$filename.'...';
2694
+			if ($globalDebug) {
2695
+				echo "downloading ".$filename.'...';
2696
+			}
2171 2697
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2172 2698
 			if (file_exists($tmp_dir.$filename)) {
2173
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2699
+				if ($globalDebug) {
2700
+					echo "Add to DB ".$filename."...";
2701
+				}
2174 2702
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2175
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2703
+			} else {
2704
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2705
+			}
2176 2706
 			if ($error != '') {
2177 2707
 				echo $error."\n";
2178
-			} elseif ($globalDebug) echo "Done\n";
2708
+			} elseif ($globalDebug) {
2709
+				echo "Done\n";
2710
+			}
2179 2711
 		}
2180 2712
 		return '';
2181 2713
 	}
@@ -2183,10 +2715,14 @@  discard block
 block discarded – undo
2183 2715
 	public static function update_models() {
2184 2716
 		global $tmp_dir, $globalDebug;
2185 2717
 		$error = '';
2186
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2718
+		if ($globalDebug) {
2719
+			echo "Models from FlightAirMap website : Download...";
2720
+		}
2187 2721
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2188 2722
 		if (file_exists($tmp_dir.'models.md5sum')) {
2189
-			if ($globalDebug) echo "Check files...\n";
2723
+			if ($globalDebug) {
2724
+				echo "Check files...\n";
2725
+			}
2190 2726
 			$newmodelsdb = array();
2191 2727
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2192 2728
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2205,25 +2741,35 @@  discard block
 block discarded – undo
2205 2741
 			}
2206 2742
 			$diff = array_diff($newmodelsdb,$modelsdb);
2207 2743
 			foreach ($diff as $key => $value) {
2208
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2744
+				if ($globalDebug) {
2745
+					echo 'Downloading model '.$key.' ...'."\n";
2746
+				}
2209 2747
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2210 2748
 				
2211 2749
 			}
2212 2750
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2213
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2751
+		} else {
2752
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2753
+		}
2214 2754
 		if ($error != '') {
2215 2755
 			return $error;
2216
-		} elseif ($globalDebug) echo "Done\n";
2756
+		} elseif ($globalDebug) {
2757
+			echo "Done\n";
2758
+		}
2217 2759
 		return '';
2218 2760
 	}
2219 2761
 
2220 2762
 	public static function update_space_models() {
2221 2763
 		global $tmp_dir, $globalDebug;
2222 2764
 		$error = '';
2223
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2765
+		if ($globalDebug) {
2766
+			echo "Space models from FlightAirMap website : Download...";
2767
+		}
2224 2768
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2225 2769
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2226
-			if ($globalDebug) echo "Check files...\n";
2770
+			if ($globalDebug) {
2771
+				echo "Check files...\n";
2772
+			}
2227 2773
 			$newmodelsdb = array();
2228 2774
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2229 2775
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2242,25 +2788,35 @@  discard block
 block discarded – undo
2242 2788
 			}
2243 2789
 			$diff = array_diff($newmodelsdb,$modelsdb);
2244 2790
 			foreach ($diff as $key => $value) {
2245
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2791
+				if ($globalDebug) {
2792
+					echo 'Downloading space model '.$key.' ...'."\n";
2793
+				}
2246 2794
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2247 2795
 				
2248 2796
 			}
2249 2797
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2250
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2798
+		} else {
2799
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2800
+		}
2251 2801
 		if ($error != '') {
2252 2802
 			return $error;
2253
-		} elseif ($globalDebug) echo "Done\n";
2803
+		} elseif ($globalDebug) {
2804
+			echo "Done\n";
2805
+		}
2254 2806
 		return '';
2255 2807
 	}
2256 2808
 
2257 2809
 	public static function update_vehicules_models() {
2258 2810
 		global $tmp_dir, $globalDebug;
2259 2811
 		$error = '';
2260
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2812
+		if ($globalDebug) {
2813
+			echo "Vehicules models from FlightAirMap website : Download...";
2814
+		}
2261 2815
 		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2262 2816
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2263
-			if ($globalDebug) echo "Check files...\n";
2817
+			if ($globalDebug) {
2818
+				echo "Check files...\n";
2819
+			}
2264 2820
 			$newmodelsdb = array();
2265 2821
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2266 2822
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2279,15 +2835,21 @@  discard block
 block discarded – undo
2279 2835
 			}
2280 2836
 			$diff = array_diff($newmodelsdb,$modelsdb);
2281 2837
 			foreach ($diff as $key => $value) {
2282
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2838
+				if ($globalDebug) {
2839
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
2840
+				}
2283 2841
 				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2284 2842
 				
2285 2843
 			}
2286 2844
 			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2287
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2845
+		} else {
2846
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2847
+		}
2288 2848
 		if ($error != '') {
2289 2849
 			return $error;
2290
-		} elseif ($globalDebug) echo "Done\n";
2850
+		} elseif ($globalDebug) {
2851
+			echo "Done\n";
2852
+		}
2291 2853
 		return '';
2292 2854
 	}
2293 2855
 
@@ -2330,7 +2892,9 @@  discard block
 block discarded – undo
2330 2892
                 }
2331 2893
 
2332 2894
 		$error = '';
2333
-		if ($globalDebug) echo "Notam : Download...";
2895
+		if ($globalDebug) {
2896
+			echo "Notam : Download...";
2897
+		}
2334 2898
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2335 2899
 		if (file_exists($tmp_dir.'notam.rss')) {
2336 2900
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2345,14 +2909,30 @@  discard block
 block discarded – undo
2345 2909
 				$data['fir'] = $q[0];
2346 2910
 				$data['code'] = $q[1];
2347 2911
 				$ifrvfr = $q[2];
2348
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2349
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2350
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2351
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2352
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2353
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2354
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2355
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2912
+				if ($ifrvfr == 'IV') {
2913
+					$data['rules'] = 'IFR/VFR';
2914
+				}
2915
+				if ($ifrvfr == 'I') {
2916
+					$data['rules'] = 'IFR';
2917
+				}
2918
+				if ($ifrvfr == 'V') {
2919
+					$data['rules'] = 'VFR';
2920
+				}
2921
+				if ($q[4] == 'A') {
2922
+					$data['scope'] = 'Airport warning';
2923
+				}
2924
+				if ($q[4] == 'E') {
2925
+					$data['scope'] = 'Enroute warning';
2926
+				}
2927
+				if ($q[4] == 'W') {
2928
+					$data['scope'] = 'Navigation warning';
2929
+				}
2930
+				if ($q[4] == 'AE') {
2931
+					$data['scope'] = 'Airport/Enroute warning';
2932
+				}
2933
+				if ($q[4] == 'AW') {
2934
+					$data['scope'] = 'Airport/Navigation warning';
2935
+				}
2356 2936
 				//$data['scope'] = $q[4];
2357 2937
 				$data['lower_limit'] = $q[5];
2358 2938
 				$data['upper_limit'] = $q[6];
@@ -2360,8 +2940,12 @@  discard block
 block discarded – undo
2360 2940
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2361 2941
 				$latitude = $Common->convertDec($las,'latitude');
2362 2942
 				$longitude = $Common->convertDec($lns,'longitude');
2363
-				if ($lac == 'S') $latitude = '-'.$latitude;
2364
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2943
+				if ($lac == 'S') {
2944
+					$latitude = '-'.$latitude;
2945
+				}
2946
+				if ($lnc == 'W') {
2947
+					$longitude = '-'.$longitude;
2948
+				}
2365 2949
 				$data['center_latitude'] = $latitude;
2366 2950
 				$data['center_longitude'] = $longitude;
2367 2951
 				$data['radius'] = intval($radius);
@@ -2391,10 +2975,14 @@  discard block
 block discarded – undo
2391 2975
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2392 2976
 				unset($data);
2393 2977
 			} 
2394
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2978
+		} else {
2979
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2980
+		}
2395 2981
 		if ($error != '') {
2396 2982
 			return $error;
2397
-		} elseif ($globalDebug) echo "Done\n";
2983
+		} elseif ($globalDebug) {
2984
+			echo "Done\n";
2985
+		}
2398 2986
 		return '';
2399 2987
 	}
2400 2988
 	
@@ -2419,7 +3007,9 @@  discard block
 block discarded – undo
2419 3007
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2420 3008
 		$airspace_json = json_decode($airspace_lst,true);
2421 3009
 		foreach ($airspace_json['records'] as $airspace) {
2422
-			if ($globalDebug) echo $airspace['name']."...\n";
3010
+			if ($globalDebug) {
3011
+				echo $airspace['name']."...\n";
3012
+			}
2423 3013
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2424 3014
 			if (file_exists($tmp_dir.$airspace['name'])) {
2425 3015
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2463,8 +3053,11 @@  discard block
 block discarded – undo
2463 3053
                         return "error : ".$e->getMessage();
2464 3054
                 }
2465 3055
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2466
-                if ($row['nb'] > 0) return false;
2467
-                else return true;
3056
+                if ($row['nb'] > 0) {
3057
+                	return false;
3058
+                } else {
3059
+                	return true;
3060
+                }
2468 3061
 	}
2469 3062
 
2470 3063
 	public static function insert_last_update() {
@@ -2489,8 +3082,11 @@  discard block
 block discarded – undo
2489 3082
                         return "error : ".$e->getMessage();
2490 3083
                 }
2491 3084
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2492
-                if ($row['nb'] > 0) return true;
2493
-                else return false;
3085
+                if ($row['nb'] > 0) {
3086
+                	return true;
3087
+                } else {
3088
+                	return false;
3089
+                }
2494 3090
 	}
2495 3091
 
2496 3092
 	public static function check_geoid_version($version) {
@@ -2503,8 +3099,11 @@  discard block
 block discarded – undo
2503 3099
                         return "error : ".$e->getMessage();
2504 3100
                 }
2505 3101
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2506
-                if ($row['nb'] > 0) return true;
2507
-                else return false;
3102
+                if ($row['nb'] > 0) {
3103
+                	return true;
3104
+                } else {
3105
+                	return false;
3106
+                }
2508 3107
 	}
2509 3108
 
2510 3109
 	public static function check_marine_identity_version($version) {
@@ -2517,8 +3116,11 @@  discard block
 block discarded – undo
2517 3116
                         return "error : ".$e->getMessage();
2518 3117
                 }
2519 3118
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2520
-                if ($row['nb'] > 0) return true;
2521
-                else return false;
3119
+                if ($row['nb'] > 0) {
3120
+                	return true;
3121
+                } else {
3122
+                	return false;
3123
+                }
2522 3124
 	}
2523 3125
 
2524 3126
 
@@ -2573,8 +3175,11 @@  discard block
 block discarded – undo
2573 3175
                         return "error : ".$e->getMessage();
2574 3176
                 }
2575 3177
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2576
-                if ($row['nb'] > 0) return false;
2577
-                else return true;
3178
+                if ($row['nb'] > 0) {
3179
+                	return false;
3180
+                } else {
3181
+                	return true;
3182
+                }
2578 3183
 	}
2579 3184
 
2580 3185
 	public static function insert_last_notam_update() {
@@ -2604,8 +3209,11 @@  discard block
 block discarded – undo
2604 3209
                         return "error : ".$e->getMessage();
2605 3210
                 }
2606 3211
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2607
-                if ($row['nb'] > 0) return false;
2608
-                else return true;
3212
+                if ($row['nb'] > 0) {
3213
+                	return false;
3214
+                } else {
3215
+                	return true;
3216
+                }
2609 3217
 	}
2610 3218
 
2611 3219
 	public static function insert_last_airspace_update() {
@@ -2635,8 +3243,11 @@  discard block
 block discarded – undo
2635 3243
                         return "error : ".$e->getMessage();
2636 3244
                 }
2637 3245
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2638
-                if ($row['nb'] > 0) return false;
2639
-                else return true;
3246
+                if ($row['nb'] > 0) {
3247
+                	return false;
3248
+                } else {
3249
+                	return true;
3250
+                }
2640 3251
 	}
2641 3252
 
2642 3253
 	public static function insert_last_geoid_update() {
@@ -2666,8 +3277,11 @@  discard block
 block discarded – undo
2666 3277
                         return "error : ".$e->getMessage();
2667 3278
                 }
2668 3279
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2669
-                if ($row['nb'] > 0) return false;
2670
-                else return true;
3280
+                if ($row['nb'] > 0) {
3281
+                	return false;
3282
+                } else {
3283
+                	return true;
3284
+                }
2671 3285
 	}
2672 3286
 
2673 3287
 	public static function insert_last_owner_update() {
@@ -2696,8 +3310,11 @@  discard block
 block discarded – undo
2696 3310
                         return "error : ".$e->getMessage();
2697 3311
                 }
2698 3312
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2699
-                if ($row['nb'] > 0) return false;
2700
-                else return true;
3313
+                if ($row['nb'] > 0) {
3314
+                	return false;
3315
+                } else {
3316
+                	return true;
3317
+                }
2701 3318
 	}
2702 3319
 
2703 3320
 	public static function insert_last_schedules_update() {
@@ -2726,8 +3343,11 @@  discard block
 block discarded – undo
2726 3343
                         return "error : ".$e->getMessage();
2727 3344
                 }
2728 3345
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2729
-                if ($row['nb'] > 0) return false;
2730
-                else return true;
3346
+                if ($row['nb'] > 0) {
3347
+                	return false;
3348
+                } else {
3349
+                	return true;
3350
+                }
2731 3351
 	}
2732 3352
 
2733 3353
 	public static function insert_last_tle_update() {
@@ -2756,8 +3376,11 @@  discard block
 block discarded – undo
2756 3376
                         return "error : ".$e->getMessage();
2757 3377
                 }
2758 3378
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2759
-                if ($row['nb'] > 0) return false;
2760
-                else return true;
3379
+                if ($row['nb'] > 0) {
3380
+                	return false;
3381
+                } else {
3382
+                	return true;
3383
+                }
2761 3384
 	}
2762 3385
 
2763 3386
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
require/class.Marine.php 4 patches
Doc Comments   +2 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	* Get SQL query part for filter used
15 15
 	* @param Array $filter the filter
16
-	* @return Array the SQL part
16
+	* @return string the SQL part
17 17
 	*/
18 18
 	
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
@@ -566,25 +566,6 @@  discard block
 block discarded – undo
566 566
 	*
567 567
 	* @param String $fammarine_id the ID
568 568
 	* @param String $ident the marine ident
569
-	* @param String $departure_airport_icao the departure airport
570
-	* @param String $arrival_airport_icao the arrival airport
571
-	* @param String $latitude latitude of flight
572
-	* @param String $longitude latitude of flight
573
-	* @param String $waypoints waypoints of flight
574
-	* @param String $heading heading of flight
575
-	* @param String $groundspeed speed of flight
576
-	* @param String $date date of flight
577
-	* @param String $departure_airport_time departure time of flight
578
-	* @param String $arrival_airport_time arrival time of flight
579
-	* @param String $squawk squawk code of flight
580
-	* @param String $route_stop route stop of flight
581
-	* @param String $highlight highlight or not
582
-	* @param String $ModeS ModesS code of flight
583
-	* @param String $registration registration code of flight
584
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
585
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
586
-	* @param String $verticalrate vertival rate of flight
587
-	* @return String success or false
588 569
 	*/
589 570
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
590 571
 	{
@@ -1467,7 +1448,7 @@  discard block
 block discarded – undo
1467 1448
 	/**
1468 1449
 	* Parses the direction degrees to working
1469 1450
 	*
1470
-	* @param Float $direction the direction in degrees
1451
+	* @param integer $direction the direction in degrees
1471 1452
 	* @return Array the direction information
1472 1453
 	*
1473 1454
 	*/
Please login to merge, or discard this patch.
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 
13 13
 	/**
14
-	* Get SQL query part for filter used
15
-	* @param Array $filter the filter
16
-	* @return Array the SQL part
17
-	*/
14
+	 * Get SQL query part for filter used
15
+	 * @param Array $filter the filter
16
+	 * @return Array the SQL part
17
+	 */
18 18
 	
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 	}
79 79
 
80 80
 	/**
81
-	* Executes the SQL statements to get the spotter information
82
-	*
83
-	* @param String $query the SQL query
84
-	* @param Array $params parameter of the query
85
-	* @param String $limitQuery the limit query
86
-	* @return Array the spotter information
87
-	*
88
-	*/
81
+	 * Executes the SQL statements to get the spotter information
82
+	 *
83
+	 * @param String $query the SQL query
84
+	 * @param Array $params parameter of the query
85
+	 * @param String $limitQuery the limit query
86
+	 * @return Array the spotter information
87
+	 *
88
+	 */
89 89
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	
214 214
 	
215 215
 	/**
216
-	* Gets all the spotter information based on the latest data entry
217
-	*
218
-	* @return Array the spotter information
219
-	*
220
-	*/
216
+	 * Gets all the spotter information based on the latest data entry
217
+	 *
218
+	 * @return Array the spotter information
219
+	 *
220
+	 */
221 221
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
222 222
 	{
223 223
 		global $global_query;
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 	}
267 267
 
268 268
 	/**
269
-	* Gets all the spotter information based on the callsign
270
-	*
271
-	* @return Array the spotter information
272
-	*
273
-	*/
269
+	 * Gets all the spotter information based on the callsign
270
+	 *
271
+	 * @return Array the spotter information
272
+	 *
273
+	 */
274 274
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
275 275
 	{
276 276
 		global $global_query;
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
 
382 382
 
383 383
 	/**
384
-	* Gets all source name
385
-	*
386
-	* @param String type format of source
387
-	* @return Array list of source name
388
-	*
389
-	*/
384
+	 * Gets all source name
385
+	 *
386
+	 * @param String type format of source
387
+	 * @return Array list of source name
388
+	 *
389
+	 */
390 390
 	public function getAllSourceName($type = '',$filters = array())
391 391
 	{
392 392
 		$filter_query = $this->getFilter($filters,true,true);
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 
417 417
 
418 418
 	/**
419
-	* Gets a list of all idents/callsigns
420
-	*
421
-	* @return Array list of ident/callsign names
422
-	*
423
-	*/
419
+	 * Gets a list of all idents/callsigns
420
+	 *
421
+	 * @return Array list of ident/callsign names
422
+	 *
423
+	 */
424 424
 	public function getAllIdents($filters = array())
425 425
 	{
426 426
 		$filter_query = $this->getFilter($filters,true,true);
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
 	}
445 445
 
446 446
 	/**
447
-	* Gets all info from a mmsi
448
-	*
449
-	* @return Array list of mmsi info
450
-	*
451
-	*/
447
+	 * Gets all info from a mmsi
448
+	 *
449
+	 * @return Array list of mmsi info
450
+	 *
451
+	 */
452 452
 	public function getIdentity($mmsi)
453 453
 	{
454 454
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -505,18 +505,18 @@  discard block
 block discarded – undo
505 505
 	
506 506
 	
507 507
 	/**
508
-	* Update ident tracker data
509
-	*
510
-	* @param String $fammarine_id the ID
511
-	* @param String $ident the marine ident
512
-	* @return String success or false
513
-	*
514
-	*/	
508
+	 * Update ident tracker data
509
+	 *
510
+	 * @param String $fammarine_id the ID
511
+	 * @param String $ident the marine ident
512
+	 * @return String success or false
513
+	 *
514
+	 */	
515 515
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
516 516
 	{
517 517
 
518 518
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
519
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
519
+				$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
520 520
 
521 521
 		try {
522 522
 			$sth = $this->db->prepare($query);
@@ -530,19 +530,19 @@  discard block
 block discarded – undo
530 530
 	}
531 531
 
532 532
 	/**
533
-	* Update Status data
534
-	*
535
-	* @param String $fammarine_id the ID
536
-	* @param String $status_id the marine status id
537
-	* @param String $status the marine status
538
-	* @return String success or false
539
-	*
540
-	*/	
533
+	 * Update Status data
534
+	 *
535
+	 * @param String $fammarine_id the ID
536
+	 * @param String $status_id the marine status id
537
+	 * @param String $status the marine status
538
+	 * @return String success or false
539
+	 *
540
+	 */	
541 541
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
542 542
 	{
543 543
 
544 544
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
545
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
545
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
546 546
 
547 547
 		try {
548 548
 			$sth = $this->db->prepare($query);
@@ -555,17 +555,17 @@  discard block
 block discarded – undo
555 555
 
556 556
 	}
557 557
 	/**
558
-	* Update latest marine data
559
-	*
560
-	* @param String $fammarine_id the ID
561
-	* @param String $ident the marine ident
562
-	* @return String success or false
563
-	*
564
-	*/	
558
+	 * Update latest marine data
559
+	 *
560
+	 * @param String $fammarine_id the ID
561
+	 * @param String $ident the marine ident
562
+	 * @return String success or false
563
+	 *
564
+	 */	
565 565
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
566 566
 	{
567 567
 		$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';
568
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
568
+				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
569 569
 
570 570
 		try {
571 571
 			$sth = $this->db->prepare($query);
@@ -579,30 +579,30 @@  discard block
 block discarded – undo
579 579
 	}
580 580
 
581 581
 	/**
582
-	* Adds a new spotter data
583
-	*
584
-	* @param String $fammarine_id the ID
585
-	* @param String $ident the marine ident
586
-	* @param String $departure_airport_icao the departure airport
587
-	* @param String $arrival_airport_icao the arrival airport
588
-	* @param String $latitude latitude of flight
589
-	* @param String $longitude latitude of flight
590
-	* @param String $waypoints waypoints of flight
591
-	* @param String $heading heading of flight
592
-	* @param String $groundspeed speed of flight
593
-	* @param String $date date of flight
594
-	* @param String $departure_airport_time departure time of flight
595
-	* @param String $arrival_airport_time arrival time of flight
596
-	* @param String $squawk squawk code of flight
597
-	* @param String $route_stop route stop of flight
598
-	* @param String $highlight highlight or not
599
-	* @param String $ModeS ModesS code of flight
600
-	* @param String $registration registration code of flight
601
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
602
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
603
-	* @param String $verticalrate vertival rate of flight
604
-	* @return String success or false
605
-	*/
582
+	 * Adds a new spotter data
583
+	 *
584
+	 * @param String $fammarine_id the ID
585
+	 * @param String $ident the marine ident
586
+	 * @param String $departure_airport_icao the departure airport
587
+	 * @param String $arrival_airport_icao the arrival airport
588
+	 * @param String $latitude latitude of flight
589
+	 * @param String $longitude latitude of flight
590
+	 * @param String $waypoints waypoints of flight
591
+	 * @param String $heading heading of flight
592
+	 * @param String $groundspeed speed of flight
593
+	 * @param String $date date of flight
594
+	 * @param String $departure_airport_time departure time of flight
595
+	 * @param String $arrival_airport_time arrival time of flight
596
+	 * @param String $squawk squawk code of flight
597
+	 * @param String $route_stop route stop of flight
598
+	 * @param String $highlight highlight or not
599
+	 * @param String $ModeS ModesS code of flight
600
+	 * @param String $registration registration code of flight
601
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
602
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
603
+	 * @param String $verticalrate vertival rate of flight
604
+	 * @return String success or false
605
+	 */
606 606
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
607 607
 	{
608 608
 		global $globalURL, $globalMarineImageFetch;
@@ -699,13 +699,13 @@  discard block
 block discarded – undo
699 699
 			unset($Image);
700 700
 		}
701 701
 		
702
-                if ($latitude == '' && $longitude == '') {
703
-            		$latitude = 0;
704
-            		$longitude = 0;
705
-            	}
706
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
-                if ($arrival_date == '') $arrival_date = NULL;
702
+				if ($latitude == '' && $longitude == '') {
703
+					$latitude = 0;
704
+					$longitude = 0;
705
+				}
706
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
+				if ($arrival_date == '') $arrival_date = NULL;
709 709
 		$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) 
710 710
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 711
 
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 			$sth->execute($query_values);
717 717
 			$this->db = null;
718 718
 		} catch (PDOException $e) {
719
-		    return "error : ".$e->getMessage();
719
+			return "error : ".$e->getMessage();
720 720
 		}
721 721
 		
722 722
 		return "success";
@@ -725,11 +725,11 @@  discard block
 block discarded – undo
725 725
 	
726 726
   
727 727
 	/**
728
-	* Gets the aircraft ident within the last hour
729
-	*
730
-	* @return String the ident
731
-	*
732
-	*/
728
+	 * Gets the aircraft ident within the last hour
729
+	 *
730
+	 * @return String the ident
731
+	 *
732
+	 */
733 733
 	public function getIdentFromLastHour($ident)
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
@@ -745,11 +745,11 @@  discard block
 block discarded – undo
745 745
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
746 746
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
747 747
 			$query_data = array(':ident' => $ident);
748
-    		}
748
+			}
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-    		$ident_result='';
752
+			$ident_result='';
753 753
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['ident'];
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
 	
761 761
 	
762 762
 	/**
763
-	* Gets the aircraft data from the last 20 seconds
764
-	*
765
-	* @return Array the spotter data
766
-	*
767
-	*/
763
+	 * Gets the aircraft data from the last 20 seconds
764
+	 *
765
+	 * @return Array the spotter data
766
+	 *
767
+	 */
768 768
 	public function getRealTimeData($q = '')
769 769
 	{
770 770
 		global $globalDBdriver;
@@ -802,11 +802,11 @@  discard block
 block discarded – undo
802 802
 	
803 803
 
804 804
 	/**
805
-	* Gets all number of flight over countries
806
-	*
807
-	* @return Array the airline country list
808
-	*
809
-	*/
805
+	 * Gets all number of flight over countries
806
+	 *
807
+	 * @return Array the airline country list
808
+	 *
809
+	 */
810 810
 
811 811
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
812 812
 	{
@@ -879,11 +879,11 @@  discard block
 block discarded – undo
879 879
 	
880 880
 	
881 881
 	/**
882
-	* Gets all callsigns that have flown over
883
-	*
884
-	* @return Array the callsign list
885
-	*
886
-	*/
882
+	 * Gets all callsigns that have flown over
883
+	 *
884
+	 * @return Array the callsign list
885
+	 *
886
+	 */
887 887
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
888 888
 	{
889 889
 		global $globalDBdriver;
@@ -950,11 +950,11 @@  discard block
 block discarded – undo
950 950
 
951 951
 
952 952
 	/**
953
-	* Counts all dates
954
-	*
955
-	* @return Array the date list
956
-	*
957
-	*/
953
+	 * Counts all dates
954
+	 *
955
+	 * @return Array the date list
956
+	 *
957
+	 */
958 958
 	public function countAllDates($filters = array())
959 959
 	{
960 960
 		global $globalTimezone, $globalDBdriver;
@@ -1000,11 +1000,11 @@  discard block
 block discarded – undo
1000 1000
 	
1001 1001
 	
1002 1002
 	/**
1003
-	* Counts all dates during the last 7 days
1004
-	*
1005
-	* @return Array the date list
1006
-	*
1007
-	*/
1003
+	 * Counts all dates during the last 7 days
1004
+	 *
1005
+	 * @return Array the date list
1006
+	 *
1007
+	 */
1008 1008
 	public function countAllDatesLast7Days($filters = array())
1009 1009
 	{
1010 1010
 		global $globalTimezone, $globalDBdriver;
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 			$query .= " GROUP BY date_name 
1027 1027
 								ORDER BY date_name ASC";
1028 1028
 			$query_data = array(':offset' => $offset);
1029
-    		}
1029
+			}
1030 1030
 		
1031 1031
 		$sth = $this->db->prepare($query);
1032 1032
 		$sth->execute($query_data);
@@ -1046,11 +1046,11 @@  discard block
 block discarded – undo
1046 1046
 	}
1047 1047
 
1048 1048
 	/**
1049
-	* Counts all dates during the last month
1050
-	*
1051
-	* @return Array the date list
1052
-	*
1053
-	*/
1049
+	 * Counts all dates during the last month
1050
+	 *
1051
+	 * @return Array the date list
1052
+	 *
1053
+	 */
1054 1054
 	public function countAllDatesLastMonth($filters = array())
1055 1055
 	{
1056 1056
 		global $globalTimezone, $globalDBdriver;
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 			$query .= " GROUP BY date_name 
1073 1073
 								ORDER BY date_name ASC";
1074 1074
 			$query_data = array(':offset' => $offset);
1075
-    		}
1075
+			}
1076 1076
 		
1077 1077
 		$sth = $this->db->prepare($query);
1078 1078
 		$sth->execute($query_data);
@@ -1094,11 +1094,11 @@  discard block
 block discarded – undo
1094 1094
 
1095 1095
 
1096 1096
 	/**
1097
-	* Counts all month
1098
-	*
1099
-	* @return Array the month list
1100
-	*
1101
-	*/
1097
+	 * Counts all month
1098
+	 *
1099
+	 * @return Array the month list
1100
+	 *
1101
+	 */
1102 1102
 	public function countAllMonths($filters = array())
1103 1103
 	{
1104 1104
 		global $globalTimezone, $globalDBdriver;
@@ -1143,11 +1143,11 @@  discard block
 block discarded – undo
1143 1143
 	
1144 1144
 
1145 1145
 	/**
1146
-	* Counts all dates during the last year
1147
-	*
1148
-	* @return Array the date list
1149
-	*
1150
-	*/
1146
+	 * Counts all dates during the last year
1147
+	 *
1148
+	 * @return Array the date list
1149
+	 *
1150
+	 */
1151 1151
 	public function countAllMonthsLastYear($filters)
1152 1152
 	{
1153 1153
 		global $globalTimezone, $globalDBdriver;
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 			$query .= " GROUP BY year_name, month_name
1170 1170
 								ORDER BY year_name, month_name ASC";
1171 1171
 			$query_data = array(':offset' => $offset);
1172
-    		}
1172
+			}
1173 1173
 		
1174 1174
 		$sth = $this->db->prepare($query);
1175 1175
 		$sth->execute($query_data);
@@ -1192,11 +1192,11 @@  discard block
 block discarded – undo
1192 1192
 	
1193 1193
 	
1194 1194
 	/**
1195
-	* Counts all hours
1196
-	*
1197
-	* @return Array the hour list
1198
-	*
1199
-	*/
1195
+	 * Counts all hours
1196
+	 *
1197
+	 * @return Array the hour list
1198
+	 *
1199
+	 */
1200 1200
 	public function countAllHours($orderby,$filters = array())
1201 1201
 	{
1202 1202
 		global $globalTimezone, $globalDBdriver;
@@ -1259,11 +1259,11 @@  discard block
 block discarded – undo
1259 1259
 	
1260 1260
 	
1261 1261
 	/**
1262
-	* Counts all hours by date
1263
-	*
1264
-	* @return Array the hour list
1265
-	*
1266
-	*/
1262
+	 * Counts all hours by date
1263
+	 *
1264
+	 * @return Array the hour list
1265
+	 *
1266
+	 */
1267 1267
 	public function countAllHoursByDate($date, $filters = array())
1268 1268
 	{
1269 1269
 		global $globalTimezone, $globalDBdriver;
@@ -1307,11 +1307,11 @@  discard block
 block discarded – undo
1307 1307
 	
1308 1308
 	
1309 1309
 	/**
1310
-	* Counts all hours by a ident/callsign
1311
-	*
1312
-	* @return Array the hour list
1313
-	*
1314
-	*/
1310
+	 * Counts all hours by a ident/callsign
1311
+	 *
1312
+	 * @return Array the hour list
1313
+	 *
1314
+	 */
1315 1315
 	public function countAllHoursByIdent($ident, $filters = array())
1316 1316
 	{
1317 1317
 		global $globalTimezone, $globalDBdriver;
@@ -1356,11 +1356,11 @@  discard block
 block discarded – undo
1356 1356
 	
1357 1357
 	
1358 1358
 	/**
1359
-	* Counts all vessels
1360
-	*
1361
-	* @return Integer the number of vessels
1362
-	*
1363
-	*/
1359
+	 * Counts all vessels
1360
+	 *
1361
+	 * @return Integer the number of vessels
1362
+	 *
1363
+	 */
1364 1364
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
1365 1365
 	{
1366 1366
 		global $globalDBdriver;
@@ -1395,11 +1395,11 @@  discard block
 block discarded – undo
1395 1395
 	}
1396 1396
 	
1397 1397
 	/**
1398
-	* Counts all vessel type
1399
-	*
1400
-	* @return Integer the number of vessels
1401
-	*
1402
-	*/
1398
+	 * Counts all vessel type
1399
+	 *
1400
+	 * @return Integer the number of vessels
1401
+	 *
1402
+	 */
1403 1403
 	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1404 1404
 	{
1405 1405
 		global $globalDBdriver;
@@ -1434,11 +1434,11 @@  discard block
 block discarded – undo
1434 1434
 	
1435 1435
   
1436 1436
 	/**
1437
-	* Counts all hours of today
1438
-	*
1439
-	* @return Array the hour list
1440
-	*
1441
-	*/
1437
+	 * Counts all hours of today
1438
+	 *
1439
+	 * @return Array the hour list
1440
+	 *
1441
+	 */
1442 1442
 	public function countAllHoursFromToday($filters = array())
1443 1443
 	{
1444 1444
 		global $globalTimezone, $globalDBdriver;
@@ -1478,12 +1478,12 @@  discard block
 block discarded – undo
1478 1478
 	}
1479 1479
     
1480 1480
     
1481
-     /**
1482
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1483
-	*
1484
-	* @return Integer the Barrie Spotter ID
1481
+	 /**
1482
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1483
+	  *
1484
+	  * @return Integer the Barrie Spotter ID
1485 1485
 q	*
1486
-	*/
1486
+	  */
1487 1487
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1488 1488
 	{
1489 1489
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1504,13 +1504,13 @@  discard block
 block discarded – undo
1504 1504
   
1505 1505
  
1506 1506
 	/**
1507
-	* Parses a date string
1508
-	*
1509
-	* @param String $dateString the date string
1510
-	* @param String $timezone the timezone of a user
1511
-	* @return Array the time information
1512
-	*
1513
-	*/
1507
+	 * Parses a date string
1508
+	 *
1509
+	 * @param String $dateString the date string
1510
+	 * @param String $timezone the timezone of a user
1511
+	 * @return Array the time information
1512
+	 *
1513
+	 */
1514 1514
 	public function parseDateString($dateString, $timezone = '')
1515 1515
 	{
1516 1516
 		$time_array = array();
@@ -1543,12 +1543,12 @@  discard block
 block discarded – undo
1543 1543
 	}
1544 1544
 	
1545 1545
 	/**
1546
-	* Parses the direction degrees to working
1547
-	*
1548
-	* @param Float $direction the direction in degrees
1549
-	* @return Array the direction information
1550
-	*
1551
-	*/
1546
+	 * Parses the direction degrees to working
1547
+	 *
1548
+	 * @param Float $direction the direction in degrees
1549
+	 * @return Array the direction information
1550
+	 *
1551
+	 */
1552 1552
 	public function parseDirection($direction = 0)
1553 1553
 	{
1554 1554
 		if ($direction == '') $direction = 0;
@@ -1627,12 +1627,12 @@  discard block
 block discarded – undo
1627 1627
 	
1628 1628
 	
1629 1629
 	/**
1630
-	* Gets Country from latitude/longitude
1631
-	*
1632
-	* @param Float $latitude latitute of the flight
1633
-	* @param Float $longitude longitute of the flight
1634
-	* @return String the countrie
1635
-	*/
1630
+	 * Gets Country from latitude/longitude
1631
+	 *
1632
+	 * @param Float $latitude latitute of the flight
1633
+	 * @param Float $longitude longitute of the flight
1634
+	 * @return String the countrie
1635
+	 */
1636 1636
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1637 1637
 	{
1638 1638
 		global $globalDBdriver, $globalDebug;
@@ -1669,11 +1669,11 @@  discard block
 block discarded – undo
1669 1669
 	}
1670 1670
 
1671 1671
 	/**
1672
-	* Gets Country from iso2
1673
-	*
1674
-	* @param String $iso2 ISO2 country code
1675
-	* @return String the countrie
1676
-	*/
1672
+	 * Gets Country from iso2
1673
+	 *
1674
+	 * @param String $iso2 ISO2 country code
1675
+	 * @return String the countrie
1676
+	 */
1677 1677
 	public function getCountryFromISO2($iso2)
1678 1678
 	{
1679 1679
 		global $globalDBdriver, $globalDebug;
@@ -1702,12 +1702,12 @@  discard block
 block discarded – undo
1702 1702
 
1703 1703
 	
1704 1704
 	/**
1705
-	* Gets the short url from bit.ly
1706
-	*
1707
-	* @param String $url the full url
1708
-	* @return String the bit.ly url
1709
-	*
1710
-	*/
1705
+	 * Gets the short url from bit.ly
1706
+	 *
1707
+	 * @param String $url the full url
1708
+	 * @return String the bit.ly url
1709
+	 *
1710
+	 */
1711 1711
 	public function getBitlyURL($url)
1712 1712
 	{
1713 1713
 		global $globalBitlyAccessToken;
@@ -1734,11 +1734,11 @@  discard block
 block discarded – undo
1734 1734
 
1735 1735
 	
1736 1736
 	/**
1737
-	* Gets all vessels types that have flown over
1738
-	*
1739
-	* @return Array the vessel type list
1740
-	*
1741
-	*/
1737
+	 * Gets all vessels types that have flown over
1738
+	 *
1739
+	 * @return Array the vessel type list
1740
+	 *
1741
+	 */
1742 1742
 	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1743 1743
 	{
1744 1744
 		global $globalDBdriver;
Please login to merge, or discard this patch.
Braces   +170 added lines, -61 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) {
@@ -68,8 +70,11 @@  discard block
 block discarded – undo
68 70
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
69 71
 			}
70 72
 		}
71
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73
+		if ($filter_query_where == '' && $where) {
74
+			$filter_query_where = ' WHERE';
75
+		} elseif ($filter_query_where != '' && $and) {
76
+			$filter_query_where .= ' AND';
77
+		}
73 78
 		if ($filter_query_where != '') {
74 79
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
75 80
 		}
@@ -123,32 +128,54 @@  discard block
 block discarded – undo
123 128
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
124 129
 			} elseif (isset($row['spotter_archive_output_id'])) {
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
126
-			*/} 
127
-			elseif (isset($row['marineid'])) {
131
+			*/} elseif (isset($row['marineid'])) {
128 132
 				$temp_array['marine_id'] = $row['marineid'];
129 133
 			} else {
130 134
 				$temp_array['marine_id'] = '';
131 135
 			}
132
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
133
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
134
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
135
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
136
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
137
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
138
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
139
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
136
+			if (isset($row['fammarine_id'])) {
137
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
138
+			}
139
+			if (isset($row['mmsi'])) {
140
+				$temp_array['mmsi'] = $row['mmsi'];
141
+			}
142
+			if (isset($row['type'])) {
143
+				$temp_array['type'] = $row['type'];
144
+			}
145
+			if (isset($row['type_id'])) {
146
+				$temp_array['type_id'] = $row['type_id'];
147
+			}
148
+			if (isset($row['ident'])) {
149
+				$temp_array['ident'] = $row['ident'];
150
+			}
151
+			if (isset($row['latitude'])) {
152
+				$temp_array['latitude'] = $row['latitude'];
153
+			}
154
+			if (isset($row['longitude'])) {
155
+				$temp_array['longitude'] = $row['longitude'];
156
+			}
157
+			if (isset($row['format_source'])) {
158
+				$temp_array['format_source'] = $row['format_source'];
159
+			}
140 160
 			if (isset($row['heading'])) {
141 161
 				$temp_array['heading'] = $row['heading'];
142 162
 				$heading_direction = $this->parseDirection($row['heading']);
143
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
163
+				if (isset($heading_direction[0]['direction_fullname'])) {
164
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
165
+				}
166
+			}
167
+			if (isset($row['ground_speed'])) {
168
+				$temp_array['ground_speed'] = $row['ground_speed'];
144 169
 			}
145
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
146 170
 
147 171
 			if($temp_array['mmsi'] != "")
148 172
 			{
149 173
 				$Image = new Image($this->db);
150
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
151
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
174
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
175
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
176
+				} else {
177
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
178
+				}
152 179
 				unset($Image);
153 180
 				if (count($image_array) > 0) {
154 181
 					$temp_array['image'] = $image_array[0]['image'];
@@ -200,13 +227,21 @@  discard block
 block discarded – undo
200 227
 			}
201 228
 			
202 229
 			$fromsource = NULL;
203
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
204
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
205
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
230
+			if (isset($row['source_name']) && $row['source_name'] != '') {
231
+				$temp_array['source_name'] = $row['source_name'];
232
+			}
233
+			if (isset($row['over_country']) && $row['over_country'] != '') {
234
+				$temp_array['over_country'] = $row['over_country'];
235
+			}
236
+			if (isset($row['distance']) && $row['distance'] != '') {
237
+				$temp_array['distance'] = $row['distance'];
238
+			}
206 239
 			$temp_array['query_number_rows'] = $num_rows;
207 240
 			$spotter_array[] = $temp_array;
208 241
 		}
209
-		if ($num_rows == 0) return array();
242
+		if ($num_rows == 0) {
243
+			return array();
244
+		}
210 245
 		$spotter_array[0]['query_number_rows'] = $num_rows;
211 246
 		return $spotter_array;
212 247
 	}	
@@ -232,8 +267,12 @@  discard block
 block discarded – undo
232 267
 			{
233 268
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
234 269
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
235
-			} else $limit_query = "";
236
-		} else $limit_query = "";
270
+			} else {
271
+				$limit_query = "";
272
+			}
273
+		} else {
274
+			$limit_query = "";
275
+		}
237 276
 		if ($sort != "")
238 277
 		{
239 278
 			$search_orderby_array = $this->getOrderBy();
@@ -257,7 +296,9 @@  discard block
 block discarded – undo
257 296
 		global $global_query;
258 297
 		
259 298
 		date_default_timezone_set('UTC');
260
-		if ($id == '') return array();
299
+		if ($id == '') {
300
+			return array();
301
+		}
261 302
 		$additional_query = "marine_output.fammarine_id = :id";
262 303
 		$query_values = array(':id' => $id);
263 304
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -400,8 +441,11 @@  discard block
 block discarded – undo
400 441
 		$query .= " ORDER BY marine_output.source_name ASC";
401 442
 
402 443
 		$sth = $this->db->prepare($query);
403
-		if (!empty($query_values)) $sth->execute($query_values);
404
-		else $sth->execute();
444
+		if (!empty($query_values)) {
445
+			$sth->execute($query_values);
446
+		} else {
447
+			$sth->execute();
448
+		}
405 449
 
406 450
 		$source_array = array();
407 451
 		$temp_array = array();
@@ -456,8 +500,11 @@  discard block
 block discarded – undo
456 500
 		$sth = $this->db->prepare($query);
457 501
 		$sth->execute(array(':mmsi' => $mmsi));
458 502
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
459
-		if (isset($result[0])) return $result[0];
460
-		else return array();
503
+		if (isset($result[0])) {
504
+			return $result[0];
505
+		} else {
506
+			return array();
507
+		}
461 508
 	}
462 509
 
463 510
 	/*
@@ -473,7 +520,9 @@  discard block
 block discarded – undo
473 520
 			date_default_timezone_set($globalTimezone);
474 521
 			$datetime = new DateTime();
475 522
 			$offset = $datetime->format('P');
476
-		} else $offset = '+00:00';
523
+		} else {
524
+			$offset = '+00:00';
525
+		}
477 526
 
478 527
 		if ($globalDBdriver == 'mysql') {
479 528
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -703,9 +752,15 @@  discard block
 block discarded – undo
703 752
             		$latitude = 0;
704 753
             		$longitude = 0;
705 754
             	}
706
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
-                if ($arrival_date == '') $arrival_date = NULL;
755
+                if ($heading == '' || $Common->isInteger($heading) === false) {
756
+                	$heading = 0;
757
+                }
758
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
759
+                	$groundspeed = 0;
760
+                }
761
+                if ($arrival_date == '') {
762
+                	$arrival_date = NULL;
763
+                }
709 764
 		$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) 
710 765
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 766
 
@@ -813,7 +868,9 @@  discard block
 block discarded – undo
813 868
 		global $globalDBdriver, $globalArchive;
814 869
 		//$filter_query = $this->getFilter($filters,true,true);
815 870
 		$Connection= new Connection($this->db);
816
-		if (!$Connection->tableExists('countries')) return array();
871
+		if (!$Connection->tableExists('countries')) {
872
+			return array();
873
+		}
817 874
 		require_once('class.SpotterLive.php');
818 875
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
819 876
 			$MarineLive = new MarineLive();
@@ -857,7 +914,9 @@  discard block
 block discarded – undo
857 914
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
858 915
 		}
859 916
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
860
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
917
+		if ($limit) {
918
+			$query .= " LIMIT 10 OFFSET 0";
919
+		}
861 920
 
862 921
 		$sth = $this->db->prepare($query);
863 922
 		$sth->execute();
@@ -891,12 +950,18 @@  discard block
 block discarded – undo
891 950
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
892 951
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
893 952
 		 if ($olderthanmonths > 0) {
894
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
895
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
953
+			if ($globalDBdriver == 'mysql') {
954
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
955
+			} else {
956
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
957
+			}
896 958
 		}
897 959
 		if ($sincedate != '') {
898
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
899
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
960
+			if ($globalDBdriver == 'mysql') {
961
+				$query .= " AND marine_output.date > '".$sincedate."'";
962
+			} else {
963
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
964
+			}
900 965
 		}
901 966
 		$query_values = array();
902 967
 		if ($year != '') {
@@ -927,7 +992,9 @@  discard block
 block discarded – undo
927 992
 			}
928 993
 		}
929 994
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
930
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
995
+		if ($limit) {
996
+			$query .= " LIMIT 10 OFFSET 0";
997
+		}
931 998
       		
932 999
 		$sth = $this->db->prepare($query);
933 1000
 		$sth->execute($query_values);
@@ -962,7 +1029,9 @@  discard block
 block discarded – undo
962 1029
 			date_default_timezone_set($globalTimezone);
963 1030
 			$datetime = new DateTime();
964 1031
 			$offset = $datetime->format('P');
965
-		} else $offset = '+00:00';
1032
+		} else {
1033
+			$offset = '+00:00';
1034
+		}
966 1035
 
967 1036
 		if ($globalDBdriver == 'mysql') {
968 1037
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1012,7 +1081,9 @@  discard block
 block discarded – undo
1012 1081
 			date_default_timezone_set($globalTimezone);
1013 1082
 			$datetime = new DateTime();
1014 1083
 			$offset = $datetime->format('P');
1015
-		} else $offset = '+00:00';
1084
+		} else {
1085
+			$offset = '+00:00';
1086
+		}
1016 1087
 		$filter_query = $this->getFilter($filters,true,true);
1017 1088
 		if ($globalDBdriver == 'mysql') {
1018 1089
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1058,7 +1129,9 @@  discard block
 block discarded – undo
1058 1129
 			date_default_timezone_set($globalTimezone);
1059 1130
 			$datetime = new DateTime();
1060 1131
 			$offset = $datetime->format('P');
1061
-		} else $offset = '+00:00';
1132
+		} else {
1133
+			$offset = '+00:00';
1134
+		}
1062 1135
 		$filter_query = $this->getFilter($filters,true,true);
1063 1136
 		if ($globalDBdriver == 'mysql') {
1064 1137
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1106,7 +1179,9 @@  discard block
 block discarded – undo
1106 1179
 			date_default_timezone_set($globalTimezone);
1107 1180
 			$datetime = new DateTime();
1108 1181
 			$offset = $datetime->format('P');
1109
-		} else $offset = '+00:00';
1182
+		} else {
1183
+			$offset = '+00:00';
1184
+		}
1110 1185
 
1111 1186
 		if ($globalDBdriver == 'mysql') {
1112 1187
 			$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
@@ -1155,7 +1230,9 @@  discard block
 block discarded – undo
1155 1230
 			date_default_timezone_set($globalTimezone);
1156 1231
 			$datetime = new DateTime();
1157 1232
 			$offset = $datetime->format('P');
1158
-		} else $offset = '+00:00';
1233
+		} else {
1234
+			$offset = '+00:00';
1235
+		}
1159 1236
 		$filter_query = $this->getFilter($filters,true,true);
1160 1237
 		if ($globalDBdriver == 'mysql') {
1161 1238
 			$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
@@ -1204,7 +1281,9 @@  discard block
 block discarded – undo
1204 1281
 			date_default_timezone_set($globalTimezone);
1205 1282
 			$datetime = new DateTime();
1206 1283
 			$offset = $datetime->format('P');
1207
-		} else $offset = '+00:00';
1284
+		} else {
1285
+			$offset = '+00:00';
1286
+		}
1208 1287
 
1209 1288
 		$orderby_sql = '';
1210 1289
 		if ($orderby == "hour")
@@ -1273,7 +1352,9 @@  discard block
 block discarded – undo
1273 1352
 			date_default_timezone_set($globalTimezone);
1274 1353
 			$datetime = new DateTime($date);
1275 1354
 			$offset = $datetime->format('P');
1276
-		} else $offset = '+00:00';
1355
+		} else {
1356
+			$offset = '+00:00';
1357
+		}
1277 1358
 
1278 1359
 		if ($globalDBdriver == 'mysql') {
1279 1360
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1321,7 +1402,9 @@  discard block
 block discarded – undo
1321 1402
 			date_default_timezone_set($globalTimezone);
1322 1403
 			$datetime = new DateTime();
1323 1404
 			$offset = $datetime->format('P');
1324
-		} else $offset = '+00:00';
1405
+		} else {
1406
+			$offset = '+00:00';
1407
+		}
1325 1408
 
1326 1409
 		if ($globalDBdriver == 'mysql') {
1327 1410
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1386,8 +1469,11 @@  discard block
 block discarded – undo
1386 1469
 				$query_values = array_merge($query_values,array(':month' => $month));
1387 1470
 			}
1388 1471
 		}
1389
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1390
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1472
+		if (empty($query_values)) {
1473
+			$queryi .= $this->getFilter($filters);
1474
+		} else {
1475
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1476
+		}
1391 1477
 		
1392 1478
 		$sth = $this->db->prepare($queryi);
1393 1479
 		$sth->execute($query_values);
@@ -1424,8 +1510,11 @@  discard block
 block discarded – undo
1424 1510
 				$query_values = array_merge($query_values,array(':month' => $month));
1425 1511
 			}
1426 1512
 		}
1427
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1428
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1513
+		if (empty($query_values)) {
1514
+			$queryi .= $this->getFilter($filters);
1515
+		} else {
1516
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1517
+		}
1429 1518
 		
1430 1519
 		$sth = $this->db->prepare($queryi);
1431 1520
 		$sth->execute($query_values);
@@ -1447,7 +1536,9 @@  discard block
 block discarded – undo
1447 1536
 			date_default_timezone_set($globalTimezone);
1448 1537
 			$datetime = new DateTime();
1449 1538
 			$offset = $datetime->format('P');
1450
-		} else $offset = '+00:00';
1539
+		} else {
1540
+			$offset = '+00:00';
1541
+		}
1451 1542
 
1452 1543
 		if ($globalDBdriver == 'mysql') {
1453 1544
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1551,7 +1642,9 @@  discard block
 block discarded – undo
1551 1642
 	*/
1552 1643
 	public function parseDirection($direction = 0)
1553 1644
 	{
1554
-		if ($direction == '') $direction = 0;
1645
+		if ($direction == '') {
1646
+			$direction = 0;
1647
+		}
1555 1648
 		$direction_array = array();
1556 1649
 		$temp_array = array();
1557 1650
 
@@ -1640,7 +1733,9 @@  discard block
 block discarded – undo
1640 1733
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1641 1734
 	
1642 1735
 		$Connection = new Connection($this->db);
1643
-		if (!$Connection->tableExists('countries')) return '';
1736
+		if (!$Connection->tableExists('countries')) {
1737
+			return '';
1738
+		}
1644 1739
 	
1645 1740
 		try {
1646 1741
 			/*
@@ -1660,9 +1755,13 @@  discard block
 block discarded – undo
1660 1755
 			$sth->closeCursor();
1661 1756
 			if (count($row) > 0) {
1662 1757
 				return $row;
1663
-			} else return '';
1758
+			} else {
1759
+				return '';
1760
+			}
1664 1761
 		} catch (PDOException $e) {
1665
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1762
+			if (isset($globalDebug) && $globalDebug) {
1763
+				echo 'Error : '.$e->getMessage()."\n";
1764
+			}
1666 1765
 			return '';
1667 1766
 		}
1668 1767
 	
@@ -1680,7 +1779,9 @@  discard block
 block discarded – undo
1680 1779
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1681 1780
 	
1682 1781
 		$Connection = new Connection($this->db);
1683
-		if (!$Connection->tableExists('countries')) return '';
1782
+		if (!$Connection->tableExists('countries')) {
1783
+			return '';
1784
+		}
1684 1785
 	
1685 1786
 		try {
1686 1787
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1692,9 +1793,13 @@  discard block
 block discarded – undo
1692 1793
 			$sth->closeCursor();
1693 1794
 			if (count($row) > 0) {
1694 1795
 				return $row;
1695
-			} else return '';
1796
+			} else {
1797
+				return '';
1798
+			}
1696 1799
 		} catch (PDOException $e) {
1697
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1800
+			if (isset($globalDebug) && $globalDebug) {
1801
+				echo 'Error : '.$e->getMessage()."\n";
1802
+			}
1698 1803
 			return '';
1699 1804
 		}
1700 1805
 	
@@ -1712,7 +1817,9 @@  discard block
 block discarded – undo
1712 1817
 	{
1713 1818
 		global $globalBitlyAccessToken;
1714 1819
 		
1715
-		if ($globalBitlyAccessToken == '') return $url;
1820
+		if ($globalBitlyAccessToken == '') {
1821
+			return $url;
1822
+		}
1716 1823
         
1717 1824
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1718 1825
 		
@@ -1788,7 +1895,9 @@  discard block
 block discarded – undo
1788 1895
 			}
1789 1896
 		}
1790 1897
 		$query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC";
1791
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1898
+		if ($limit) {
1899
+			$query .= " LIMIT 10 OFFSET 0";
1900
+		}
1792 1901
 		$sth = $this->db->prepare($query);
1793 1902
 		$sth->execute($query_values);
1794 1903
 		$marine_array = array();
Please login to merge, or discard this patch.
Spacing   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @return Array the SQL part
17 17
 	*/
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 spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
38
+					$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";
39 39
 				} else {
40
-					$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";
40
+					$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";
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,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72 72
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73 73
 		if ($filter_query_where != '') {
74
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
74
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
75 75
 		}
76 76
 		$filter_query = $filter_query_join.$filter_query_where;
77 77
 		return $filter_query;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	* @return Array the spotter information
87 87
 	*
88 88
 	*/
89
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
89
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
92 92
 		if (!is_string($query))
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 			$sth = $this->db->prepare($query.$limitQuery);
107 107
 			$sth->execute($params);
108 108
 		} catch (PDOException $e) {
109
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
109
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
110 110
 			exit();
111 111
 		}
112 112
 		
113 113
 		$num_rows = 0;
114 114
 		$spotter_array = array();
115
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
115
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
116 116
 		{
117 117
 			$num_rows++;
118 118
 			$temp_array = array();
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 			}
145 145
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
146 146
 
147
-			if($temp_array['mmsi'] != "")
147
+			if ($temp_array['mmsi'] != "")
148 148
 			{
149 149
 				$Image = new Image($this->db);
150
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
150
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
151 151
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
152 152
 				unset($Image);
153 153
 				if (count($image_array) > 0) {
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 				{
184 184
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
185 185
 				} else {
186
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
186
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
187 187
 				}
188 188
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
189
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
190
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
189
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
190
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
191 191
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
192 192
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
193 193
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
194 194
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
195
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
196
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
195
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
196
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
197 197
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
198 198
 					}
199 199
 				}
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 		if ($limit != "")
227 227
 		{
228 228
 			$limit_array = explode(",", $limit);
229
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
230
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
229
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
230
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
231 231
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
232 232
 			{
233 233
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 		} else {
242 242
 			$orderby_query = " ORDER BY marine_output.date DESC";
243 243
 		}
244
-		$query  = $global_query.$filter_query." ".$orderby_query;
245
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
244
+		$query = $global_query.$filter_query." ".$orderby_query;
245
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
246 246
 		return $spotter_array;
247 247
 	}
248 248
     
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 		if ($id == '') return array();
261 261
 		$additional_query = "marine_output.fammarine_id = :id";
262 262
 		$query_values = array(':id' => $id);
263
-		$query  = $global_query." WHERE ".$additional_query." ";
264
-		$spotter_array = $this->getDataFromDB($query,$query_values);
263
+		$query = $global_query." WHERE ".$additional_query." ";
264
+		$spotter_array = $this->getDataFromDB($query, $query_values);
265 265
 		return $spotter_array;
266 266
 	}
267 267
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		$query_values = array();
281 281
 		$limit_query = '';
282 282
 		$additional_query = '';
283
-		$filter_query = $this->getFilter($filter,true,true);
283
+		$filter_query = $this->getFilter($filter, true, true);
284 284
 		if ($ident != "")
285 285
 		{
286 286
 			if (!is_string($ident))
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 		{
297 297
 			$limit_array = explode(",", $limit);
298 298
 			
299
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
300
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
299
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
300
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
301 301
 			
302 302
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
303 303
 			{
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		return $spotter_array;
322 322
 	}
323 323
 	
324
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
324
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
325 325
 	{
326 326
 		global $global_query, $globalTimezone, $globalDBdriver;
327 327
 		
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		$limit_query = '';
330 330
 		$additional_query = '';
331 331
 
332
-		$filter_query = $this->getFilter($filter,true,true);
332
+		$filter_query = $this->getFilter($filter, true, true);
333 333
 		
334 334
 		if ($date != "")
335 335
 		{
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 		{
356 356
 			$limit_array = explode(",", $limit);
357 357
 			
358
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
359
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
358
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
359
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
360 360
 			
361 361
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
362 362
 			{
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	* @return Array list of source name
388 388
 	*
389 389
 	*/
390
-	public function getAllSourceName($type = '',$filters = array())
390
+	public function getAllSourceName($type = '', $filters = array())
391 391
 	{
392
-		$filter_query = $this->getFilter($filters,true,true);
392
+		$filter_query = $this->getFilter($filters, true, true);
393 393
 		$query_values = array();
394
-		$query  = "SELECT DISTINCT marine_output.source_name 
394
+		$query = "SELECT DISTINCT marine_output.source_name 
395 395
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
396 396
 		if ($type != '') {
397 397
 			$query_values = array(':type' => $type);
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		$source_array = array();
407 407
 		$temp_array = array();
408 408
 		
409
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
409
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
410 410
 		{
411 411
 			$temp_array['source_name'] = $row['source_name'];
412 412
 			$source_array[] = $temp_array;
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
 	*/
424 424
 	public function getAllIdents($filters = array())
425 425
 	{
426
-		$filter_query = $this->getFilter($filters,true,true);
427
-		$query  = "SELECT DISTINCT marine_output.ident
426
+		$filter_query = $this->getFilter($filters, true, true);
427
+		$query = "SELECT DISTINCT marine_output.ident
428 428
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
429 429
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
430 430
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		$ident_array = array();
435 435
 		$temp_array = array();
436 436
 		
437
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
437
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
438 438
 		{
439 439
 			$temp_array['ident'] = $row['ident'];
440 440
 			$ident_array[] = $temp_array;
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	*/
452 452
 	public function getIdentity($mmsi)
453 453
 	{
454
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
454
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
455 455
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
456 456
 		$sth = $this->db->prepare($query);
457 457
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
 		} else $offset = '+00:00';
477 477
 
478 478
 		if ($globalDBdriver == 'mysql') {
479
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
479
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
480 480
 								FROM marine_output
481 481
 								WHERE marine_output.date <> '' 
482 482
 								ORDER BY marine_output.date ASC LIMIT 0,200";
483 483
 		} else {
484
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
484
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
485 485
 								FROM marine_output
486 486
 								WHERE marine_output.date <> '' 
487 487
 								ORDER BY marine_output.date ASC LIMIT 0,200";
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		$date_array = array();
494 494
 		$temp_array = array();
495 495
 		
496
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
496
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
497 497
 		{
498 498
 			$temp_array['date'] = $row['date'];
499 499
 
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 	* @return String success or false
513 513
 	*
514 514
 	*/	
515
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
515
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
516 516
 	{
517 517
 
518 518
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
519
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
519
+                $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
520 520
 
521 521
 		try {
522 522
 			$sth = $this->db->prepare($query);
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
 	* @return String success or false
539 539
 	*
540 540
 	*/	
541
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
541
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
542 542
 	{
543 543
 
544 544
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
545
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
545
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
546 546
 
547 547
 		try {
548 548
 			$sth = $this->db->prepare($query);
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
566 566
 	{
567 567
 		$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';
568
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
568
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
569 569
 
570 570
 		try {
571 571
 			$sth = $this->db->prepare($query);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 	* @param String $verticalrate vertival rate of flight
604 604
 	* @return String success or false
605 605
 	*/
606
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
606
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '')
607 607
 	{
608 608
 		global $globalURL, $globalMarineImageFetch;
609 609
 		
@@ -670,31 +670,31 @@  discard block
 block discarded – undo
670 670
 		}
671 671
 
672 672
     
673
-		if ($date == "" || strtotime($date) < time()-20*60)
673
+		if ($date == "" || strtotime($date) < time() - 20*60)
674 674
 		{
675 675
 			$date = date("Y-m-d H:i:s", time());
676 676
 		}
677 677
 
678
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
679
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
680
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
681
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
682
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
683
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
684
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
685
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
686
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
687
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
688
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
689
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
690
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
691
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
678
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
679
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
681
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
682
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
683
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
684
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
685
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
686
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
687
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
688
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
689
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
690
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
691
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
692 692
 	
693 693
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
694 694
 			$Image = new Image($this->db);
695
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
695
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
696 696
 			if (!isset($image_array[0]['mmsi'])) {
697
-				$Image->addMarineImage($mmsi,$imo,$ident);
697
+				$Image->addMarineImage($mmsi, $imo, $ident);
698 698
 			}
699 699
 			unset($Image);
700 700
 		}
@@ -706,10 +706,10 @@  discard block
 block discarded – undo
706 706
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707 707
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708 708
                 if ($arrival_date == '') $arrival_date = NULL;
709
-		$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) 
709
+		$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) 
710 710
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 711
 
712
-		$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);
712
+		$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);
713 713
 		try {
714 714
 		        
715 715
 			$sth = $this->db->prepare($query);
@@ -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_output.ident FROM marine_output 
737
+			$query = "SELECT marine_output.ident FROM marine_output 
738 738
 								WHERE marine_output.ident = :ident 
739 739
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
740 740
 								AND marine_output.date < UTC_TIMESTAMP()";
741 741
 			$query_data = array(':ident' => $ident);
742 742
 		} else {
743
-			$query  = "SELECT marine_output.ident FROM marine_output 
743
+			$query = "SELECT marine_output.ident FROM marine_output 
744 744
 								WHERE marine_output.ident = :ident 
745 745
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
746 746
 								AND marine_output.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['ident'];
756 756
 		}
@@ -776,8 +776,8 @@  discard block
 block discarded – undo
776 776
 				return false;
777 777
 			} else {
778 778
 				$q_array = explode(" ", $q);
779
-				foreach ($q_array as $q_item){
780
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
779
+				foreach ($q_array as $q_item) {
780
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
781 781
 					$additional_query .= " AND (";
782 782
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
783 783
 					$additional_query .= ")";
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
 			}
786 786
 		}
787 787
 		if ($globalDBdriver == 'mysql') {
788
-			$query  = "SELECT marine_output.* FROM marine_output 
788
+			$query = "SELECT marine_output.* FROM marine_output 
789 789
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
790 790
 				AND marine_output.date < UTC_TIMESTAMP()";
791 791
 		} else {
792
-			$query  = "SELECT marine_output.* FROM marine_output 
792
+			$query = "SELECT marine_output.* FROM marine_output 
793 793
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
794 794
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
795 795
 		}
@@ -808,16 +808,16 @@  discard block
 block discarded – undo
808 808
 	*
809 809
 	*/
810 810
 
811
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
811
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
812 812
 	{
813 813
 		global $globalDBdriver, $globalArchive;
814 814
 		//$filter_query = $this->getFilter($filters,true,true);
815
-		$Connection= new Connection($this->db);
815
+		$Connection = new Connection($this->db);
816 816
 		if (!$Connection->tableExists('countries')) return array();
817 817
 		require_once('class.SpotterLive.php');
818 818
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
819 819
 			$MarineLive = new MarineLive();
820
-			$filter_query = $MarineLive->getFilter($filters,true,true);
820
+			$filter_query = $MarineLive->getFilter($filters, true, true);
821 821
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
822 822
 			if ($olderthanmonths > 0) {
823 823
 				if ($globalDBdriver == 'mysql') {
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 		} else {
838 838
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
839 839
 			$MarineArchive = new MarineArchive();
840
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
840
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
841 841
 			$filter_query .= " over_country <> ''";
842 842
 			if ($olderthanmonths > 0) {
843 843
 				if ($globalDBdriver == 'mysql') {
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 		$flight_array = array();
866 866
 		$temp_array = array();
867 867
         
868
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
868
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
869 869
 		{
870 870
 			$temp_array['marine_count'] = $row['nb'];
871 871
 			$temp_array['marine_country'] = $row['name'];
@@ -884,11 +884,11 @@  discard block
 block discarded – undo
884 884
 	* @return Array the callsign list
885 885
 	*
886 886
 	*/
887
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
887
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
888 888
 	{
889 889
 		global $globalDBdriver;
890
-		$filter_query = $this->getFilter($filters,true,true);
891
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
890
+		$filter_query = $this->getFilter($filters, true, true);
891
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
892 892
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
893 893
 		 if ($olderthanmonths > 0) {
894 894
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -902,28 +902,28 @@  discard block
 block discarded – undo
902 902
 		if ($year != '') {
903 903
 			if ($globalDBdriver == 'mysql') {
904 904
 				$query .= " AND YEAR(marine_output.date) = :year";
905
-				$query_values = array_merge($query_values,array(':year' => $year));
905
+				$query_values = array_merge($query_values, array(':year' => $year));
906 906
 			} else {
907 907
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
908
-				$query_values = array_merge($query_values,array(':year' => $year));
908
+				$query_values = array_merge($query_values, array(':year' => $year));
909 909
 			}
910 910
 		}
911 911
 		if ($month != '') {
912 912
 			if ($globalDBdriver == 'mysql') {
913 913
 				$query .= " AND MONTH(marine_output.date) = :month";
914
-				$query_values = array_merge($query_values,array(':month' => $month));
914
+				$query_values = array_merge($query_values, array(':month' => $month));
915 915
 			} else {
916 916
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
917
-				$query_values = array_merge($query_values,array(':month' => $month));
917
+				$query_values = array_merge($query_values, array(':month' => $month));
918 918
 			}
919 919
 		}
920 920
 		if ($day != '') {
921 921
 			if ($globalDBdriver == 'mysql') {
922 922
 				$query .= " AND DAY(marine_output.date) = :day";
923
-				$query_values = array_merge($query_values,array(':day' => $day));
923
+				$query_values = array_merge($query_values, array(':day' => $day));
924 924
 			} else {
925 925
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
926
-				$query_values = array_merge($query_values,array(':day' => $day));
926
+				$query_values = array_merge($query_values, array(':day' => $day));
927 927
 			}
928 928
 		}
929 929
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 		$callsign_array = array();
936 936
 		$temp_array = array();
937 937
         
938
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
938
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
939 939
 		{
940 940
 			$temp_array['callsign_icao'] = $row['ident'];
941 941
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 		$date_array = array();
988 988
 		$temp_array = array();
989 989
         
990
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
990
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
991 991
 		{
992 992
 			$temp_array['date_name'] = $row['date_name'];
993 993
 			$temp_array['date_count'] = $row['date_count'];
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
 			$datetime = new DateTime();
1014 1014
 			$offset = $datetime->format('P');
1015 1015
 		} else $offset = '+00:00';
1016
-		$filter_query = $this->getFilter($filters,true,true);
1016
+		$filter_query = $this->getFilter($filters, true, true);
1017 1017
 		if ($globalDBdriver == 'mysql') {
1018 1018
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1019 1019
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 		$date_array = array();
1035 1035
 		$temp_array = array();
1036 1036
         
1037
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1037
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1038 1038
 		{
1039 1039
 			$temp_array['date_name'] = $row['date_name'];
1040 1040
 			$temp_array['date_count'] = $row['date_count'];
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
 			$datetime = new DateTime();
1060 1060
 			$offset = $datetime->format('P');
1061 1061
 		} else $offset = '+00:00';
1062
-		$filter_query = $this->getFilter($filters,true,true);
1062
+		$filter_query = $this->getFilter($filters, true, true);
1063 1063
 		if ($globalDBdriver == 'mysql') {
1064 1064
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1065 1065
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 		$date_array = array();
1081 1081
 		$temp_array = array();
1082 1082
         
1083
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1083
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1084 1084
 		{
1085 1085
 			$temp_array['date_name'] = $row['date_name'];
1086 1086
 			$temp_array['date_count'] = $row['date_count'];
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 		$date_array = array();
1128 1128
 		$temp_array = array();
1129 1129
         
1130
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1130
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1131 1131
 		{
1132 1132
 			$temp_array['month_name'] = $row['month_name'];
1133 1133
 			$temp_array['year_name'] = $row['year_name'];
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 			$datetime = new DateTime();
1157 1157
 			$offset = $datetime->format('P');
1158 1158
 		} else $offset = '+00:00';
1159
-		$filter_query = $this->getFilter($filters,true,true);
1159
+		$filter_query = $this->getFilter($filters, true, true);
1160 1160
 		if ($globalDBdriver == 'mysql') {
1161 1161
 			$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
1162 1162
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		$date_array = array();
1178 1178
 		$temp_array = array();
1179 1179
         
1180
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1180
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1181 1181
 		{
1182 1182
 			$temp_array['year_name'] = $row['year_name'];
1183 1183
 			$temp_array['month_name'] = $row['month_name'];
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 	* @return Array the hour list
1198 1198
 	*
1199 1199
 	*/
1200
-	public function countAllHours($orderby,$filters = array())
1200
+	public function countAllHours($orderby, $filters = array())
1201 1201
 	{
1202 1202
 		global $globalTimezone, $globalDBdriver;
1203 1203
 		if ($globalTimezone != '') {
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 		$hour_array = array();
1246 1246
 		$temp_array = array();
1247 1247
         
1248
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1248
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1249 1249
 		{
1250 1250
 			$temp_array['hour_name'] = $row['hour_name'];
1251 1251
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 	public function countAllHoursByDate($date, $filters = array())
1268 1268
 	{
1269 1269
 		global $globalTimezone, $globalDBdriver;
1270
-		$filter_query = $this->getFilter($filters,true,true);
1271
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1270
+		$filter_query = $this->getFilter($filters, true, true);
1271
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1272 1272
 		if ($globalTimezone != '') {
1273 1273
 			date_default_timezone_set($globalTimezone);
1274 1274
 			$datetime = new DateTime($date);
@@ -1276,12 +1276,12 @@  discard block
 block discarded – undo
1276 1276
 		} else $offset = '+00:00';
1277 1277
 
1278 1278
 		if ($globalDBdriver == 'mysql') {
1279
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1279
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1280 1280
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1281 1281
 								GROUP BY hour_name 
1282 1282
 								ORDER BY hour_name ASC";
1283 1283
 		} else {
1284
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1284
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1285 1285
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1286 1286
 								GROUP BY hour_name 
1287 1287
 								ORDER BY hour_name ASC";
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 		$hour_array = array();
1294 1294
 		$temp_array = array();
1295 1295
         
1296
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1296
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1297 1297
 		{
1298 1298
 			$temp_array['hour_name'] = $row['hour_name'];
1299 1299
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
 	public function countAllHoursByIdent($ident, $filters = array())
1316 1316
 	{
1317 1317
 		global $globalTimezone, $globalDBdriver;
1318
-		$filter_query = $this->getFilter($filters,true,true);
1319
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1318
+		$filter_query = $this->getFilter($filters, true, true);
1319
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1320 1320
 		if ($globalTimezone != '') {
1321 1321
 			date_default_timezone_set($globalTimezone);
1322 1322
 			$datetime = new DateTime();
@@ -1324,12 +1324,12 @@  discard block
 block discarded – undo
1324 1324
 		} else $offset = '+00:00';
1325 1325
 
1326 1326
 		if ($globalDBdriver == 'mysql') {
1327
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1327
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1328 1328
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1329 1329
 								GROUP BY hour_name 
1330 1330
 								ORDER BY hour_name ASC";
1331 1331
 		} else {
1332
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1332
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1333 1333
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1334 1334
 								GROUP BY hour_name 
1335 1335
 								ORDER BY hour_name ASC";
@@ -1337,12 +1337,12 @@  discard block
 block discarded – undo
1337 1337
       
1338 1338
 		
1339 1339
 		$sth = $this->db->prepare($query);
1340
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1340
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1341 1341
       
1342 1342
 		$hour_array = array();
1343 1343
 		$temp_array = array();
1344 1344
         
1345
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1345
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1346 1346
 		{
1347 1347
 			$temp_array['hour_name'] = $row['hour_name'];
1348 1348
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1361,33 +1361,33 @@  discard block
 block discarded – undo
1361 1361
 	* @return Integer the number of vessels
1362 1362
 	*
1363 1363
 	*/
1364
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1364
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1365 1365
 	{
1366 1366
 		global $globalDBdriver;
1367 1367
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1368
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1368
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1369 1369
 		$query_values = array();
1370 1370
 		$query = '';
1371 1371
 		if ($year != '') {
1372 1372
 			if ($globalDBdriver == 'mysql') {
1373 1373
 				$query .= " AND YEAR(marine_output.date) = :year";
1374
-				$query_values = array_merge($query_values,array(':year' => $year));
1374
+				$query_values = array_merge($query_values, array(':year' => $year));
1375 1375
 			} else {
1376 1376
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1377
-				$query_values = array_merge($query_values,array(':year' => $year));
1377
+				$query_values = array_merge($query_values, array(':year' => $year));
1378 1378
 			}
1379 1379
 		}
1380 1380
 		if ($month != '') {
1381 1381
 			if ($globalDBdriver == 'mysql') {
1382 1382
 				$query .= " AND MONTH(marine_output.date) = :month";
1383
-				$query_values = array_merge($query_values,array(':month' => $month));
1383
+				$query_values = array_merge($query_values, array(':month' => $month));
1384 1384
 			} else {
1385 1385
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1386
-				$query_values = array_merge($query_values,array(':month' => $month));
1386
+				$query_values = array_merge($query_values, array(':month' => $month));
1387 1387
 			}
1388 1388
 		}
1389 1389
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1390
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1390
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1391 1391
 		
1392 1392
 		$sth = $this->db->prepare($queryi);
1393 1393
 		$sth->execute($query_values);
@@ -1400,32 +1400,32 @@  discard block
 block discarded – undo
1400 1400
 	* @return Integer the number of vessels
1401 1401
 	*
1402 1402
 	*/
1403
-	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1403
+	public function countOverallMarineTypes($filters = array(), $year = '', $month = '')
1404 1404
 	{
1405 1405
 		global $globalDBdriver;
1406
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1406
+		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1407 1407
 		$query_values = array();
1408 1408
 		$query = '';
1409 1409
 		if ($year != '') {
1410 1410
 			if ($globalDBdriver == 'mysql') {
1411 1411
 				$query .= " AND YEAR(marine_output.date) = :year";
1412
-				$query_values = array_merge($query_values,array(':year' => $year));
1412
+				$query_values = array_merge($query_values, array(':year' => $year));
1413 1413
 			} else {
1414 1414
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1415
-				$query_values = array_merge($query_values,array(':year' => $year));
1415
+				$query_values = array_merge($query_values, array(':year' => $year));
1416 1416
 			}
1417 1417
 		}
1418 1418
 		if ($month != '') {
1419 1419
 			if ($globalDBdriver == 'mysql') {
1420 1420
 				$query .= " AND MONTH(marine_output.date) = :month";
1421
-				$query_values = array_merge($query_values,array(':month' => $month));
1421
+				$query_values = array_merge($query_values, array(':month' => $month));
1422 1422
 			} else {
1423 1423
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1424
-				$query_values = array_merge($query_values,array(':month' => $month));
1424
+				$query_values = array_merge($query_values, array(':month' => $month));
1425 1425
 			}
1426 1426
 		}
1427 1427
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1428
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1428
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1429 1429
 		
1430 1430
 		$sth = $this->db->prepare($queryi);
1431 1431
 		$sth->execute($query_values);
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
 	public function countAllHoursFromToday($filters = array())
1443 1443
 	{
1444 1444
 		global $globalTimezone, $globalDBdriver;
1445
-		$filter_query = $this->getFilter($filters,true,true);
1445
+		$filter_query = $this->getFilter($filters, true, true);
1446 1446
 		if ($globalTimezone != '') {
1447 1447
 			date_default_timezone_set($globalTimezone);
1448 1448
 			$datetime = new DateTime();
@@ -1450,12 +1450,12 @@  discard block
 block discarded – undo
1450 1450
 		} else $offset = '+00:00';
1451 1451
 
1452 1452
 		if ($globalDBdriver == 'mysql') {
1453
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1453
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1454 1454
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1455 1455
 								GROUP BY hour_name 
1456 1456
 								ORDER BY hour_name ASC";
1457 1457
 		} else {
1458
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1458
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1459 1459
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1460 1460
 								GROUP BY hour_name 
1461 1461
 								ORDER BY hour_name ASC";
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
 		$hour_array = array();
1468 1468
 		$temp_array = array();
1469 1469
         
1470
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1470
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1471 1471
 		{
1472 1472
 			$temp_array['hour_name'] = $row['hour_name'];
1473 1473
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1486,9 +1486,9 @@  discard block
 block discarded – undo
1486 1486
 	*/
1487 1487
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1488 1488
 	{
1489
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1489
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1490 1490
 
1491
-		$query  = "SELECT marine_output.marine_id
1491
+		$query = "SELECT marine_output.marine_id
1492 1492
 				FROM marine_output 
1493 1493
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1494 1494
         
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
 		$sth = $this->db->prepare($query);
1497 1497
 		$sth->execute();
1498 1498
 
1499
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1499
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1500 1500
 		{
1501 1501
 			return $row['marine_id'];
1502 1502
 		}
@@ -1521,23 +1521,23 @@  discard block
 block discarded – undo
1521 1521
 		}
1522 1522
 		
1523 1523
 		$current_date = date("Y-m-d H:i:s");
1524
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1524
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1525 1525
 		
1526 1526
 		$diff = abs(strtotime($current_date) - strtotime($date));
1527 1527
 
1528
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1528
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1529 1529
 		$years = $time_array['years'];
1530 1530
 		
1531
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1531
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1532 1532
 		$months = $time_array['months'];
1533 1533
 		
1534
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1534
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1535 1535
 		$days = $time_array['days'];
1536
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1536
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1537 1537
 		$hours = $time_array['hours'];
1538
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1538
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1539 1539
 		$minutes = $time_array['minutes'];
1540
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1540
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1541 1541
 		
1542 1542
 		return $time_array;
1543 1543
 	}
@@ -1560,63 +1560,63 @@  discard block
 block discarded – undo
1560 1560
 			$temp_array['direction_degree'] = $direction;
1561 1561
 			$temp_array['direction_shortname'] = "N";
1562 1562
 			$temp_array['direction_fullname'] = "North";
1563
-		} elseif ($direction >= 22.5 && $direction < 45){
1563
+		} elseif ($direction >= 22.5 && $direction < 45) {
1564 1564
 			$temp_array['direction_degree'] = $direction;
1565 1565
 			$temp_array['direction_shortname'] = "NNE";
1566 1566
 			$temp_array['direction_fullname'] = "North-Northeast";
1567
-		} elseif ($direction >= 45 && $direction < 67.5){
1567
+		} elseif ($direction >= 45 && $direction < 67.5) {
1568 1568
 			$temp_array['direction_degree'] = $direction;
1569 1569
 			$temp_array['direction_shortname'] = "NE";
1570 1570
 			$temp_array['direction_fullname'] = "Northeast";
1571
-		} elseif ($direction >= 67.5 && $direction < 90){
1571
+		} elseif ($direction >= 67.5 && $direction < 90) {
1572 1572
 			$temp_array['direction_degree'] = $direction;
1573 1573
 			$temp_array['direction_shortname'] = "ENE";
1574 1574
 			$temp_array['direction_fullname'] = "East-Northeast";
1575
-		} elseif ($direction >= 90 && $direction < 112.5){
1575
+		} elseif ($direction >= 90 && $direction < 112.5) {
1576 1576
 			$temp_array['direction_degree'] = $direction;
1577 1577
 			$temp_array['direction_shortname'] = "E";
1578 1578
 			$temp_array['direction_fullname'] = "East";
1579
-		} elseif ($direction >= 112.5 && $direction < 135){
1579
+		} elseif ($direction >= 112.5 && $direction < 135) {
1580 1580
 			$temp_array['direction_degree'] = $direction;
1581 1581
 			$temp_array['direction_shortname'] = "ESE";
1582 1582
 			$temp_array['direction_fullname'] = "East-Southeast";
1583
-		} elseif ($direction >= 135 && $direction < 157.5){
1583
+		} elseif ($direction >= 135 && $direction < 157.5) {
1584 1584
 			$temp_array['direction_degree'] = $direction;
1585 1585
 			$temp_array['direction_shortname'] = "SE";
1586 1586
 			$temp_array['direction_fullname'] = "Southeast";
1587
-		} elseif ($direction >= 157.5 && $direction < 180){
1587
+		} elseif ($direction >= 157.5 && $direction < 180) {
1588 1588
 			$temp_array['direction_degree'] = $direction;
1589 1589
 			$temp_array['direction_shortname'] = "SSE";
1590 1590
 			$temp_array['direction_fullname'] = "South-Southeast";
1591
-		} elseif ($direction >= 180 && $direction < 202.5){
1591
+		} elseif ($direction >= 180 && $direction < 202.5) {
1592 1592
 			$temp_array['direction_degree'] = $direction;
1593 1593
 			$temp_array['direction_shortname'] = "S";
1594 1594
 			$temp_array['direction_fullname'] = "South";
1595
-		} elseif ($direction >= 202.5 && $direction < 225){
1595
+		} elseif ($direction >= 202.5 && $direction < 225) {
1596 1596
 			$temp_array['direction_degree'] = $direction;
1597 1597
 			$temp_array['direction_shortname'] = "SSW";
1598 1598
 			$temp_array['direction_fullname'] = "South-Southwest";
1599
-		} elseif ($direction >= 225 && $direction < 247.5){
1599
+		} elseif ($direction >= 225 && $direction < 247.5) {
1600 1600
 			$temp_array['direction_degree'] = $direction;
1601 1601
 			$temp_array['direction_shortname'] = "SW";
1602 1602
 			$temp_array['direction_fullname'] = "Southwest";
1603
-		} elseif ($direction >= 247.5 && $direction < 270){
1603
+		} elseif ($direction >= 247.5 && $direction < 270) {
1604 1604
 			$temp_array['direction_degree'] = $direction;
1605 1605
 			$temp_array['direction_shortname'] = "WSW";
1606 1606
 			$temp_array['direction_fullname'] = "West-Southwest";
1607
-		} elseif ($direction >= 270 && $direction < 292.5){
1607
+		} elseif ($direction >= 270 && $direction < 292.5) {
1608 1608
 			$temp_array['direction_degree'] = $direction;
1609 1609
 			$temp_array['direction_shortname'] = "W";
1610 1610
 			$temp_array['direction_fullname'] = "West";
1611
-		} elseif ($direction >= 292.5 && $direction < 315){
1611
+		} elseif ($direction >= 292.5 && $direction < 315) {
1612 1612
 			$temp_array['direction_degree'] = $direction;
1613 1613
 			$temp_array['direction_shortname'] = "WNW";
1614 1614
 			$temp_array['direction_fullname'] = "West-Northwest";
1615
-		} elseif ($direction >= 315 && $direction < 337.5){
1615
+		} elseif ($direction >= 315 && $direction < 337.5) {
1616 1616
 			$temp_array['direction_degree'] = $direction;
1617 1617
 			$temp_array['direction_shortname'] = "NW";
1618 1618
 			$temp_array['direction_fullname'] = "Northwest";
1619
-		} elseif ($direction >= 337.5 && $direction < 360){
1619
+		} elseif ($direction >= 337.5 && $direction < 360) {
1620 1620
 			$temp_array['direction_degree'] = $direction;
1621 1621
 			$temp_array['direction_shortname'] = "NNW";
1622 1622
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1633,11 +1633,11 @@  discard block
 block discarded – undo
1633 1633
 	* @param Float $longitude longitute of the flight
1634 1634
 	* @return String the countrie
1635 1635
 	*/
1636
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1636
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1637 1637
 	{
1638 1638
 		global $globalDBdriver, $globalDebug;
1639
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1640
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1639
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1640
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1641 1641
 	
1642 1642
 		$Connection = new Connection($this->db);
1643 1643
 		if (!$Connection->tableExists('countries')) return '';
@@ -1677,7 +1677,7 @@  discard block
 block discarded – undo
1677 1677
 	public function getCountryFromISO2($iso2)
1678 1678
 	{
1679 1679
 		global $globalDBdriver, $globalDebug;
1680
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1680
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1681 1681
 	
1682 1682
 		$Connection = new Connection($this->db);
1683 1683
 		if (!$Connection->tableExists('countries')) return '';
@@ -1725,7 +1725,7 @@  discard block
 block discarded – undo
1725 1725
 		
1726 1726
 		$bitly_data = json_decode($bitly_data);
1727 1727
 		$bitly_url = '';
1728
-		if ($bitly_data->status_txt = "OK"){
1728
+		if ($bitly_data->status_txt = "OK") {
1729 1729
 			$bitly_url = $bitly_data->data->url;
1730 1730
 		}
1731 1731
 
@@ -1739,11 +1739,11 @@  discard block
 block discarded – undo
1739 1739
 	* @return Array the vessel type list
1740 1740
 	*
1741 1741
 	*/
1742
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1742
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1743 1743
 	{
1744 1744
 		global $globalDBdriver;
1745
-		$filter_query = $this->getFilter($filters,true,true);
1746
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count 
1745
+		$filter_query = $this->getFilter($filters, true, true);
1746
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count 
1747 1747
 		    FROM marine_output ".$filter_query." marine_output.type  <> ''";
1748 1748
 		if ($olderthanmonths > 0) {
1749 1749
 			if ($globalDBdriver == 'mysql') {
@@ -1763,28 +1763,28 @@  discard block
 block discarded – undo
1763 1763
 		if ($year != '') {
1764 1764
 			if ($globalDBdriver == 'mysql') {
1765 1765
 				$query .= " AND YEAR(marine_output.date) = :year";
1766
-				$query_values = array_merge($query_values,array(':year' => $year));
1766
+				$query_values = array_merge($query_values, array(':year' => $year));
1767 1767
 			} else {
1768 1768
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1769
-				$query_values = array_merge($query_values,array(':year' => $year));
1769
+				$query_values = array_merge($query_values, array(':year' => $year));
1770 1770
 			}
1771 1771
 		}
1772 1772
 		if ($month != '') {
1773 1773
 			if ($globalDBdriver == 'mysql') {
1774 1774
 				$query .= " AND MONTH(marine_output.date) = :month";
1775
-				$query_values = array_merge($query_values,array(':month' => $month));
1775
+				$query_values = array_merge($query_values, array(':month' => $month));
1776 1776
 			} else {
1777 1777
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1778
-				$query_values = array_merge($query_values,array(':month' => $month));
1778
+				$query_values = array_merge($query_values, array(':month' => $month));
1779 1779
 			}
1780 1780
 		}
1781 1781
 		if ($day != '') {
1782 1782
 			if ($globalDBdriver == 'mysql') {
1783 1783
 				$query .= " AND DAY(marine_output.date) = :day";
1784
-				$query_values = array_merge($query_values,array(':day' => $day));
1784
+				$query_values = array_merge($query_values, array(':day' => $day));
1785 1785
 			} else {
1786 1786
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1787
-				$query_values = array_merge($query_values,array(':day' => $day));
1787
+				$query_values = array_merge($query_values, array(':day' => $day));
1788 1788
 			}
1789 1789
 		}
1790 1790
 		$query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC";
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
 		$sth->execute($query_values);
1794 1794
 		$marine_array = array();
1795 1795
 		$temp_array = array();
1796
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1796
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1797 1797
 		{
1798 1798
 			$temp_array['marine_type'] = $row['marine_type'];
1799 1799
 			$temp_array['marine_type_count'] = $row['marine_type_count'];
@@ -1804,7 +1804,7 @@  discard block
 block discarded – undo
1804 1804
 
1805 1805
 	public function getOrderBy()
1806 1806
 	{
1807
-		$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"));
1807
+		$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"));
1808 1808
 		
1809 1809
 		return $orderby;
1810 1810
 		
Please login to merge, or discard this patch.
require/class.MarineLive.php 4 patches
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;
@@ -794,10 +794,6 @@  discard block
 block discarded – undo
794 794
 	*
795 795
 	* @param String $fammarine_id the ID from flightaware
796 796
 	* @param String $ident the flight ident
797
-	* @param String $aircraft_icao the aircraft type
798
-	* @param String $departure_airport_icao the departure airport
799
-	* @param String $arrival_airport_icao the arrival airport
800
-	* @return String success or false
801 797
 	*
802 798
 	*/
803 799
 	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
Please login to merge, or discard this patch.
Indentation   +190 added lines, -190 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 the latest data entry and coord
262
-	*
263
-	* @return Array the spotter information
264
-	*
265
-	*/
261
+	 * Gets all the spotter information based on the latest data entry and coord
262
+	 *
263
+	 * @return Array the spotter information
264
+	 *
265
+	 */
266 266
 	public function getMinLiveMarineDatabyCoord($coord, $filter = array())
267 267
 	{
268 268
 		global $globalDBdriver, $globalLiveInterval;
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 	}
291 291
 
292 292
 	/**
293
-	* Gets all the spotter information based on a user's latitude and longitude
294
-	*
295
-	* @return Array the spotter information
296
-	*
297
-	*/
293
+	 * Gets all the spotter information based on a user's latitude and longitude
294
+	 *
295
+	 * @return Array the spotter information
296
+	 *
297
+	 */
298 298
 	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
299 299
 	{
300 300
 		$Marine = new Marine($this->db);
@@ -307,134 +307,134 @@  discard block
 block discarded – undo
307 307
 		if ($lng != '')
308 308
 		{
309 309
 			if (!is_numeric($lng))
310
-                        {
311
-                                return false;
312
-                        }
313
-                }
314
-
315
-                if ($radius != '')
316
-                {
317
-                        if (!is_numeric($radius))
318
-                        {
319
-                                return false;
320
-                        }
321
-                }
310
+						{
311
+								return false;
312
+						}
313
+				}
314
+
315
+				if ($radius != '')
316
+				{
317
+						if (!is_numeric($radius))
318
+						{
319
+								return false;
320
+						}
321
+				}
322 322
 		$additional_query = '';
323 323
 		if ($interval != '')
324
-                {
325
-                        if (!is_string($interval))
326
-                        {
327
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
328
-			        return false;
329
-                        } else {
330
-                if ($interval == '1m')
331
-                {
332
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
333
-                } else if ($interval == '15m'){
334
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
335
-                } 
336
-            }
337
-                } else {
338
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
339
-        }
340
-
341
-                $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 
324
+				{
325
+						if (!is_string($interval))
326
+						{
327
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
328
+					return false;
329
+						} else {
330
+				if ($interval == '1m')
331
+				{
332
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
333
+				} else if ($interval == '15m'){
334
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
335
+				} 
336
+			}
337
+				} else {
338
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
339
+		}
340
+
341
+				$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 
342 342
                    WHERE marine_live.latitude <> '' 
343 343
                                    AND marine_live.longitude <> '' 
344 344
                    ".$additional_query."
345 345
                    HAVING distance < :radius  
346 346
                                    ORDER BY distance";
347 347
 
348
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
348
+				$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
349 349
 
350
-                return $spotter_array;
351
-        }
350
+				return $spotter_array;
351
+		}
352 352
 
353 353
     
354
-        /**
355
-	* Gets all the spotter information based on a particular callsign
356
-	*
357
-	* @return Array the spotter information
358
-	*
359
-	*/
354
+		/**
355
+		 * Gets all the spotter information based on a particular callsign
356
+		 *
357
+		 * @return Array the spotter information
358
+		 *
359
+		 */
360 360
 	public function getLastLiveMarineDataByIdent($ident)
361 361
 	{
362 362
 		$Marine = new Marine($this->db);
363 363
 		date_default_timezone_set('UTC');
364 364
 
365 365
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
366
-                $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';
366
+				$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';
367 367
 
368 368
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
369 369
 
370 370
 		return $spotter_array;
371 371
 	}
372 372
 
373
-        /**
374
-	* Gets all the spotter information based on a particular callsign
375
-	*
376
-	* @return Array the spotter information
377
-	*
378
-	*/
373
+		/**
374
+		 * Gets all the spotter information based on a particular callsign
375
+		 *
376
+		 * @return Array the spotter information
377
+		 *
378
+		 */
379 379
 	public function getDateLiveMarineDataByIdent($ident,$date)
380 380
 	{
381 381
 		$Marine = new Marine($this->db);
382 382
 		date_default_timezone_set('UTC');
383 383
 
384 384
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
385
-                $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';
385
+				$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';
386 386
 
387
-                $date = date('c',$date);
387
+				$date = date('c',$date);
388 388
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
389 389
 
390 390
 		return $spotter_array;
391 391
 	}
392 392
 
393
-        /**
394
-	* Gets last spotter information based on a particular callsign
395
-	*
396
-	* @return Array the spotter information
397
-	*
398
-	*/
393
+		/**
394
+		 * Gets last spotter information based on a particular callsign
395
+		 *
396
+		 * @return Array the spotter information
397
+		 *
398
+		 */
399 399
 	public function getLastLiveMarineDataById($id)
400 400
 	{
401 401
 		$Marine = new Marine($this->db);
402 402
 		date_default_timezone_set('UTC');
403 403
 
404 404
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
405
-                $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';
405
+				$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';
406 406
 
407 407
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
408 408
 
409 409
 		return $spotter_array;
410 410
 	}
411 411
 
412
-        /**
413
-	* Gets last spotter information based on a particular callsign
414
-	*
415
-	* @return Array the spotter information
416
-	*
417
-	*/
412
+		/**
413
+		 * Gets last spotter information based on a particular callsign
414
+		 *
415
+		 * @return Array the spotter information
416
+		 *
417
+		 */
418 418
 	public function getDateLiveMarineDataById($id,$date)
419 419
 	{
420 420
 		$Marine = new Marine($this->db);
421 421
 		date_default_timezone_set('UTC');
422 422
 
423 423
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
424
-                $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';
425
-                $date = date('c',$date);
424
+				$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';
425
+				$date = date('c',$date);
426 426
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
427 427
 
428 428
 		return $spotter_array;
429 429
 	}
430 430
 
431 431
 
432
-        /**
433
-	* Gets all the spotter information based on a particular id
434
-	*
435
-	* @return Array the spotter information
436
-	*
437
-	*/
432
+		/**
433
+		 * Gets all the spotter information based on a particular id
434
+		 *
435
+		 * @return Array the spotter information
436
+		 *
437
+		 */
438 438
 	public function getAllLiveMarineDataById($id,$liveinterval = false)
439 439
 	{
440 440
 		global $globalDBdriver, $globalLiveInterval;
@@ -462,18 +462,18 @@  discard block
 block discarded – undo
462 462
 		return $spotter_array;
463 463
 	}
464 464
 
465
-        /**
466
-	* Gets all the spotter information based on a particular ident
467
-	*
468
-	* @return Array the spotter information
469
-	*
470
-	*/
465
+		/**
466
+		 * Gets all the spotter information based on a particular ident
467
+		 *
468
+		 * @return Array the spotter information
469
+		 *
470
+		 */
471 471
 	public function getAllLiveMarineDataByIdent($ident)
472 472
 	{
473 473
 		date_default_timezone_set('UTC');
474 474
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
475 475
 		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
476
-    		try {
476
+			try {
477 477
 			
478 478
 			$sth = $this->db->prepare($query);
479 479
 			$sth->execute(array(':ident' => $ident));
@@ -487,23 +487,23 @@  discard block
 block discarded – undo
487 487
 
488 488
 
489 489
 	/**
490
-	* Deletes all info in the table
491
-	*
492
-	* @return String success or false
493
-	*
494
-	*/
490
+	 * Deletes all info in the table
491
+	 *
492
+	 * @return String success or false
493
+	 *
494
+	 */
495 495
 	public function deleteLiveMarineData()
496 496
 	{
497 497
 		global $globalDBdriver;
498 498
 		if ($globalDBdriver == 'mysql') {
499 499
 			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
500 500
 			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';
501
-            		//$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)";
501
+					//$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)";
502 502
 		} else {
503 503
 			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";
504 504
 		}
505 505
         
506
-    		try {
506
+			try {
507 507
 			
508 508
 			$sth = $this->db->prepare($query);
509 509
 			$sth->execute();
@@ -515,18 +515,18 @@  discard block
 block discarded – undo
515 515
 	}
516 516
 
517 517
 	/**
518
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
519
-	*
520
-	* @return String success or false
521
-	*
522
-	*/
518
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
519
+	 *
520
+	 * @return String success or false
521
+	 *
522
+	 */
523 523
 	public function deleteLiveMarineDataNotUpdated()
524 524
 	{
525 525
 		global $globalDBdriver, $globalDebug;
526 526
 		if ($globalDBdriver == 'mysql') {
527 527
 			//$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';
528
-    			$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";
529
-    			try {
528
+				$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";
529
+				try {
530 530
 				
531 531
 				$sth = $this->db->prepare($query);
532 532
 				$sth->execute();
@@ -534,8 +534,8 @@  discard block
 block discarded – undo
534 534
 				return "error";
535 535
 			}
536 536
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
537
-                        $i = 0;
538
-                        $j =0;
537
+						$i = 0;
538
+						$j =0;
539 539
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
540 540
 			foreach($all as $row)
541 541
 			{
@@ -543,20 +543,20 @@  discard block
 block discarded – undo
543 543
 				$j++;
544 544
 				if ($j == 30) {
545 545
 					if ($globalDebug) echo ".";
546
-				    	try {
546
+						try {
547 547
 						
548 548
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
549 549
 						$sth->execute();
550 550
 					} catch(PDOException $e) {
551 551
 						return "error";
552 552
 					}
553
-                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
554
-                                	$j = 0;
553
+									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
554
+									$j = 0;
555 555
 				}
556 556
 				$query_delete .= "'".$row['fammarine_id']."',";
557 557
 			}
558 558
 			if ($i > 0) {
559
-    				try {
559
+					try {
560 560
 					
561 561
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
562 562
 					$sth->execute();
@@ -567,9 +567,9 @@  discard block
 block discarded – undo
567 567
 			return "success";
568 568
 		} elseif ($globalDBdriver == 'pgsql') {
569 569
 			//$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";
570
-    			//$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";
571
-    			$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)";
572
-    			try {
570
+				//$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";
571
+				$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)";
572
+				try {
573 573
 				
574 574
 				$sth = $this->db->prepare($query);
575 575
 				$sth->execute();
@@ -613,17 +613,17 @@  discard block
 block discarded – undo
613 613
 	}
614 614
 
615 615
 	/**
616
-	* Deletes all info in the table for an ident
617
-	*
618
-	* @return String success or false
619
-	*
620
-	*/
616
+	 * Deletes all info in the table for an ident
617
+	 *
618
+	 * @return String success or false
619
+	 *
620
+	 */
621 621
 	public function deleteLiveMarineDataByIdent($ident)
622 622
 	{
623 623
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
624 624
 		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
625 625
         
626
-    		try {
626
+			try {
627 627
 			
628 628
 			$sth = $this->db->prepare($query);
629 629
 			$sth->execute(array(':ident' => $ident));
@@ -635,17 +635,17 @@  discard block
 block discarded – undo
635 635
 	}
636 636
 
637 637
 	/**
638
-	* Deletes all info in the table for an id
639
-	*
640
-	* @return String success or false
641
-	*
642
-	*/
638
+	 * Deletes all info in the table for an id
639
+	 *
640
+	 * @return String success or false
641
+	 *
642
+	 */
643 643
 	public function deleteLiveMarineDataById($id)
644 644
 	{
645 645
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
646 646
 		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
647 647
         
648
-    		try {
648
+			try {
649 649
 			
650 650
 			$sth = $this->db->prepare($query);
651 651
 			$sth->execute(array(':id' => $id));
@@ -658,11 +658,11 @@  discard block
 block discarded – undo
658 658
 
659 659
 
660 660
 	/**
661
-	* Gets the aircraft ident within the last hour
662
-	*
663
-	* @return String the ident
664
-	*
665
-	*/
661
+	 * Gets the aircraft ident within the last hour
662
+	 *
663
+	 * @return String the ident
664
+	 *
665
+	 */
666 666
 	public function getIdentFromLastHour($ident)
667 667
 	{
668 668
 		global $globalDBdriver, $globalTimezone;
@@ -688,14 +688,14 @@  discard block
 block discarded – undo
688 688
 			$ident_result = $row['ident'];
689 689
 		}
690 690
 		return $ident_result;
691
-        }
691
+		}
692 692
 
693 693
 	/**
694
-	* Check recent aircraft
695
-	*
696
-	* @return String the ident
697
-	*
698
-	*/
694
+	 * Check recent aircraft
695
+	 *
696
+	 * @return String the ident
697
+	 *
698
+	 */
699 699
 	public function checkIdentRecent($ident)
700 700
 	{
701 701
 		global $globalDBdriver, $globalTimezone;
@@ -721,14 +721,14 @@  discard block
 block discarded – undo
721 721
 			$ident_result = $row['fammarine_id'];
722 722
 		}
723 723
 		return $ident_result;
724
-        }
724
+		}
725 725
 
726 726
 	/**
727
-	* Check recent aircraft by id
728
-	*
729
-	* @return String the ident
730
-	*
731
-	*/
727
+	 * Check recent aircraft by id
728
+	 *
729
+	 * @return String the ident
730
+	 *
731
+	 */
732 732
 	public function checkIdRecent($id)
733 733
 	{
734 734
 		global $globalDBdriver, $globalTimezone;
@@ -754,14 +754,14 @@  discard block
 block discarded – undo
754 754
 			$ident_result = $row['fammarine_id'];
755 755
 		}
756 756
 		return $ident_result;
757
-        }
757
+		}
758 758
 
759 759
 	/**
760
-	* Check recent aircraft by mmsi
761
-	*
762
-	* @return String the ident
763
-	*
764
-	*/
760
+	 * Check recent aircraft by mmsi
761
+	 *
762
+	 * @return String the ident
763
+	 *
764
+	 */
765 765
 	public function checkMMSIRecent($mmsi)
766 766
 	{
767 767
 		global $globalDBdriver, $globalTimezone;
@@ -787,19 +787,19 @@  discard block
 block discarded – undo
787 787
 			$ident_result = $row['fammarine_id'];
788 788
 		}
789 789
 		return $ident_result;
790
-        }
790
+		}
791 791
 
792 792
 	/**
793
-	* Adds a new spotter data
794
-	*
795
-	* @param String $fammarine_id the ID from flightaware
796
-	* @param String $ident the flight ident
797
-	* @param String $aircraft_icao the aircraft type
798
-	* @param String $departure_airport_icao the departure airport
799
-	* @param String $arrival_airport_icao the arrival airport
800
-	* @return String success or false
801
-	*
802
-	*/
793
+	 * Adds a new spotter data
794
+	 *
795
+	 * @param String $fammarine_id the ID from flightaware
796
+	 * @param String $ident the flight ident
797
+	 * @param String $aircraft_icao the aircraft type
798
+	 * @param String $departure_airport_icao the departure airport
799
+	 * @param String $arrival_airport_icao the arrival airport
800
+	 * @return String success or false
801
+	 *
802
+	 */
803 803
 	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
804 804
 	{
805 805
 		global $globalURL, $globalArchive, $globalDebug;
@@ -870,10 +870,10 @@  discard block
 block discarded – undo
870 870
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
871 871
 		
872 872
 
873
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
874
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
875
-            	if ($arrival_date == '') $arrival_date = NULL;
876
-            	$query = '';
873
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
874
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
875
+				if ($arrival_date == '') $arrival_date = NULL;
876
+				$query = '';
877 877
 		if ($globalArchive) {
878 878
 			if ($globalDebug) echo '-- Delete previous data -- ';
879 879
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 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];
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
119 119
 			}
120 120
 		}
121
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
121
+		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
122 122
 
123 123
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
124 124
 		if ($globalDBdriver == 'mysql') {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		} else {
128 128
 			$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;
129 129
 		}
130
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
130
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
131 131
 
132 132
 		return $spotter_array;
133 133
 	}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		global $globalDBdriver, $globalLiveInterval;
144 144
 		date_default_timezone_set('UTC');
145 145
 
146
-		$filter_query = $this->getFilter($filter,true,true);
146
+		$filter_query = $this->getFilter($filter, true, true);
147 147
 
148 148
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
149 149
 		if ($globalDBdriver == 'mysql') {
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		try {
158 158
 			$sth = $this->db->prepare($query);
159 159
 			$sth->execute();
160
-		} catch(PDOException $e) {
160
+		} catch (PDOException $e) {
161 161
 			echo $e->getMessage();
162 162
 			die;
163 163
 		}
@@ -177,15 +177,15 @@  discard block
 block discarded – undo
177 177
 		global $globalDBdriver, $globalLiveInterval;
178 178
 		date_default_timezone_set('UTC');
179 179
 
180
-		$filter_query = $this->getFilter($filter,true,true);
180
+		$filter_query = $this->getFilter($filter, true, true);
181 181
 
182 182
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
183 183
 		if ($globalDBdriver == 'mysql') {
184
-			$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
+			$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 
185 185
 			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' 
186 186
 			ORDER BY marine_live.fammarine_id, marine_live.date";
187 187
                 } else {
188
-			$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
+			$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 
189 189
 			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' 
190 190
 			ORDER BY marine_live.fammarine_id, marine_live.date";
191 191
 		}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     		try {
194 194
 			$sth = $this->db->prepare($query);
195 195
 			$sth->execute();
196
-		} catch(PDOException $e) {
196
+		} catch (PDOException $e) {
197 197
 			echo $e->getMessage();
198 198
 			die;
199 199
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	public function getLiveMarineCount($filter = array())
211 211
 	{
212 212
 		global $globalDBdriver, $globalLiveInterval;
213
-		$filter_query = $this->getFilter($filter,true,true);
213
+		$filter_query = $this->getFilter($filter, true, true);
214 214
 
215 215
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
216 216
 		if ($globalDBdriver == 'mysql') {
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		try {
222 222
 			$sth = $this->db->prepare($query);
223 223
 			$sth->execute();
224
-		} catch(PDOException $e) {
224
+		} catch (PDOException $e) {
225 225
 			echo $e->getMessage();
226 226
 			die;
227 227
 		}
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 		$filter_query = $this->getFilter($filter);
245 245
 
246 246
 		if (is_array($coord)) {
247
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
248
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
247
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
248
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
249
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
250
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
251 251
 		} else return array();
252 252
 		if ($globalDBdriver == 'mysql') {
253 253
 			$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;
@@ -272,17 +272,17 @@  discard block
 block discarded – undo
272 272
 		$filter_query = $this->getFilter($filter);
273 273
 
274 274
 		if (is_array($coord)) {
275
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
276
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
277
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
275
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
276
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
277
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
278
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
279 279
 		} else return array();
280 280
 		if ($globalDBdriver == 'mysql') {
281 281
 			$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 
282 282
 			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' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
283 283
 			ORDER BY marine_live.fammarine_id, marine_live.date";
284 284
 		} else {
285
-			$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 
285
+			$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 
286 286
 			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' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong."
287 287
 			ORDER BY marine_live.fammarine_id, marine_live.date";
288 288
 		}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
                 if ($interval == '1m')
332 332
                 {
333 333
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
334
-                } else if ($interval == '15m'){
334
+                } else if ($interval == '15m') {
335 335
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
336 336
                 } 
337 337
             }
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
340 340
         }
341 341
 
342
-                $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 
342
+                $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 
343 343
                    WHERE marine_live.latitude <> '' 
344 344
                                    AND marine_live.longitude <> '' 
345 345
                    ".$additional_query."
346 346
                    HAVING distance < :radius  
347 347
                                    ORDER BY distance";
348 348
 
349
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
349
+                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
350 350
 
351 351
                 return $spotter_array;
352 352
         }
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 		date_default_timezone_set('UTC');
365 365
 
366 366
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
367
-                $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';
367
+                $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';
368 368
 
369
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
369
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
370 370
 
371 371
 		return $spotter_array;
372 372
 	}
@@ -377,16 +377,16 @@  discard block
 block discarded – undo
377 377
 	* @return Array the spotter information
378 378
 	*
379 379
 	*/
380
-	public function getDateLiveMarineDataByIdent($ident,$date)
380
+	public function getDateLiveMarineDataByIdent($ident, $date)
381 381
 	{
382 382
 		$Marine = new Marine($this->db);
383 383
 		date_default_timezone_set('UTC');
384 384
 
385 385
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
386
-                $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';
386
+                $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';
387 387
 
388
-                $date = date('c',$date);
389
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
388
+                $date = date('c', $date);
389
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
390 390
 
391 391
 		return $spotter_array;
392 392
 	}
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
 		date_default_timezone_set('UTC');
404 404
 
405 405
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
406
-                $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';
406
+                $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';
407 407
 
408
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
408
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
409 409
 
410 410
 		return $spotter_array;
411 411
 	}
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
 	* @return Array the spotter information
417 417
 	*
418 418
 	*/
419
-	public function getDateLiveMarineDataById($id,$date)
419
+	public function getDateLiveMarineDataById($id, $date)
420 420
 	{
421 421
 		$Marine = new Marine($this->db);
422 422
 		date_default_timezone_set('UTC');
423 423
 
424 424
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
425
-                $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';
426
-                $date = date('c',$date);
427
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
425
+                $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';
426
+                $date = date('c', $date);
427
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
428 428
 
429 429
 		return $spotter_array;
430 430
 	}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	* @return Array the spotter information
437 437
 	*
438 438
 	*/
439
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
439
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
440 440
 	{
441 441
 		global $globalDBdriver, $globalLiveInterval;
442 442
 		date_default_timezone_set('UTC');
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 		try {
456 456
 			$sth = $this->db->prepare($query);
457 457
 			$sth->execute(array(':id' => $id));
458
-		} catch(PDOException $e) {
458
+		} catch (PDOException $e) {
459 459
 			echo $e->getMessage();
460 460
 			die;
461 461
 		}
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
 	{
474 474
 		date_default_timezone_set('UTC');
475 475
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
476
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
476
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
477 477
     		try {
478 478
 			
479 479
 			$sth = $this->db->prepare($query);
480 480
 			$sth->execute(array(':ident' => $ident));
481
-		} catch(PDOException $e) {
481
+		} catch (PDOException $e) {
482 482
 			echo $e->getMessage();
483 483
 			die;
484 484
 		}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 			
509 509
 			$sth = $this->db->prepare($query);
510 510
 			$sth->execute();
511
-		} catch(PDOException $e) {
511
+		} catch (PDOException $e) {
512 512
 			return "error";
513 513
 		}
514 514
 
@@ -531,14 +531,14 @@  discard block
 block discarded – undo
531 531
 				
532 532
 				$sth = $this->db->prepare($query);
533 533
 				$sth->execute();
534
-			} catch(PDOException $e) {
534
+			} catch (PDOException $e) {
535 535
 				return "error";
536 536
 			}
537 537
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
538 538
                         $i = 0;
539
-                        $j =0;
539
+                        $j = 0;
540 540
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
541
-			foreach($all as $row)
541
+			foreach ($all as $row)
542 542
 			{
543 543
 				$i++;
544 544
 				$j++;
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 					if ($globalDebug) echo ".";
547 547
 				    	try {
548 548
 						
549
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
549
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
550 550
 						$sth->execute();
551
-					} catch(PDOException $e) {
551
+					} catch (PDOException $e) {
552 552
 						return "error";
553 553
 					}
554 554
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 			if ($i > 0) {
560 560
     				try {
561 561
 					
562
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
562
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
563 563
 					$sth->execute();
564
-				} catch(PDOException $e) {
564
+				} catch (PDOException $e) {
565 565
 					return "error";
566 566
 				}
567 567
 			}
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 				
575 575
 				$sth = $this->db->prepare($query);
576 576
 				$sth->execute();
577
-			} catch(PDOException $e) {
577
+			} catch (PDOException $e) {
578 578
 				return "error";
579 579
 			}
580 580
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
 	public function deleteLiveMarineDataByIdent($ident)
623 623
 	{
624 624
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
625
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
625
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
626 626
         
627 627
     		try {
628 628
 			
629 629
 			$sth = $this->db->prepare($query);
630 630
 			$sth->execute(array(':ident' => $ident));
631
-		} catch(PDOException $e) {
631
+		} catch (PDOException $e) {
632 632
 			return "error";
633 633
 		}
634 634
 
@@ -644,13 +644,13 @@  discard block
 block discarded – undo
644 644
 	public function deleteLiveMarineDataById($id)
645 645
 	{
646 646
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
647
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
647
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
648 648
         
649 649
     		try {
650 650
 			
651 651
 			$sth = $this->db->prepare($query);
652 652
 			$sth->execute(array(':id' => $id));
653
-		} catch(PDOException $e) {
653
+		} catch (PDOException $e) {
654 654
 			return "error";
655 655
 		}
656 656
 
@@ -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 FROM marine_live 
671
+			$query = 'SELECT marine_live.ident FROM marine_live 
672 672
 				WHERE marine_live.ident = :ident 
673 673
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
674 674
 				AND marine_live.date < UTC_TIMESTAMP()';
675 675
 			$query_data = array(':ident' => $ident);
676 676
 		} else {
677
-			$query  = "SELECT marine_live.ident FROM marine_live 
677
+			$query = "SELECT marine_live.ident FROM marine_live 
678 678
 				WHERE marine_live.ident = :ident 
679 679
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
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['ident'];
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.ident = :ident 
706 706
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
707 707
 //				AND marine_live.date < UTC_TIMESTAMP()";
708 708
 			$query_data = array(':ident' => $ident);
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.ident = :ident 
712 712
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
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.ident, marine_live.fammarine_id FROM marine_live 
737
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
738 738
 				WHERE marine_live.fammarine_id = :id 
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(':id' => $id);
742 742
 		} else {
743
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
743
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
744 744
 				WHERE marine_live.fammarine_id = :id 
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
 		}
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
 	{
768 768
 		global $globalDBdriver, $globalTimezone;
769 769
 		if ($globalDBdriver == 'mysql') {
770
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
770
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
771 771
 				WHERE marine_live.mmsi = :mmsi 
772 772
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
773 773
 //				AND marine_live.date < UTC_TIMESTAMP()";
774 774
 			$query_data = array(':mmsi' => $mmsi);
775 775
 		} else {
776
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
776
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
777 777
 				WHERE marine_live.mmsi = :mmsi 
778 778
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
779 779
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
 		
783 783
 		$sth = $this->db->prepare($query);
784 784
 		$sth->execute($query_data);
785
-		$ident_result='';
786
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
785
+		$ident_result = '';
786
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
787 787
 		{
788 788
 			$ident_result = $row['fammarine_id'];
789 789
 		}
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 	* @return String success or false
802 802
 	*
803 803
 	*/
804
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
804
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
805 805
 	{
806 806
 		global $globalURL, $globalArchive, $globalDebug;
807 807
 		$Common = new Common();
@@ -853,26 +853,26 @@  discard block
 block discarded – undo
853 853
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
854 854
 
855 855
         
856
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
857
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
858
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
859
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
860
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
861
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
862
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
863
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
864
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
865
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
866
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
867
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
868
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
869
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
870
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
871
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
856
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
857
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
858
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
859
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
860
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
861
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
862
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
863
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
864
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
865
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
866
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
867
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
868
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
869
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
870
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
871
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
872 872
 		
873 873
 
874
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
875
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
874
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
875
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
876 876
             	if ($arrival_date == '') $arrival_date = NULL;
877 877
             	$query = '';
878 878
 		if ($globalArchive) {
@@ -882,18 +882,18 @@  discard block
 block discarded – undo
882 882
 		$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) 
883 883
 		    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)';
884 884
 
885
-		$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);
885
+		$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);
886 886
 		try {
887 887
 			$sth = $this->db->prepare($query);
888 888
 			$sth->execute($query_values);
889
-		} catch(PDOException $e) {
889
+		} catch (PDOException $e) {
890 890
 			return "error : ".$e->getMessage();
891 891
 		}
892 892
 		
893 893
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
894 894
 			if ($globalDebug) echo '(Add to Marine archive : ';
895 895
 			$MarineArchive = new MarineArchive($this->db);
896
-			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country);
896
+			$result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country);
897 897
 			if ($globalDebug) echo $result.')';
898 898
 		}
899 899
 		return "success";
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 
902 902
 	public function getOrderBy()
903 903
 	{
904
-		$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"));
904
+		$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"));
905 905
 		return $orderby;
906 906
 	}
907 907
 
Please login to merge, or discard this patch.
Braces   +77 added lines, -26 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
 		}
@@ -118,9 +123,13 @@  discard block
 block discarded – undo
118 123
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
119 124
 			}
120 125
 		}
121
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
126
+		if ($orderby_query == '') {
127
+			$orderby_query= ' ORDER BY date DESC';
128
+		}
122 129
 
123
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
130
+		if (!isset($globalLiveInterval)) {
131
+			$globalLiveInterval = '200';
132
+		}
124 133
 		if ($globalDBdriver == 'mysql') {
125 134
 			//$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";
126 135
 			$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;
@@ -145,7 +154,9 @@  discard block
 block discarded – undo
145 154
 
146 155
 		$filter_query = $this->getFilter($filter,true,true);
147 156
 
148
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
157
+		if (!isset($globalLiveInterval)) {
158
+			$globalLiveInterval = '200';
159
+		}
149 160
 		if ($globalDBdriver == 'mysql') {
150 161
 			$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 
151 162
 			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";
@@ -179,7 +190,9 @@  discard block
 block discarded – undo
179 190
 
180 191
 		$filter_query = $this->getFilter($filter,true,true);
181 192
 
182
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
193
+		if (!isset($globalLiveInterval)) {
194
+			$globalLiveInterval = '200';
195
+		}
183 196
 		if ($globalDBdriver == 'mysql') {
184 197
 			$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 
185 198
 			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' 
@@ -212,7 +225,9 @@  discard block
 block discarded – undo
212 225
 		global $globalDBdriver, $globalLiveInterval;
213 226
 		$filter_query = $this->getFilter($filter,true,true);
214 227
 
215
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
228
+		if (!isset($globalLiveInterval)) {
229
+			$globalLiveInterval = '200';
230
+		}
216 231
 		if ($globalDBdriver == 'mysql') {
217 232
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
218 233
 		} else {
@@ -240,7 +255,9 @@  discard block
 block discarded – undo
240 255
 	{
241 256
 		global $globalDBdriver, $globalLiveInterval;
242 257
 		$Spotter = new Spotter($this->db);
243
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
258
+		if (!isset($globalLiveInterval)) {
259
+			$globalLiveInterval = '200';
260
+		}
244 261
 		$filter_query = $this->getFilter($filter);
245 262
 
246 263
 		if (is_array($coord)) {
@@ -248,7 +265,9 @@  discard block
 block discarded – undo
248 265
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249 266
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250 267
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
251
-		} else return array();
268
+		} else {
269
+			return array();
270
+		}
252 271
 		if ($globalDBdriver == 'mysql') {
253 272
 			$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;
254 273
 		} else {
@@ -268,7 +287,9 @@  discard block
 block discarded – undo
268 287
 	{
269 288
 		global $globalDBdriver, $globalLiveInterval;
270 289
 		$Spotter = new Spotter($this->db);
271
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
290
+		if (!isset($globalLiveInterval)) {
291
+			$globalLiveInterval = '200';
292
+		}
272 293
 		$filter_query = $this->getFilter($filter);
273 294
 
274 295
 		if (is_array($coord)) {
@@ -276,7 +297,9 @@  discard block
 block discarded – undo
276 297
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
277 298
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278 299
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
279
-		} else return array();
300
+		} else {
301
+			return array();
302
+		}
280 303
 		if ($globalDBdriver == 'mysql') {
281 304
 			$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 
282 305
 			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' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
@@ -444,11 +467,15 @@  discard block
 block discarded – undo
444 467
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
445 468
 		if ($globalDBdriver == 'mysql') {
446 469
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
447
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
470
+			if ($liveinterval) {
471
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
472
+			}
448 473
 			$query .= ' ORDER BY date';
449 474
 		} else {
450 475
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
451
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
476
+			if ($liveinterval) {
477
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
478
+			}
452 479
 			$query .= ' ORDER BY date';
453 480
 		}
454 481
 
@@ -543,7 +570,9 @@  discard block
 block discarded – undo
543 570
 				$i++;
544 571
 				$j++;
545 572
 				if ($j == 30) {
546
-					if ($globalDebug) echo ".";
573
+					if ($globalDebug) {
574
+						echo ".";
575
+					}
547 576
 				    	try {
548 577
 						
549 578
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -823,7 +852,9 @@  discard block
 block discarded – undo
823 852
 			{
824 853
 				return false;
825 854
 			}
826
-		} else return '';
855
+		} else {
856
+			return '';
857
+		}
827 858
 
828 859
 		if ($longitude != '')
829 860
 		{
@@ -831,7 +862,9 @@  discard block
 block discarded – undo
831 862
 			{
832 863
 				return false;
833 864
 			}
834
-		} else return '';
865
+		} else {
866
+			return '';
867
+		}
835 868
 
836 869
 
837 870
 		if ($heading != '')
@@ -840,7 +873,9 @@  discard block
 block discarded – undo
840 873
 			{
841 874
 				return false;
842 875
 			}
843
-		} else $heading = 0;
876
+		} else {
877
+			$heading = 0;
878
+		}
844 879
 
845 880
 		if ($groundspeed != '')
846 881
 		{
@@ -848,9 +883,13 @@  discard block
 block discarded – undo
848 883
 			{
849 884
 				return false;
850 885
 			}
851
-		} else $groundspeed = 0;
886
+		} else {
887
+			$groundspeed = 0;
888
+		}
852 889
 		date_default_timezone_set('UTC');
853
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
890
+		if ($date == '') {
891
+			$date = date("Y-m-d H:i:s", time());
892
+		}
854 893
 
855 894
         
856 895
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -871,12 +910,20 @@  discard block
 block discarded – undo
871 910
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
872 911
 		
873 912
 
874
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
875
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
876
-            	if ($arrival_date == '') $arrival_date = NULL;
913
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
914
+            		$groundspeed = 0;
915
+            	}
916
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
917
+            		$heading = 0;
918
+            	}
919
+            	if ($arrival_date == '') {
920
+            		$arrival_date = NULL;
921
+            	}
877 922
             	$query = '';
878 923
 		if ($globalArchive) {
879
-			if ($globalDebug) echo '-- Delete previous data -- ';
924
+			if ($globalDebug) {
925
+				echo '-- Delete previous data -- ';
926
+			}
880 927
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
881 928
 		}
882 929
 		$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) 
@@ -891,10 +938,14 @@  discard block
 block discarded – undo
891 938
 		}
892 939
 		
893 940
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
894
-			if ($globalDebug) echo '(Add to Marine archive : ';
941
+			if ($globalDebug) {
942
+				echo '(Add to Marine archive : ';
943
+			}
895 944
 			$MarineArchive = new MarineArchive($this->db);
896 945
 			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country);
897
-			if ($globalDebug) echo $result.')';
946
+			if ($globalDebug) {
947
+				echo $result.')';
948
+			}
898 949
 		}
899 950
 		return "success";
900 951
 	}
Please login to merge, or discard this patch.