Completed
Push — master ( cc50d0...0f8c33 )
by Yannick
09:46
created
require/class.AIS.php 2 patches
Doc Comments   +22 added lines patch added patch discarded remove patch
@@ -68,6 +68,10 @@  discard block
 block discarded – undo
68 68
        't', 'u', 'v', 'w' // 119
69 69
     ); // char 64
70 70
     */
71
+
72
+	/**
73
+	 * @param integer $ascii
74
+	 */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73 77
 		if ($ascii < 48) { }
@@ -93,6 +97,10 @@  discard block
 block discarded – undo
93 97
 		return(substr($bin, -6)); 
94 98
 	}
95 99
 
100
+	/**
101
+	 * @param integer $_start
102
+	 * @param integer $_size
103
+	 */
96 104
 	private function binchar($_str, $_start, $_size) {
97 105
 		//  ' ' --- '?', // 0x20 - 0x3F
98 106
 		//  '@' --- '_', // 0x40 - 0x5F
@@ -117,6 +125,10 @@  discard block
 block discarded – undo
117 125
 	}
118 126
 
119 127
 	// function for decoding the AIS Message ITU Payload
128
+
129
+	/**
130
+	 * @param string $_aisdata
131
+	 */
120 132
 	private function decode_ais($_aisdata) {
121 133
 		$ro = new stdClass(); // return object
122 134
 		$ro->cls = 0; // AIS class undefined, also indicate unparsed msg
@@ -202,6 +214,12 @@  discard block
 block discarded – undo
202 214
 		}
203 215
 	}
204 216
 
217
+	/**
218
+	 * @param string $_itu
219
+	 * @param integer $_len
220
+	 * @param integer $_filler
221
+	 * @param string $aux
222
+	 */
205 223
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
206 224
 		global $port; // tcpip port...
207 225
 		
@@ -221,6 +239,10 @@  discard block
 block discarded – undo
221 239
 
222 240
 	// char* - AIS \r terminated string
223 241
 	// TCP based streams which send messages in full can use this instead of calling process_ais_buf
242
+
243
+	/**
244
+	 * @param string $rawdata
245
+	 */
224 246
 	public function process_ais_raw($rawdata, $aux = '') { // return int
225 247
 		static $num_seq; // 1 to 9
226 248
 		static $seq; // 1 to 9
Please login to merge, or discard this patch.
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
 
30 30
 	private function make_latf($temp) { // unsigned long 
31 31
 		$flat; // float
32
-		$temp = $temp & 0x07FFFFFF;
33
-		if ($temp & 0x04000000) {
34
-			$temp = $temp ^ 0x07FFFFFF;
32
+		$temp = $temp&0x07FFFFFF;
33
+		if ($temp&0x04000000) {
34
+			$temp = $temp^0x07FFFFFF;
35 35
 			$temp += 1;
36
-			$flat = (float)($temp / (60.0 * 10000.0));
36
+			$flat = (float) ($temp/(60.0*10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else $flat = (float) ($temp/(60.0*10000.0));
39 39
 		return $flat; // float
40 40
 	}
41 41
 
42 42
 	private function make_lonf($temp) { // unsigned long
43 43
 		$flon; // float
44
-		$temp = $temp & 0x0FFFFFFF;
45
-		if ($temp & 0x08000000) {
46
-			$temp = $temp ^ 0x0FFFFFFF;
44
+		$temp = $temp&0x0FFFFFFF;
45
+		if ($temp&0x08000000) {
46
+			$temp = $temp^0x0FFFFFFF;
47 47
 			$temp += 1;
48
-			$flon = (float)($temp / (60.0 * 10000.0));
48
+			$flon = (float) ($temp/(60.0*10000.0));
49 49
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
50
+		} else $flon = (float) ($temp/(60.0*10000.0));
51 51
 		return $flon;
52 52
 	}
53 53
 
54 54
 	private function ascii_2_dec($chr) {
55
-		$dec=ord($chr);//get decimal ascii code
56
-		$hex=dechex($dec);//convert decimal to hex
55
+		$dec = ord($chr); //get decimal ascii code
56
+		$hex = dechex($dec); //convert decimal to hex
57 57
 		return ($dec);
58 58
 	}
59 59
 	
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 		//only process in the following range: 48-87, 96-119
73 73
 		if ($ascii < 48) { }
74 74
 		else {
75
-			if($ascii>119) { }
75
+			if ($ascii > 119) { }
76 76
 			else {
77
-				if ($ascii>87 && $ascii<96) ;
77
+				if ($ascii > 87 && $ascii < 96);
78 78
 				else {
79
-					$ascii=$ascii+40;
80
-					if ($ascii>128){
81
-						$ascii=$ascii+32;
79
+					$ascii = $ascii + 40;
80
+					if ($ascii > 128) {
81
+						$ascii = $ascii + 32;
82 82
 					} else {
83
-						$ascii=$ascii+40;
83
+						$ascii = $ascii + 40;
84 84
 					}
85 85
 				}
86 86
 			}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	}
90 90
 
91 91
 	private function dec_2_6bit($dec) {
92
-		$bin=decbin($dec);
92
+		$bin = decbin($dec);
93 93
 		return(substr($bin, -6)); 
94 94
 	}
95 95
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 		    '<', '=', '>', '?'
107 107
 		);
108 108
 		$rv = '';
109
-		if ($_size % 6 == 0) {
110
-			$len = $_size / 6;
111
-			for ($i=0; $i<$len; $i++) {
112
-				$offset = $i * 6;
113
-				$rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ];
109
+		if ($_size%6 == 0) {
110
+			$len = $_size/6;
111
+			for ($i = 0; $i < $len; $i++) {
112
+				$offset = $i*6;
113
+				$rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))];
114 114
 			}
115 115
 		}
116 116
 		return $rv;
@@ -127,40 +127,40 @@  discard block
 block discarded – undo
127 127
 		$ro->lon = 0.0;
128 128
 		$ro->lat = 0.0;
129 129
 		$ro->ts = time();
130
-		$ro->id = bindec(substr($_aisdata,0,6));
131
-		$ro->mmsi = bindec(substr($_aisdata,8,30));
130
+		$ro->id = bindec(substr($_aisdata, 0, 6));
131
+		$ro->mmsi = bindec(substr($_aisdata, 8, 30));
132 132
 		if ($ro->id >= 1 && $ro->id <= 3) {
133
-			$ro->cog = bindec(substr($_aisdata,116,12))/10;
134
-			$ro->sog = bindec(substr($_aisdata,50,10))/10;
135
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
136
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
133
+			$ro->cog = bindec(substr($_aisdata, 116, 12))/10;
134
+			$ro->sog = bindec(substr($_aisdata, 50, 10))/10;
135
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
136
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
137 137
 			$ro->cls = 1; // class A
138 138
 		} else if ($ro->id == 5) {
139 139
 			//$imo = bindec(substr($_aisdata,40,30));
140 140
 			//$cs = $this->binchar($_aisdata,70,42);
141
-			$ro->name = $this->binchar($_aisdata,112,120);
141
+			$ro->name = $this->binchar($_aisdata, 112, 120);
142 142
 			$ro->cls = 1; // class A
143 143
 		} else if ($ro->id == 18) {
144
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
145
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
146
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
147
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
144
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
145
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
146
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28)));
147
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27)));
148 148
 			$ro->cls = 2; // class B
149 149
 		} else if ($ro->id == 19) {
150
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
151
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
152
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
153
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
154
-			$ro->name = $this->binchar($_aisdata,143,120);
150
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
151
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
152
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
153
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
154
+			$ro->name = $this->binchar($_aisdata, 143, 120);
155 155
 			$ro->cls = 2; // class B
156 156
 		} else if ($ro->id == 24) {
157
-			$pn = bindec(substr($_aisdata,38,2));
157
+			$pn = bindec(substr($_aisdata, 38, 2));
158 158
 			if ($pn == 0) {
159
-				$ro->name = $this->binchar($_aisdata,40,120);
159
+				$ro->name = $this->binchar($_aisdata, 40, 120);
160 160
 			}
161 161
 			$ro->cls = 2; // class B
162 162
 		}
163
-		$ro->statusid = bindec(substr($_aisdata,38,4));
163
+		$ro->statusid = bindec(substr($_aisdata, 38, 4));
164 164
 		$ro->status = $this->getStatus($ro->statusid);
165 165
 		//var_dump($ro); // dump results here for demo purpose
166 166
 		return $ro;
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 		global $port; // tcpip port...
207 207
 		
208 208
 		static $debug_counter = 0;
209
-		$aisdata168='';//six bit array of ascii characters
209
+		$aisdata168 = ''; //six bit array of ascii characters
210 210
 		$ais_nmea_array = str_split($_itu); // convert to an array
211 211
 		foreach ($ais_nmea_array as $value) {
212 212
 			$dec = $this->ascii_2_dec($value);
213 213
 			$bit8 = $this->asciidec_2_8bit($dec);
214 214
 			$bit6 = $this->dec_2_6bit($bit8);
215 215
 			//echo $value ."-" .$bit6 ."";
216
-			$aisdata168 .=$bit6;
216
+			$aisdata168 .= $bit6;
217 217
 		}
218 218
 		//echo $aisdata168 . "<br/>";
219 219
 		return $this->decode_ais($aisdata168, $aux);
@@ -235,20 +235,20 @@  discard block
 block discarded – undo
235 235
 		// calculate checksum after ! till *
236 236
 		// assume 1st ! is valid
237 237
 		// find * ensure that it is at correct position
238
-		$end = strrpos ( $rawdata , '*' );
238
+		$end = strrpos($rawdata, '*');
239 239
 		if ($end === FALSE) return -1; // check for NULLS!!!
240
-		$cs = substr( $rawdata, $end + 1 );
241
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
242
-		$dcs = (int)hexdec( $cs );
243
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
244
-		if ( $chksum == $dcs ) { // NMEA checksum pass
240
+		$cs = substr($rawdata, $end + 1);
241
+		if (strlen($cs) != 2) return -1; // correct cs length
242
+		$dcs = (int) hexdec($cs);
243
+		for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum
244
+		if ($chksum == $dcs) { // NMEA checksum pass
245 245
 			$pcs = explode(',', $rawdata);
246 246
 			// !AI??? identifier
247
-			$num_seq = (int)$pcs[1]; // number of sequences
248
-			$seq = (int)$pcs[2]; // get sequence
247
+			$num_seq = (int) $pcs[1]; // number of sequences
248
+			$seq = (int) $pcs[2]; // get sequence
249 249
 			// get msg sequence id
250 250
 			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
251
-			else $msg_sid = (int)$pcs[3]; // multipart message
251
+			else $msg_sid = (int) $pcs[3]; // multipart message
252 252
 			$ais_ch = $pcs[4]; // get AIS channel
253 253
 			// message sequence checking
254 254
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 					}
282 282
 				}
283 283
 				$itu = $itu.$pcs[5]; // get itu message
284
-				$filler += (int)$pcs[6][0]; // get filler
284
+				$filler += (int) $pcs[6][0]; // get filler
285 285
 				if ($num_seq == 1 // valid single message
286 286
 				    || $num_seq == $pseq // valid multi-part message
287 287
 				) {
@@ -301,13 +301,13 @@  discard block
 block discarded – undo
301 301
 		$cbuf = $cbuf.$ibuf;
302 302
 		$last_pos = 0;
303 303
 		$result = new stdClass();
304
-		while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) {
304
+		while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) {
305 305
 		//while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) {
306 306
 			//DEBUG echo $cbuf;
307
-			if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim?
307
+			if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim?
308 308
 				$tst = substr($cbuf, $start - 3, ($end - $start + 3));
309 309
 				//DEBUG echo "[$start $end $tst]\n";
310
-				$result = $this->process_ais_raw( $tst, "" );
310
+				$result = $this->process_ais_raw($tst, "");
311 311
 				$last_pos = $end + 1;
312 312
 			} else break;
313 313
 		}
@@ -319,41 +319,41 @@  discard block
 block discarded – undo
319 319
 	// incoming data from serial or IP comms
320 320
 	public function process_ais_line($cbuf) {
321 321
 		$result = new stdClass();
322
-		$start = strpos($cbuf,"VDM");
322
+		$start = strpos($cbuf, "VDM");
323 323
 		$tst = substr($cbuf, $start - 3);
324
-		$result = $this->process_ais_raw( $tst, "" );
324
+		$result = $this->process_ais_raw($tst, "");
325 325
 		return $result;
326 326
 	}
327 327
 
328 328
 	/* AIS Encoding
329 329
 	*/
330
-	private function mk_ais_lat( $lat ) {
330
+	private function mk_ais_lat($lat) {
331 331
 		//$lat = 1.2569;
332
-		if ($lat<0.0) {
332
+		if ($lat < 0.0) {
333 333
 			$lat = -$lat;
334
-			$neg=true;
335
-		} else $neg=false;
334
+			$neg = true;
335
+		} else $neg = false;
336 336
 		$latd = 0x00000000;
337
-		$latd = intval ($lat * 600000.0);
338
-		if ($neg==true) {
337
+		$latd = intval($lat*600000.0);
338
+		if ($neg == true) {
339 339
 			$latd = ~$latd;
340
-			$latd+=1;
340
+			$latd += 1;
341 341
 			$latd &= 0x07FFFFFF;
342 342
 		}
343 343
 		return $latd;
344 344
 	}
345 345
 
346
-	private function mk_ais_lon( $lon ) {
346
+	private function mk_ais_lon($lon) {
347 347
 		//$lon = 103.851;
348
-		if ($lon<0.0) {
348
+		if ($lon < 0.0) {
349 349
 			$lon = -$lon;
350
-			$neg=true;
351
-		} else $neg=false;
350
+			$neg = true;
351
+		} else $neg = false;
352 352
 		$lond = 0x00000000;
353
-		$lond = intval ($lon * 600000.0);
354
-		if ($neg==true) {
353
+		$lond = intval($lon*600000.0);
354
+		if ($neg == true) {
355 355
 			$lond = ~$lond;
356
-			$lond+=1;
356
+			$lond += 1;
357 357
 			$lond &= 0x0FFFFFFF;
358 358
 		}
359 359
 		return $lond;
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
 
362 362
 	private function char2bin($name, $max_len) {
363 363
 		$len = strlen($name);
364
-		if ($len > $max_len) $name = substr($name,0,$max_len);
365
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
364
+		if ($len > $max_len) $name = substr($name, 0, $max_len);
365
+		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6);
366 366
 		else $pad = '';
367 367
 		$rv = '';
368 368
 		$ais_chars = array(
@@ -378,26 +378,26 @@  discard block
 block discarded – undo
378 378
 		if ($_a) foreach ($_a as $_1) {
379 379
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
380 380
 			else $dec = 0;
381
-			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
381
+			$bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT);
382 382
 			$rv .= $bin;
383 383
 			//echo "$_1 $dec ($bin)<br/>";
384 384
 		}
385 385
 		return $rv.$pad;
386 386
 	}
387 387
 
388
-	private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') {
388
+	private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') {
389 389
 		$len_bit = strlen($_enc);
390
-		$rem6 = $len_bit % 6;
390
+		$rem6 = $len_bit%6;
391 391
 		$pad6_len = 0;
392 392
 		if ($rem6) $pad6_len = 6 - $rem6;
393 393
 		//echo  $pad6_len.'<br>';
394 394
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
395
-		$len_enc = strlen($_enc) / 6;
395
+		$len_enc = strlen($_enc)/6;
396 396
 		//echo $_enc.' '.$len_enc.'<br/>';
397 397
 		$itu = '';
398
-		for ($i=0; $i<$len_enc; $i++) {
399
-			$offset = $i * 6;
400
-			$dec = bindec(substr($_enc,$offset,6));
398
+		for ($i = 0; $i < $len_enc; $i++) {
399
+			$offset = $i*6;
400
+			$dec = bindec(substr($_enc, $offset, 6));
401 401
 			if ($dec < 40) $dec += 48;
402 402
 			else $dec += 56;
403 403
 			//echo chr($dec)." $dec<br/>";
@@ -407,15 +407,15 @@  discard block
 block discarded – undo
407 407
 		$chksum = 0;
408 408
 		$itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0";
409 409
 		$len_itu = strlen($itu);
410
-		for ($i=0; $i<$len_itu; $i++) {
411
-			$chksum ^= ord( $itu[$i] );
410
+		for ($i = 0; $i < $len_itu; $i++) {
411
+			$chksum ^= ord($itu[$i]);
412 412
 		}
413
-		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
414
-		$lsb = $chksum & 0x0F;
415
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
413
+		$hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
414
+		$lsb = $chksum&0x0F;
415
+		if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb];
416 416
 		else $lsbc = '0';
417
-		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
418
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
417
+		$msb = (($chksum&0xF0) >> 4)&0x0F;
418
+		if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb];
419 419
 		else $msbc = '0';
420 420
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
421 421
 		return $itu;
@@ -441,13 +441,13 @@  discard block
 block discarded – undo
441 441
 	public function parse_line($buffer) {
442 442
 		$result = array();
443 443
 		$data = new stdClass();
444
-		$start = strpos($buffer,"VDM");
444
+		$start = strpos($buffer, "VDM");
445 445
 		$tst = substr($buffer, $start - 3);
446
-		$data = $this->process_ais_raw( $tst, "" );
446
+		$data = $this->process_ais_raw($tst, "");
447 447
 		if (!is_object($data)) return array();
448 448
 		if ($data->lon != 0) $result['longitude'] = $data->lon;
449 449
 		if ($data->lat != 0) $result['latitude'] = $data->lat;
450
-		$result['ident'] = trim(str_replace('@','',$data->name));
450
+		$result['ident'] = trim(str_replace('@', '', $data->name));
451 451
 		$result['timestamp'] = $data->ts;
452 452
 		$result['mmsi'] = $data->mmsi;
453 453
 		if ($data->sog != -1.0) $result['speed'] = $data->sog;
Please login to merge, or discard this patch.
require/class.Connection.php 2 patches
Doc Comments   +20 added lines patch added patch discarded remove patch
@@ -6,6 +6,9 @@  discard block
 block discarded – undo
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 37;
8 8
 	
9
+	/**
10
+	 * @param string $dbname
11
+	 */
9 12
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10 13
 	    global $globalDBdriver;
11 14
 	    if ($dbc === null) {
@@ -132,6 +135,9 @@  discard block
 block discarded – undo
132 135
 		return true;
133 136
 	}
134 137
 
138
+	/**
139
+	 * @param string $table
140
+	 */
135 141
 	public function tableExists($table)
136 142
 	{
137 143
 		global $globalDBdriver, $globalDBname;
@@ -181,6 +187,11 @@  discard block
 block discarded – undo
181 187
 	/*
182 188
 	* Check if index exist
183 189
 	*/
190
+
191
+	/**
192
+	 * @param string $table
193
+	 * @param string $index
194
+	 */
184 195
 	public function indexExists($table,$index)
185 196
 	{
186 197
 		global $globalDBdriver, $globalDBname;
@@ -223,6 +234,10 @@  discard block
 block discarded – undo
223 234
 		return $columns;
224 235
 	}
225 236
 
237
+	/**
238
+	 * @param string $table
239
+	 * @param string $column
240
+	 */
226 241
 	public function getColumnType($table,$column) {
227 242
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
228 243
 		$tomet = $select->getColumnMeta(0);
@@ -233,6 +248,11 @@  discard block
 block discarded – undo
233 248
 	* Check if a column name exist in a table
234 249
 	* @return Boolean column exist or not
235 250
 	*/
251
+
252
+	/**
253
+	 * @param string $table
254
+	 * @param string $name
255
+	 */
236 256
 	public function checkColumnName($table,$name)
237 257
 	{
238 258
 		global $globalDBdriver, $globalDBname;
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 
4
-class Connection{
4
+class Connection {
5 5
 	public $db = null;
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 37;
8 8
 	
9
-	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
9
+	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) {
10 10
 	    global $globalDBdriver;
11 11
 	    if ($dbc === null) {
12 12
 		if ($this->db === null && $dbname === null) {
13 13
 		    if ($user === null && $pass === null) {
14 14
 			$this->createDBConnection();
15 15
 		    } else {
16
-			$this->createDBConnection(null,$user,$pass);
16
+			$this->createDBConnection(null, $user, $pass);
17 17
 		    }
18 18
 		} else {
19 19
 		    $this->createDBConnection($dbname);
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 		while (true) {
92 92
 			try {
93 93
 				if ($globalDBSdriver == 'mysql') {
94
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass);
94
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass);
95 95
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
96 96
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
97
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
98
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
99
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
100
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
101
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
97
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
98
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500);
99
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
100
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
101
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
102 102
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
103 103
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
104 104
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -108,19 +108,19 @@  discard block
 block discarded – undo
108 108
 					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"');
109 109
 					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"');
110 110
 				} else {
111
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass);
111
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass);
112 112
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
113 113
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
114
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
115
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
116
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
117
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
118
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
114
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
115
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200);
116
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
117
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
118
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
119 119
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
120 120
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
121 121
 				}
122 122
 				break;
123
-			} catch(PDOException $e) {
123
+			} catch (PDOException $e) {
124 124
 				$i++;
125 125
 				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
126 126
 				//exit;
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 		try {
145 145
 			//$Connection = new Connection();
146 146
 			$results = $this->db->query($query);
147
-		} catch(PDOException $e) {
147
+		} catch (PDOException $e) {
148 148
 			return false;
149 149
 		}
150
-		if($results->rowCount()>0) {
150
+		if ($results->rowCount() > 0) {
151 151
 		    return true; 
152 152
 		}
153 153
 		else return false;
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 			     return false;
169 169
 			}
170 170
 			
171
-		} catch(PDOException $e) {
172
-			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
171
+		} catch (PDOException $e) {
172
+			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
173 173
             			throw $e;
174 174
 	                }
175 175
 	                //echo 'error ! '.$e->getMessage();
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	/*
182 182
 	* Check if index exist
183 183
 	*/
184
-	public function indexExists($table,$index)
184
+	public function indexExists($table, $index)
185 185
 	{
186 186
 		global $globalDBdriver, $globalDBname;
187 187
 		if ($globalDBdriver == 'mysql') {
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 		try {
193 193
 			//$Connection = new Connection();
194 194
 			$results = $this->db->query($query);
195
-		} catch(PDOException $e) {
195
+		} catch (PDOException $e) {
196 196
 			return false;
197 197
 		}
198 198
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
199
-		if($nb[0]['nb'] > 0) {
199
+		if ($nb[0]['nb'] > 0) {
200 200
 			return true; 
201 201
 		}
202 202
 		else return false;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		$query = "SELECT * FROM ".$table." LIMIT 0";
212 212
 		try {
213 213
 			$results = $this->db->query($query);
214
-		} catch(PDOException $e) {
214
+		} catch (PDOException $e) {
215 215
 			return "error : ".$e->getMessage()."\n";
216 216
 		}
217 217
 		$columns = array();
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		return $columns;
224 224
 	}
225 225
 
226
-	public function getColumnType($table,$column) {
226
+	public function getColumnType($table, $column) {
227 227
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
228 228
 		$tomet = $select->getColumnMeta(0);
229 229
 		return $tomet['native_type'];
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	* Check if a column name exist in a table
234 234
 	* @return Boolean column exist or not
235 235
 	*/
236
-	public function checkColumnName($table,$name)
236
+	public function checkColumnName($table, $name)
237 237
 	{
238 238
 		global $globalDBdriver, $globalDBname;
239 239
 		if ($globalDBdriver == 'mysql') {
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 		}
244 244
 			try {
245 245
 				$sth = $this->db()->prepare($query);
246
-				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name));
247
-			} catch(PDOException $e) {
246
+				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name));
247
+			} catch (PDOException $e) {
248 248
 				echo "error : ".$e->getMessage()."\n";
249 249
 			}
250 250
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 				try {
284 284
 					$sth = $this->db->prepare($query);
285 285
 					$sth->execute();
286
-				} catch(PDOException $e) {
286
+				} catch (PDOException $e) {
287 287
 					return "error : ".$e->getMessage()."\n";
288 288
 				}
289 289
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
require/class.Marine.php 2 patches
Doc Comments   +2 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	* Get SQL query part for filter used
17 17
 	* @param Array $filter the filter
18
-	* @return Array the SQL part
18
+	* @return string the SQL part
19 19
 	*/
20 20
 	
21 21
 	public function getFilter($filter = array(),$where = false,$and = false) {
@@ -502,9 +502,6 @@  discard block
 block discarded – undo
502 502
 	/**
503 503
 	* Update ident spotter data
504 504
 	*
505
-	* @param String $flightaware_id the ID from flightaware
506
-	* @param String $ident the flight ident
507
-	* @return String success or false
508 505
 	*
509 506
 	*/	
510 507
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
@@ -526,10 +523,6 @@  discard block
 block discarded – undo
526 523
 	/**
527 524
 	* Update latest spotter data
528 525
 	*
529
-	* @param String $flightaware_id the ID from flightaware
530
-	* @param String $ident the flight ident
531
-	* @param String $arrival_airport_icao the arrival airport
532
-	* @return String success or false
533 526
 	*
534 527
 	*/	
535 528
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
@@ -551,28 +544,6 @@  discard block
 block discarded – undo
551 544
 	/**
552 545
 	* Adds a new spotter data
553 546
 	*
554
-	* @param String $flightaware_id the ID from flightaware
555
-	* @param String $ident the flight ident
556
-	* @param String $aircraft_icao the aircraft type
557
-	* @param String $departure_airport_icao the departure airport
558
-	* @param String $arrival_airport_icao the arrival airport
559
-	* @param String $latitude latitude of flight
560
-	* @param String $longitude latitude of flight
561
-	* @param String $waypoints waypoints of flight
562
-	* @param String $heading heading of flight
563
-	* @param String $groundspeed speed of flight
564
-	* @param String $date date of flight
565
-	* @param String $departure_airport_time departure time of flight
566
-	* @param String $arrival_airport_time arrival time of flight
567
-	* @param String $squawk squawk code of flight
568
-	* @param String $route_stop route stop of flight
569
-	* @param String $highlight highlight or not
570
-	* @param String $ModeS ModesS code of flight
571
-	* @param String $registration registration code of flight
572
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
573
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
574
-	* @param String $verticalrate vertival rate of flight
575
-	* @return String success or false
576 547
 	*/
577 548
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$status = '',$format_source = '', $source_name = '')
578 549
 	{
@@ -1442,7 +1413,7 @@  discard block
 block discarded – undo
1442 1413
 	/**
1443 1414
 	* Parses the direction degrees to working
1444 1415
 	*
1445
-	* @param Float $direction the direction in degrees
1416
+	* @param integer $direction the direction in degrees
1446 1417
 	* @return Array the direction information
1447 1418
 	*
1448 1419
 	*/
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT marine_output.* FROM marine_output";
6 6
 
7
-class Marine{
7
+class Marine {
8 8
 	public $db;
9 9
 	
10 10
 	public function __construct($dbc = null) {
@@ -18,33 +18,33 @@  discard block
 block discarded – undo
18 18
 	* @return Array the SQL part
19 19
 	*/
20 20
 	
21
-	public function getFilter($filter = array(),$where = false,$and = false) {
21
+	public function getFilter($filter = array(), $where = false, $and = false) {
22 22
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
23 23
 		$filters = array();
24 24
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
25 25
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
26 26
 				$filters = $globalStatsFilters[$globalFilterName];
27 27
 			} else {
28
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
28
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
29 29
 			}
30 30
 		}
31 31
 		if (isset($filter[0]['source'])) {
32
-			$filters = array_merge($filters,$filter);
32
+			$filters = array_merge($filters, $filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
35 35
 		$filter_query_join = '';
36 36
 		$filter_query_where = '';
37
-		foreach($filters as $flt) {
37
+		foreach ($filters as $flt) {
38 38
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
39 39
 				if (isset($flt['source'])) {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
41 41
 				} else {
42
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
42
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
43 43
 				}
44 44
 			}
45 45
 		}
46 46
 		if (isset($filter['source']) && !empty($filter['source'])) {
47
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
47
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
48 48
 		}
49 49
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
50 50
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74 74
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75 75
 		if ($filter_query_where != '') {
76
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
76
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
77 77
 		}
78 78
 		$filter_query = $filter_query_join.$filter_query_where;
79 79
 		return $filter_query;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	* @return Array the spotter information
89 89
 	*
90 90
 	*/
91
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
91
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
92 92
 	{
93 93
 		date_default_timezone_set('UTC');
94 94
 		if (!is_string($query))
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 			$sth = $this->db->prepare($query.$limitQuery);
109 109
 			$sth->execute($params);
110 110
 		} catch (PDOException $e) {
111
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
111
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
112 112
 			exit();
113 113
 		}
114 114
 		
115 115
 		$num_rows = 0;
116 116
 		$spotter_array = array();
117
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
117
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
118 118
 		{
119 119
 			$num_rows++;
120 120
 			$temp_array = array();
@@ -169,17 +169,17 @@  discard block
 block discarded – undo
169 169
 				{
170 170
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
171 171
 				} else {
172
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
172
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
173 173
 				}
174 174
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
175
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
176
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
175
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
176
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
177 177
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
178 178
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
179 179
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
180 180
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
181
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
182
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
181
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
182
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
183 183
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
184 184
 					}
185 185
 				}
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
 		{
217 217
 			$limit_array = explode(",", $limit);
218 218
 			
219
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
220
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
219
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
220
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
221 221
 			
222 222
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
223 223
 			{
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 			$orderby_query = " ORDER BY marine_output.date DESC";
235 235
 		}
236 236
 
237
-		$query  = $global_query.$filter_query." ".$orderby_query;
237
+		$query = $global_query.$filter_query." ".$orderby_query;
238 238
 
239
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
239
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
240 240
 
241 241
 		return $spotter_array;
242 242
 	}
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 		if ($id == '') return array();
256 256
 		$additional_query = "marine_output.fammarine_id = :id";
257 257
 		$query_values = array(':id' => $id);
258
-		$query  = $global_query." WHERE ".$additional_query." ";
259
-		$spotter_array = $this->getDataFromDB($query,$query_values);
258
+		$query = $global_query." WHERE ".$additional_query." ";
259
+		$spotter_array = $this->getDataFromDB($query, $query_values);
260 260
 		return $spotter_array;
261 261
 	}
262 262
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 		$query_values = array();
276 276
 		$limit_query = '';
277 277
 		$additional_query = '';
278
-		$filter_query = $this->getFilter($filter,true,true);
278
+		$filter_query = $this->getFilter($filter, true, true);
279 279
 		if ($ident != "")
280 280
 		{
281 281
 			if (!is_string($ident))
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 		{
292 292
 			$limit_array = explode(",", $limit);
293 293
 			
294
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
295
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
294
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
295
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
296 296
 			
297 297
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
298 298
 			{
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 		return $spotter_array;
317 317
 	}
318 318
 	
319
-	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
319
+	public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array())
320 320
 	{
321 321
 		global $global_query, $globalTimezone, $globalDBdriver;
322 322
 		
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		$limit_query = '';
325 325
 		$additional_query = '';
326 326
 
327
-		$filter_query = $this->getFilter($filter,true,true);
327
+		$filter_query = $this->getFilter($filter, true, true);
328 328
 		
329 329
 		if ($date != "")
330 330
 		{
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
 		{
351 351
 			$limit_array = explode(",", $limit);
352 352
 			
353
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
354
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
353
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
354
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
355 355
 			
356 356
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
357 357
 			{
@@ -382,11 +382,11 @@  discard block
 block discarded – undo
382 382
 	* @return Array list of source name
383 383
 	*
384 384
 	*/
385
-	public function getAllSourceName($type = '',$filters = array())
385
+	public function getAllSourceName($type = '', $filters = array())
386 386
 	{
387
-		$filter_query = $this->getFilter($filters,true,true);
387
+		$filter_query = $this->getFilter($filters, true, true);
388 388
 		$query_values = array();
389
-		$query  = "SELECT DISTINCT marine_output.source_name 
389
+		$query = "SELECT DISTINCT marine_output.source_name 
390 390
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
391 391
 		if ($type != '') {
392 392
 			$query_values = array(':type' => $type);
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 		$source_array = array();
402 402
 		$temp_array = array();
403 403
 		
404
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
404
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
405 405
 		{
406 406
 			$temp_array['source_name'] = $row['source_name'];
407 407
 			$source_array[] = $temp_array;
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	*/
419 419
 	public function getAllIdents($filters = array())
420 420
 	{
421
-		$filter_query = $this->getFilter($filters,true,true);
422
-		$query  = "SELECT DISTINCT marine_output.ident
421
+		$filter_query = $this->getFilter($filters, true, true);
422
+		$query = "SELECT DISTINCT marine_output.ident
423 423
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
424 424
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
425 425
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		$ident_array = array();
430 430
 		$temp_array = array();
431 431
 		
432
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
432
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
433 433
 		{
434 434
 			$temp_array['ident'] = $row['ident'];
435 435
 			$ident_array[] = $temp_array;
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 	*/
447 447
 	public function getIdentity($mmsi)
448 448
 	{
449
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
449
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
450 450
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
451 451
 		$sth = $this->db->prepare($query);
452 452
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -471,12 +471,12 @@  discard block
 block discarded – undo
471 471
 		} else $offset = '+00:00';
472 472
 
473 473
 		if ($globalDBdriver == 'mysql') {
474
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
474
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
475 475
 								FROM marine_output
476 476
 								WHERE marine_output.date <> '' 
477 477
 								ORDER BY marine_output.date ASC LIMIT 0,200";
478 478
 		} else {
479
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
479
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
480 480
 								FROM marine_output
481 481
 								WHERE marine_output.date <> '' 
482 482
 								ORDER BY marine_output.date ASC LIMIT 0,200";
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 		$date_array = array();
489 489
 		$temp_array = array();
490 490
 		
491
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
491
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
492 492
 		{
493 493
 			$temp_array['date'] = $row['date'];
494 494
 
@@ -507,11 +507,11 @@  discard block
 block discarded – undo
507 507
 	* @return String success or false
508 508
 	*
509 509
 	*/	
510
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
510
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
511 511
 	{
512 512
 
513 513
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
514
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
514
+                $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
515 515
 
516 516
 		try {
517 517
 			$sth = $this->db->prepare($query);
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
536 536
 	{
537 537
 		$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';
538
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
538
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
539 539
 
540 540
 		try {
541 541
 			$sth = $this->db->prepare($query);
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	* @param String $verticalrate vertival rate of flight
575 575
 	* @return String success or false
576 576
 	*/
577
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$status = '',$format_source = '', $source_name = '')
577
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $status = '', $format_source = '', $source_name = '')
578 578
 	{
579 579
 		global $globalURL;
580 580
 		
@@ -641,21 +641,21 @@  discard block
 block discarded – undo
641 641
 		}
642 642
 
643 643
     
644
-		if ($date == "" || strtotime($date) < time()-20*60)
644
+		if ($date == "" || strtotime($date) < time() - 20*60)
645 645
 		{
646 646
 			$date = date("Y-m-d H:i:s", time());
647 647
 		}
648 648
 
649
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
650
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
651
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
652
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
653
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
654
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
655
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
656
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
657
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
658
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
649
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
650
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
651
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
652
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
653
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
654
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
655
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
656
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
657
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
658
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
659 659
 	
660 660
                 if ($latitude == '' && $longitude == '') {
661 661
             		$latitude = 0;
@@ -663,10 +663,10 @@  discard block
 block discarded – undo
663 663
             	}
664 664
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
665 665
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
666
-                $query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status) 
666
+                $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status) 
667 667
                 VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status)";
668 668
 
669
-                $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);
669
+                $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);
670 670
 
671 671
 		try {
672 672
 		        
@@ -692,13 +692,13 @@  discard block
 block discarded – undo
692 692
 	{
693 693
 		global $globalDBdriver, $globalTimezone;
694 694
 		if ($globalDBdriver == 'mysql') {
695
-			$query  = "SELECT marine_output.ident FROM marine_output 
695
+			$query = "SELECT marine_output.ident FROM marine_output 
696 696
 								WHERE marine_output.ident = :ident 
697 697
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
698 698
 								AND marine_output.date < UTC_TIMESTAMP()";
699 699
 			$query_data = array(':ident' => $ident);
700 700
 		} else {
701
-			$query  = "SELECT marine_output.ident FROM marine_output 
701
+			$query = "SELECT marine_output.ident FROM marine_output 
702 702
 								WHERE marine_output.ident = :ident 
703 703
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
704 704
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -707,8 +707,8 @@  discard block
 block discarded – undo
707 707
 		
708 708
 		$sth = $this->db->prepare($query);
709 709
 		$sth->execute($query_data);
710
-    		$ident_result='';
711
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
710
+    		$ident_result = '';
711
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
712 712
 		{
713 713
 			$ident_result = $row['ident'];
714 714
 		}
@@ -734,8 +734,8 @@  discard block
 block discarded – undo
734 734
 				return false;
735 735
 			} else {
736 736
 				$q_array = explode(" ", $q);
737
-				foreach ($q_array as $q_item){
738
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
737
+				foreach ($q_array as $q_item) {
738
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
739 739
 					$additional_query .= " AND (";
740 740
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
741 741
 					$additional_query .= ")";
@@ -743,11 +743,11 @@  discard block
 block discarded – undo
743 743
 			}
744 744
 		}
745 745
 		if ($globalDBdriver == 'mysql') {
746
-			$query  = "SELECT marine_output.* FROM marine_output 
746
+			$query = "SELECT marine_output.* FROM marine_output 
747 747
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
748 748
 				AND marine_output.date < UTC_TIMESTAMP()";
749 749
 		} else {
750
-			$query  = "SELECT marine_output.* FROM marine_output 
750
+			$query = "SELECT marine_output.* FROM marine_output 
751 751
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
752 752
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
753 753
 		}
@@ -820,11 +820,11 @@  discard block
 block discarded – undo
820 820
 	* @return Array the callsign list
821 821
 	*
822 822
 	*/
823
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
823
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
824 824
 	{
825 825
 		global $globalDBdriver;
826
-		$filter_query = $this->getFilter($filters,true,true);
827
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
826
+		$filter_query = $this->getFilter($filters, true, true);
827
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
828 828
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
829 829
 		 if ($olderthanmonths > 0) {
830 830
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -838,28 +838,28 @@  discard block
 block discarded – undo
838 838
 		if ($year != '') {
839 839
 			if ($globalDBdriver == 'mysql') {
840 840
 				$query .= " AND YEAR(marine_output.date) = :year";
841
-				$query_values = array_merge($query_values,array(':year' => $year));
841
+				$query_values = array_merge($query_values, array(':year' => $year));
842 842
 			} else {
843 843
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
844
-				$query_values = array_merge($query_values,array(':year' => $year));
844
+				$query_values = array_merge($query_values, array(':year' => $year));
845 845
 			}
846 846
 		}
847 847
 		if ($month != '') {
848 848
 			if ($globalDBdriver == 'mysql') {
849 849
 				$query .= " AND MONTH(marine_output.date) = :month";
850
-				$query_values = array_merge($query_values,array(':month' => $month));
850
+				$query_values = array_merge($query_values, array(':month' => $month));
851 851
 			} else {
852 852
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
853
-				$query_values = array_merge($query_values,array(':month' => $month));
853
+				$query_values = array_merge($query_values, array(':month' => $month));
854 854
 			}
855 855
 		}
856 856
 		if ($day != '') {
857 857
 			if ($globalDBdriver == 'mysql') {
858 858
 				$query .= " AND DAY(marine_output.date) = :day";
859
-				$query_values = array_merge($query_values,array(':day' => $day));
859
+				$query_values = array_merge($query_values, array(':day' => $day));
860 860
 			} else {
861 861
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
862
-				$query_values = array_merge($query_values,array(':day' => $day));
862
+				$query_values = array_merge($query_values, array(':day' => $day));
863 863
 			}
864 864
 		}
865 865
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 		$callsign_array = array();
872 872
 		$temp_array = array();
873 873
         
874
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
874
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
875 875
 		{
876 876
 			$temp_array['callsign_icao'] = $row['ident'];
877 877
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 		$date_array = array();
924 924
 		$temp_array = array();
925 925
         
926
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
926
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
927 927
 		{
928 928
 			$temp_array['date_name'] = $row['date_name'];
929 929
 			$temp_array['date_count'] = $row['date_count'];
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 			$datetime = new DateTime();
950 950
 			$offset = $datetime->format('P');
951 951
 		} else $offset = '+00:00';
952
-		$filter_query = $this->getFilter($filters,true,true);
952
+		$filter_query = $this->getFilter($filters, true, true);
953 953
 		if ($globalDBdriver == 'mysql') {
954 954
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
955 955
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
 		$date_array = array();
971 971
 		$temp_array = array();
972 972
         
973
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
973
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
974 974
 		{
975 975
 			$temp_array['date_name'] = $row['date_name'];
976 976
 			$temp_array['date_count'] = $row['date_count'];
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 			$datetime = new DateTime();
996 996
 			$offset = $datetime->format('P');
997 997
 		} else $offset = '+00:00';
998
-		$filter_query = $this->getFilter($filters,true,true);
998
+		$filter_query = $this->getFilter($filters, true, true);
999 999
 		if ($globalDBdriver == 'mysql') {
1000 1000
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1001 1001
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
 		$date_array = array();
1017 1017
 		$temp_array = array();
1018 1018
         
1019
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1019
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1020 1020
 		{
1021 1021
 			$temp_array['date_name'] = $row['date_name'];
1022 1022
 			$temp_array['date_count'] = $row['date_count'];
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 		$date_array = array();
1064 1064
 		$temp_array = array();
1065 1065
         
1066
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1066
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1067 1067
 		{
1068 1068
 			$temp_array['month_name'] = $row['month_name'];
1069 1069
 			$temp_array['year_name'] = $row['year_name'];
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 			$datetime = new DateTime();
1093 1093
 			$offset = $datetime->format('P');
1094 1094
 		} else $offset = '+00:00';
1095
-		$filter_query = $this->getFilter($filters,true,true);
1095
+		$filter_query = $this->getFilter($filters, true, true);
1096 1096
 		if ($globalDBdriver == 'mysql') {
1097 1097
 			$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
1098 1098
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 		$date_array = array();
1114 1114
 		$temp_array = array();
1115 1115
         
1116
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1116
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1117 1117
 		{
1118 1118
 			$temp_array['year_name'] = $row['year_name'];
1119 1119
 			$temp_array['month_name'] = $row['month_name'];
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 	* @return Array the hour list
1134 1134
 	*
1135 1135
 	*/
1136
-	public function countAllHours($orderby,$filters = array())
1136
+	public function countAllHours($orderby, $filters = array())
1137 1137
 	{
1138 1138
 		global $globalTimezone, $globalDBdriver;
1139 1139
 		if ($globalTimezone != '') {
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 		$hour_array = array();
1182 1182
 		$temp_array = array();
1183 1183
         
1184
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1184
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1185 1185
 		{
1186 1186
 			$temp_array['hour_name'] = $row['hour_name'];
1187 1187
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1203,8 +1203,8 @@  discard block
 block discarded – undo
1203 1203
 	public function countAllHoursByDate($date, $filters = array())
1204 1204
 	{
1205 1205
 		global $globalTimezone, $globalDBdriver;
1206
-		$filter_query = $this->getFilter($filters,true,true);
1207
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1206
+		$filter_query = $this->getFilter($filters, true, true);
1207
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1208 1208
 		if ($globalTimezone != '') {
1209 1209
 			date_default_timezone_set($globalTimezone);
1210 1210
 			$datetime = new DateTime($date);
@@ -1212,12 +1212,12 @@  discard block
 block discarded – undo
1212 1212
 		} else $offset = '+00:00';
1213 1213
 
1214 1214
 		if ($globalDBdriver == 'mysql') {
1215
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1215
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1216 1216
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1217 1217
 								GROUP BY hour_name 
1218 1218
 								ORDER BY hour_name ASC";
1219 1219
 		} else {
1220
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1220
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1221 1221
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1222 1222
 								GROUP BY hour_name 
1223 1223
 								ORDER BY hour_name ASC";
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 		$hour_array = array();
1230 1230
 		$temp_array = array();
1231 1231
         
1232
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1232
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1233 1233
 		{
1234 1234
 			$temp_array['hour_name'] = $row['hour_name'];
1235 1235
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1251,8 +1251,8 @@  discard block
 block discarded – undo
1251 1251
 	public function countAllHoursByIdent($ident, $filters = array())
1252 1252
 	{
1253 1253
 		global $globalTimezone, $globalDBdriver;
1254
-		$filter_query = $this->getFilter($filters,true,true);
1255
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1254
+		$filter_query = $this->getFilter($filters, true, true);
1255
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1256 1256
 		if ($globalTimezone != '') {
1257 1257
 			date_default_timezone_set($globalTimezone);
1258 1258
 			$datetime = new DateTime();
@@ -1260,12 +1260,12 @@  discard block
 block discarded – undo
1260 1260
 		} else $offset = '+00:00';
1261 1261
 
1262 1262
 		if ($globalDBdriver == 'mysql') {
1263
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1263
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1264 1264
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1265 1265
 								GROUP BY hour_name 
1266 1266
 								ORDER BY hour_name ASC";
1267 1267
 		} else {
1268
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1268
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1269 1269
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1270 1270
 								GROUP BY hour_name 
1271 1271
 								ORDER BY hour_name ASC";
@@ -1273,12 +1273,12 @@  discard block
 block discarded – undo
1273 1273
       
1274 1274
 		
1275 1275
 		$sth = $this->db->prepare($query);
1276
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1276
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1277 1277
       
1278 1278
 		$hour_array = array();
1279 1279
 		$temp_array = array();
1280 1280
         
1281
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1281
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1282 1282
 		{
1283 1283
 			$temp_array['hour_name'] = $row['hour_name'];
1284 1284
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1297,32 +1297,32 @@  discard block
 block discarded – undo
1297 1297
 	* @return Integer the number of flights
1298 1298
 	*
1299 1299
 	*/
1300
-	public function countOverallTracked($filters = array(),$year = '',$month = '')
1300
+	public function countOverallTracked($filters = array(), $year = '', $month = '')
1301 1301
 	{
1302 1302
 		global $globalDBdriver;
1303
-		$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1303
+		$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1304 1304
 		$query_values = array();
1305 1305
 		$query = '';
1306 1306
 		if ($year != '') {
1307 1307
 			if ($globalDBdriver == 'mysql') {
1308 1308
 				$query .= " AND YEAR(marine_output.date) = :year";
1309
-				$query_values = array_merge($query_values,array(':year' => $year));
1309
+				$query_values = array_merge($query_values, array(':year' => $year));
1310 1310
 			} else {
1311 1311
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1312
-				$query_values = array_merge($query_values,array(':year' => $year));
1312
+				$query_values = array_merge($query_values, array(':year' => $year));
1313 1313
 			}
1314 1314
 		}
1315 1315
 		if ($month != '') {
1316 1316
 			if ($globalDBdriver == 'mysql') {
1317 1317
 				$query .= " AND MONTH(marine_output.date) = :month";
1318
-				$query_values = array_merge($query_values,array(':month' => $month));
1318
+				$query_values = array_merge($query_values, array(':month' => $month));
1319 1319
 			} else {
1320 1320
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1321
-				$query_values = array_merge($query_values,array(':month' => $month));
1321
+				$query_values = array_merge($query_values, array(':month' => $month));
1322 1322
 			}
1323 1323
 		}
1324 1324
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1325
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1325
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1326 1326
 		
1327 1327
 		$sth = $this->db->prepare($queryi);
1328 1328
 		$sth->execute($query_values);
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 	public function countAllHoursFromToday($filters = array())
1340 1340
 	{
1341 1341
 		global $globalTimezone, $globalDBdriver;
1342
-		$filter_query = $this->getFilter($filters,true,true);
1342
+		$filter_query = $this->getFilter($filters, true, true);
1343 1343
 		if ($globalTimezone != '') {
1344 1344
 			date_default_timezone_set($globalTimezone);
1345 1345
 			$datetime = new DateTime();
@@ -1347,12 +1347,12 @@  discard block
 block discarded – undo
1347 1347
 		} else $offset = '+00:00';
1348 1348
 
1349 1349
 		if ($globalDBdriver == 'mysql') {
1350
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1350
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1351 1351
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1352 1352
 								GROUP BY hour_name 
1353 1353
 								ORDER BY hour_name ASC";
1354 1354
 		} else {
1355
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1355
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1356 1356
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1357 1357
 								GROUP BY hour_name 
1358 1358
 								ORDER BY hour_name ASC";
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
 		$hour_array = array();
1365 1365
 		$temp_array = array();
1366 1366
         
1367
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1367
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1368 1368
 		{
1369 1369
 			$temp_array['hour_name'] = $row['hour_name'];
1370 1370
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1383,9 +1383,9 @@  discard block
 block discarded – undo
1383 1383
 	*/
1384 1384
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1385 1385
 	{
1386
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1386
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1387 1387
 
1388
-		$query  = "SELECT marine_output.marine_id
1388
+		$query = "SELECT marine_output.marine_id
1389 1389
 				FROM marine_output 
1390 1390
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1391 1391
         
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
 		$sth = $this->db->prepare($query);
1394 1394
 		$sth->execute();
1395 1395
 
1396
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1396
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1397 1397
 		{
1398 1398
 			return $row['marine_id'];
1399 1399
 		}
@@ -1418,23 +1418,23 @@  discard block
 block discarded – undo
1418 1418
 		}
1419 1419
 		
1420 1420
 		$current_date = date("Y-m-d H:i:s");
1421
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1421
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1422 1422
 		
1423 1423
 		$diff = abs(strtotime($current_date) - strtotime($date));
1424 1424
 
1425
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1425
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1426 1426
 		$years = $time_array['years'];
1427 1427
 		
1428
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1428
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1429 1429
 		$months = $time_array['months'];
1430 1430
 		
1431
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1431
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1432 1432
 		$days = $time_array['days'];
1433
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1433
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1434 1434
 		$hours = $time_array['hours'];
1435
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1435
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1436 1436
 		$minutes = $time_array['minutes'];
1437
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1437
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1438 1438
 		
1439 1439
 		return $time_array;
1440 1440
 	}
@@ -1457,63 +1457,63 @@  discard block
 block discarded – undo
1457 1457
 			$temp_array['direction_degree'] = $direction;
1458 1458
 			$temp_array['direction_shortname'] = "N";
1459 1459
 			$temp_array['direction_fullname'] = "North";
1460
-		} elseif ($direction >= 22.5 && $direction < 45){
1460
+		} elseif ($direction >= 22.5 && $direction < 45) {
1461 1461
 			$temp_array['direction_degree'] = $direction;
1462 1462
 			$temp_array['direction_shortname'] = "NNE";
1463 1463
 			$temp_array['direction_fullname'] = "North-Northeast";
1464
-		} elseif ($direction >= 45 && $direction < 67.5){
1464
+		} elseif ($direction >= 45 && $direction < 67.5) {
1465 1465
 			$temp_array['direction_degree'] = $direction;
1466 1466
 			$temp_array['direction_shortname'] = "NE";
1467 1467
 			$temp_array['direction_fullname'] = "Northeast";
1468
-		} elseif ($direction >= 67.5 && $direction < 90){
1468
+		} elseif ($direction >= 67.5 && $direction < 90) {
1469 1469
 			$temp_array['direction_degree'] = $direction;
1470 1470
 			$temp_array['direction_shortname'] = "ENE";
1471 1471
 			$temp_array['direction_fullname'] = "East-Northeast";
1472
-		} elseif ($direction >= 90 && $direction < 112.5){
1472
+		} elseif ($direction >= 90 && $direction < 112.5) {
1473 1473
 			$temp_array['direction_degree'] = $direction;
1474 1474
 			$temp_array['direction_shortname'] = "E";
1475 1475
 			$temp_array['direction_fullname'] = "East";
1476
-		} elseif ($direction >= 112.5 && $direction < 135){
1476
+		} elseif ($direction >= 112.5 && $direction < 135) {
1477 1477
 			$temp_array['direction_degree'] = $direction;
1478 1478
 			$temp_array['direction_shortname'] = "ESE";
1479 1479
 			$temp_array['direction_fullname'] = "East-Southeast";
1480
-		} elseif ($direction >= 135 && $direction < 157.5){
1480
+		} elseif ($direction >= 135 && $direction < 157.5) {
1481 1481
 			$temp_array['direction_degree'] = $direction;
1482 1482
 			$temp_array['direction_shortname'] = "SE";
1483 1483
 			$temp_array['direction_fullname'] = "Southeast";
1484
-		} elseif ($direction >= 157.5 && $direction < 180){
1484
+		} elseif ($direction >= 157.5 && $direction < 180) {
1485 1485
 			$temp_array['direction_degree'] = $direction;
1486 1486
 			$temp_array['direction_shortname'] = "SSE";
1487 1487
 			$temp_array['direction_fullname'] = "South-Southeast";
1488
-		} elseif ($direction >= 180 && $direction < 202.5){
1488
+		} elseif ($direction >= 180 && $direction < 202.5) {
1489 1489
 			$temp_array['direction_degree'] = $direction;
1490 1490
 			$temp_array['direction_shortname'] = "S";
1491 1491
 			$temp_array['direction_fullname'] = "South";
1492
-		} elseif ($direction >= 202.5 && $direction < 225){
1492
+		} elseif ($direction >= 202.5 && $direction < 225) {
1493 1493
 			$temp_array['direction_degree'] = $direction;
1494 1494
 			$temp_array['direction_shortname'] = "SSW";
1495 1495
 			$temp_array['direction_fullname'] = "South-Southwest";
1496
-		} elseif ($direction >= 225 && $direction < 247.5){
1496
+		} elseif ($direction >= 225 && $direction < 247.5) {
1497 1497
 			$temp_array['direction_degree'] = $direction;
1498 1498
 			$temp_array['direction_shortname'] = "SW";
1499 1499
 			$temp_array['direction_fullname'] = "Southwest";
1500
-		} elseif ($direction >= 247.5 && $direction < 270){
1500
+		} elseif ($direction >= 247.5 && $direction < 270) {
1501 1501
 			$temp_array['direction_degree'] = $direction;
1502 1502
 			$temp_array['direction_shortname'] = "WSW";
1503 1503
 			$temp_array['direction_fullname'] = "West-Southwest";
1504
-		} elseif ($direction >= 270 && $direction < 292.5){
1504
+		} elseif ($direction >= 270 && $direction < 292.5) {
1505 1505
 			$temp_array['direction_degree'] = $direction;
1506 1506
 			$temp_array['direction_shortname'] = "W";
1507 1507
 			$temp_array['direction_fullname'] = "West";
1508
-		} elseif ($direction >= 292.5 && $direction < 315){
1508
+		} elseif ($direction >= 292.5 && $direction < 315) {
1509 1509
 			$temp_array['direction_degree'] = $direction;
1510 1510
 			$temp_array['direction_shortname'] = "WNW";
1511 1511
 			$temp_array['direction_fullname'] = "West-Northwest";
1512
-		} elseif ($direction >= 315 && $direction < 337.5){
1512
+		} elseif ($direction >= 315 && $direction < 337.5) {
1513 1513
 			$temp_array['direction_degree'] = $direction;
1514 1514
 			$temp_array['direction_shortname'] = "NW";
1515 1515
 			$temp_array['direction_fullname'] = "Northwest";
1516
-		} elseif ($direction >= 337.5 && $direction < 360){
1516
+		} elseif ($direction >= 337.5 && $direction < 360) {
1517 1517
 			$temp_array['direction_degree'] = $direction;
1518 1518
 			$temp_array['direction_shortname'] = "NNW";
1519 1519
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1530,11 +1530,11 @@  discard block
 block discarded – undo
1530 1530
 	* @param Float $longitude longitute of the flight
1531 1531
 	* @return String the countrie
1532 1532
 	*/
1533
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1533
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1534 1534
 	{
1535 1535
 		global $globalDBdriver, $globalDebug;
1536
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1537
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1536
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1537
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1538 1538
 	
1539 1539
 		$Connection = new Connection($this->db);
1540 1540
 		if (!$Connection->tableExists('countries')) return '';
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
 	public function getCountryFromISO2($iso2)
1575 1575
 	{
1576 1576
 		global $globalDBdriver, $globalDebug;
1577
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1577
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1578 1578
 	
1579 1579
 		$Connection = new Connection($this->db);
1580 1580
 		if (!$Connection->tableExists('countries')) return '';
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
 		
1623 1623
 		$bitly_data = json_decode($bitly_data);
1624 1624
 		$bitly_url = '';
1625
-		if ($bitly_data->status_txt = "OK"){
1625
+		if ($bitly_data->status_txt = "OK") {
1626 1626
 			$bitly_url = $bitly_data->data->url;
1627 1627
 		}
1628 1628
 
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 
1633 1633
 	public function getOrderBy()
1634 1634
 	{
1635
-		$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"));
1635
+		$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"));
1636 1636
 		
1637 1637
 		return $orderby;
1638 1638
 		
Please login to merge, or discard this patch.
require/class.MarineLive.php 2 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;
@@ -762,10 +762,6 @@  discard block
 block discarded – undo
762 762
 	*
763 763
 	* @param String $fammarine_id the ID from flightaware
764 764
 	* @param String $ident the flight ident
765
-	* @param String $aircraft_icao the aircraft type
766
-	* @param String $departure_airport_icao the departure airport
767
-	* @param String $arrival_airport_icao the arrival airport
768
-	* @return String success or false
769 765
 	*
770 766
 	*/
771 767
 	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
Please login to merge, or discard this patch.
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
72 72
 				}
73 73
 			}
74
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
74
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
75 75
 		}
76 76
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
77
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
78 78
 		}
79 79
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80 80
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81 81
 		if ($filter_query_where != '') {
82
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
82
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
83 83
 		}
84 84
 		$filter_query = $filter_query_join.$filter_query_where;
85 85
 		return $filter_query;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		if ($limit != '')
103 103
 		{
104 104
 			$limit_array = explode(',', $limit);
105
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
106
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
105
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
107 107
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
108 108
 			{
109 109
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		} else {
127 127
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
128 128
 		}
129
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
129
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
130 130
 
131 131
 		return $spotter_array;
132 132
 	}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		global $globalDBdriver, $globalLiveInterval;
143 143
 		date_default_timezone_set('UTC');
144 144
 
145
-		$filter_query = $this->getFilter($filter,true,true);
145
+		$filter_query = $this->getFilter($filter, true, true);
146 146
 
147 147
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
148 148
 		if ($globalDBdriver == 'mysql') {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 		try {
157 157
 			$sth = $this->db->prepare($query);
158 158
 			$sth->execute();
159
-		} catch(PDOException $e) {
159
+		} catch (PDOException $e) {
160 160
 			echo $e->getMessage();
161 161
 			die;
162 162
 		}
@@ -176,15 +176,15 @@  discard block
 block discarded – undo
176 176
 		global $globalDBdriver, $globalLiveInterval;
177 177
 		date_default_timezone_set('UTC');
178 178
 
179
-		$filter_query = $this->getFilter($filter,true,true);
179
+		$filter_query = $this->getFilter($filter, true, true);
180 180
 
181 181
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
182 182
 		if ($globalDBdriver == 'mysql') {
183
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
183
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184 184
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
185 185
 			ORDER BY marine_live.fammarine_id, marine_live.date";
186 186
                 } else {
187
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
187
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
188 188
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
189 189
 			ORDER BY marine_live.fammarine_id, marine_live.date";
190 190
 		}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     		try {
193 193
 			$sth = $this->db->prepare($query);
194 194
 			$sth->execute();
195
-		} catch(PDOException $e) {
195
+		} catch (PDOException $e) {
196 196
 			echo $e->getMessage();
197 197
 			die;
198 198
 		}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	public function getLiveMarineCount($filter = array())
210 210
 	{
211 211
 		global $globalDBdriver, $globalLiveInterval;
212
-		$filter_query = $this->getFilter($filter,true,true);
212
+		$filter_query = $this->getFilter($filter, true, true);
213 213
 
214 214
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
215 215
 		if ($globalDBdriver == 'mysql') {
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		try {
221 221
 			$sth = $this->db->prepare($query);
222 222
 			$sth->execute();
223
-		} catch(PDOException $e) {
223
+		} catch (PDOException $e) {
224 224
 			echo $e->getMessage();
225 225
 			die;
226 226
 		}
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 		$filter_query = $this->getFilter($filter);
244 244
 
245 245
 		if (is_array($coord)) {
246
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
247
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
248
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
246
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
247
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
248
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
249
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
250 250
 		} else return array();
251 251
 		if ($globalDBdriver == 'mysql') {
252 252
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
                 if ($interval == '1m')
299 299
                 {
300 300
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
301
-                } else if ($interval == '15m'){
301
+                } else if ($interval == '15m') {
302 302
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
303 303
                 } 
304 304
             }
@@ -306,14 +306,14 @@  discard block
 block discarded – undo
306 306
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
307 307
         }
308 308
 
309
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
309
+                $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
310 310
                    WHERE marine_live.latitude <> '' 
311 311
                                    AND marine_live.longitude <> '' 
312 312
                    ".$additional_query."
313 313
                    HAVING distance < :radius  
314 314
                                    ORDER BY distance";
315 315
 
316
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
316
+                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
317 317
 
318 318
                 return $spotter_array;
319 319
         }
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 		date_default_timezone_set('UTC');
332 332
 
333 333
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
334
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
334
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
335 335
 
336
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
336
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
337 337
 
338 338
 		return $spotter_array;
339 339
 	}
@@ -344,16 +344,16 @@  discard block
 block discarded – undo
344 344
 	* @return Array the spotter information
345 345
 	*
346 346
 	*/
347
-	public function getDateLiveMarineDataByIdent($ident,$date)
347
+	public function getDateLiveMarineDataByIdent($ident, $date)
348 348
 	{
349 349
 		$Marine = new Marine($this->db);
350 350
 		date_default_timezone_set('UTC');
351 351
 
352 352
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
353
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
353
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
354 354
 
355
-                $date = date('c',$date);
356
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
355
+                $date = date('c', $date);
356
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
357 357
 
358 358
 		return $spotter_array;
359 359
 	}
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
 		date_default_timezone_set('UTC');
371 371
 
372 372
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
373
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
373
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
374 374
 
375
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
375
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
376 376
 
377 377
 		return $spotter_array;
378 378
 	}
@@ -383,15 +383,15 @@  discard block
 block discarded – undo
383 383
 	* @return Array the spotter information
384 384
 	*
385 385
 	*/
386
-	public function getDateLiveMarineDataById($id,$date)
386
+	public function getDateLiveMarineDataById($id, $date)
387 387
 	{
388 388
 		$Marine = new Marine($this->db);
389 389
 		date_default_timezone_set('UTC');
390 390
 
391 391
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
392
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
393
-                $date = date('c',$date);
394
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
392
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
393
+                $date = date('c', $date);
394
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
395 395
 
396 396
 		return $spotter_array;
397 397
 	}
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	* @return Array the spotter information
404 404
 	*
405 405
 	*/
406
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
406
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
407 407
 	{
408 408
 		global $globalDBdriver, $globalLiveInterval;
409 409
 		date_default_timezone_set('UTC');
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 		try {
423 423
 			$sth = $this->db->prepare($query);
424 424
 			$sth->execute(array(':id' => $id));
425
-		} catch(PDOException $e) {
425
+		} catch (PDOException $e) {
426 426
 			echo $e->getMessage();
427 427
 			die;
428 428
 		}
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
 	{
441 441
 		date_default_timezone_set('UTC');
442 442
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
443
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
443
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
444 444
     		try {
445 445
 			
446 446
 			$sth = $this->db->prepare($query);
447 447
 			$sth->execute(array(':ident' => $ident));
448
-		} catch(PDOException $e) {
448
+		} catch (PDOException $e) {
449 449
 			echo $e->getMessage();
450 450
 			die;
451 451
 		}
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 			
476 476
 			$sth = $this->db->prepare($query);
477 477
 			$sth->execute();
478
-		} catch(PDOException $e) {
478
+		} catch (PDOException $e) {
479 479
 			return "error";
480 480
 		}
481 481
 
@@ -498,14 +498,14 @@  discard block
 block discarded – undo
498 498
 				
499 499
 				$sth = $this->db->prepare($query);
500 500
 				$sth->execute();
501
-			} catch(PDOException $e) {
501
+			} catch (PDOException $e) {
502 502
 				return "error";
503 503
 			}
504 504
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
505 505
                         $i = 0;
506
-                        $j =0;
506
+                        $j = 0;
507 507
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
508
-			foreach($all as $row)
508
+			foreach ($all as $row)
509 509
 			{
510 510
 				$i++;
511 511
 				$j++;
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
 					if ($globalDebug) echo ".";
514 514
 				    	try {
515 515
 						
516
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
516
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
517 517
 						$sth->execute();
518
-					} catch(PDOException $e) {
518
+					} catch (PDOException $e) {
519 519
 						return "error";
520 520
 					}
521 521
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
 			if ($i > 0) {
527 527
     				try {
528 528
 					
529
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
529
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
530 530
 					$sth->execute();
531
-				} catch(PDOException $e) {
531
+				} catch (PDOException $e) {
532 532
 					return "error";
533 533
 				}
534 534
 			}
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 				
542 542
 				$sth = $this->db->prepare($query);
543 543
 				$sth->execute();
544
-			} catch(PDOException $e) {
544
+			} catch (PDOException $e) {
545 545
 				return "error";
546 546
 			}
547 547
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -589,13 +589,13 @@  discard block
 block discarded – undo
589 589
 	public function deleteLiveMarineDataByIdent($ident)
590 590
 	{
591 591
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
592
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
592
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
593 593
         
594 594
     		try {
595 595
 			
596 596
 			$sth = $this->db->prepare($query);
597 597
 			$sth->execute(array(':ident' => $ident));
598
-		} catch(PDOException $e) {
598
+		} catch (PDOException $e) {
599 599
 			return "error";
600 600
 		}
601 601
 
@@ -611,13 +611,13 @@  discard block
 block discarded – undo
611 611
 	public function deleteLiveMarineDataById($id)
612 612
 	{
613 613
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
614
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
614
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
615 615
         
616 616
     		try {
617 617
 			
618 618
 			$sth = $this->db->prepare($query);
619 619
 			$sth->execute(array(':id' => $id));
620
-		} catch(PDOException $e) {
620
+		} catch (PDOException $e) {
621 621
 			return "error";
622 622
 		}
623 623
 
@@ -635,13 +635,13 @@  discard block
 block discarded – undo
635 635
 	{
636 636
 		global $globalDBdriver, $globalTimezone;
637 637
 		if ($globalDBdriver == 'mysql') {
638
-			$query  = 'SELECT marine_live.ident FROM marine_live 
638
+			$query = 'SELECT marine_live.ident FROM marine_live 
639 639
 				WHERE marine_live.ident = :ident 
640 640
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
641 641
 				AND marine_live.date < UTC_TIMESTAMP()';
642 642
 			$query_data = array(':ident' => $ident);
643 643
 		} else {
644
-			$query  = "SELECT marine_live.ident FROM marine_live 
644
+			$query = "SELECT marine_live.ident FROM marine_live 
645 645
 				WHERE marine_live.ident = :ident 
646 646
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
647 647
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -650,8 +650,8 @@  discard block
 block discarded – undo
650 650
 		
651 651
 		$sth = $this->db->prepare($query);
652 652
 		$sth->execute($query_data);
653
-		$ident_result='';
654
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
653
+		$ident_result = '';
654
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
655 655
 		{
656 656
 			$ident_result = $row['ident'];
657 657
 		}
@@ -668,13 +668,13 @@  discard block
 block discarded – undo
668 668
 	{
669 669
 		global $globalDBdriver, $globalTimezone;
670 670
 		if ($globalDBdriver == 'mysql') {
671
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
671
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
672 672
 				WHERE marine_live.ident = :ident 
673 673
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
674 674
 //				AND marine_live.date < UTC_TIMESTAMP()";
675 675
 			$query_data = array(':ident' => $ident);
676 676
 		} else {
677
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
677
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
678 678
 				WHERE marine_live.ident = :ident 
679 679
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
680 680
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
 		
684 684
 		$sth = $this->db->prepare($query);
685 685
 		$sth->execute($query_data);
686
-		$ident_result='';
687
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
686
+		$ident_result = '';
687
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
688 688
 		{
689 689
 			$ident_result = $row['fammarine_id'];
690 690
 		}
@@ -701,13 +701,13 @@  discard block
 block discarded – undo
701 701
 	{
702 702
 		global $globalDBdriver, $globalTimezone;
703 703
 		if ($globalDBdriver == 'mysql') {
704
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
704
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
705 705
 				WHERE marine_live.fammarine_id = :id 
706 706
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
707 707
 //				AND marine_live.date < UTC_TIMESTAMP()";
708 708
 			$query_data = array(':id' => $id);
709 709
 		} else {
710
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
710
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
711 711
 				WHERE marine_live.fammarine_id = :id 
712 712
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
713 713
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
 		
717 717
 		$sth = $this->db->prepare($query);
718 718
 		$sth->execute($query_data);
719
-		$ident_result='';
720
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
719
+		$ident_result = '';
720
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
721 721
 		{
722 722
 			$ident_result = $row['fammarine_id'];
723 723
 		}
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
736 736
 		if ($globalDBdriver == 'mysql') {
737
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
737
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
738 738
 				WHERE marine_live.mmsi = :mmsi 
739 739
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
740 740
 //				AND marine_live.date < UTC_TIMESTAMP()";
741 741
 			$query_data = array(':mmsi' => $mmsi);
742 742
 		} else {
743
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
743
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
744 744
 				WHERE marine_live.mmsi = :mmsi 
745 745
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
746 746
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-		$ident_result='';
753
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
752
+		$ident_result = '';
753
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['fammarine_id'];
756 756
 		}
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 	* @return String success or false
769 769
 	*
770 770
 	*/
771
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
771
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
772 772
 	{
773 773
 		global $globalURL, $globalArchive, $globalDebug;
774 774
 		$Common = new Common();
@@ -820,31 +820,31 @@  discard block
 block discarded – undo
820 820
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
821 821
 
822 822
         
823
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
824
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
825
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
826
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
827
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
828
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
829
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
830
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
831
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
832
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
833
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
834
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
835
-
836
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
837
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
823
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
824
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
825
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
826
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
827
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
828
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
829
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
830
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
831
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
832
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
833
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
834
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
835
+
836
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
837
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
838 838
             	
839
-		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status) 
839
+		$query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status) 
840 840
 		VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status)';
841 841
 
842
-		$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);
842
+		$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);
843 843
 		try {
844 844
 			
845 845
 			$sth = $this->db->prepare($query);
846 846
 			$sth->execute($query_values);
847
-                } catch(PDOException $e) {
847
+                } catch (PDOException $e) {
848 848
                 	return "error : ".$e->getMessage();
849 849
                 }
850 850
 		/*
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 
862 862
 	public function getOrderBy()
863 863
 	{
864
-		$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"));
864
+		$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"));
865 865
 		return $orderby;
866 866
 	}
867 867
 
Please login to merge, or discard this patch.
require/class.Tracker.php 2 patches
Doc Comments   +2 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	* Get SQL query part for filter used
17 17
 	* @param Array $filter the filter
18
-	* @return Array the SQL part
18
+	* @return string the SQL part
19 19
 	*/
20 20
 	
21 21
 	public function getFilter($filter = array(),$where = false,$and = false) {
@@ -486,9 +486,6 @@  discard block
 block discarded – undo
486 486
 	/**
487 487
 	* Update ident spotter data
488 488
 	*
489
-	* @param String $flightaware_id the ID from flightaware
490
-	* @param String $ident the flight ident
491
-	* @return String success or false
492 489
 	*
493 490
 	*/	
494 491
 	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
@@ -510,10 +507,6 @@  discard block
 block discarded – undo
510 507
 	/**
511 508
 	* Update latest spotter data
512 509
 	*
513
-	* @param String $flightaware_id the ID from flightaware
514
-	* @param String $ident the flight ident
515
-	* @param String $arrival_airport_icao the arrival airport
516
-	* @return String success or false
517 510
 	*
518 511
 	*/	
519 512
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
@@ -535,29 +528,6 @@  discard block
 block discarded – undo
535 528
 	/**
536 529
 	* Adds a new spotter data
537 530
 	*
538
-	* @param String $flightaware_id the ID from flightaware
539
-	* @param String $ident the flight ident
540
-	* @param String $aircraft_icao the aircraft type
541
-	* @param String $departure_airport_icao the departure airport
542
-	* @param String $arrival_airport_icao the arrival airport
543
-	* @param String $latitude latitude of flight
544
-	* @param String $longitude latitude of flight
545
-	* @param String $waypoints waypoints of flight
546
-	* @param String $altitude altitude of flight
547
-	* @param String $heading heading of flight
548
-	* @param String $groundspeed speed of flight
549
-	* @param String $date date of flight
550
-	* @param String $departure_airport_time departure time of flight
551
-	* @param String $arrival_airport_time arrival time of flight
552
-	* @param String $squawk squawk code of flight
553
-	* @param String $route_stop route stop of flight
554
-	* @param String $highlight highlight or not
555
-	* @param String $ModeS ModesS code of flight
556
-	* @param String $registration registration code of flight
557
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
558
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
559
-	* @param String $verticalrate vertival rate of flight
560
-	* @return String success or false
561 531
 	*/
562 532
 	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
563 533
 	{
@@ -1428,7 +1398,7 @@  discard block
 block discarded – undo
1428 1398
 	/**
1429 1399
 	* Parses the direction degrees to working
1430 1400
 	*
1431
-	* @param Float $direction the direction in degrees
1401
+	* @param integer $direction the direction in degrees
1432 1402
 	* @return Array the direction information
1433 1403
 	*
1434 1404
 	*/
Please login to merge, or discard this patch.
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT tracker_output.* FROM tracker_output";
6 6
 
7
-class Tracker{
7
+class Tracker {
8 8
 	public $db;
9 9
 	
10 10
 	public function __construct($dbc = null) {
@@ -18,33 +18,33 @@  discard block
 block discarded – undo
18 18
 	* @return Array the SQL part
19 19
 	*/
20 20
 	
21
-	public function getFilter($filter = array(),$where = false,$and = false) {
21
+	public function getFilter($filter = array(), $where = false, $and = false) {
22 22
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
23 23
 		$filters = array();
24 24
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
25 25
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
26 26
 				$filters = $globalStatsFilters[$globalFilterName];
27 27
 			} else {
28
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
28
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
29 29
 			}
30 30
 		}
31 31
 		if (isset($filter[0]['source'])) {
32
-			$filters = array_merge($filters,$filter);
32
+			$filters = array_merge($filters, $filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
35 35
 		$filter_query_join = '';
36 36
 		$filter_query_where = '';
37
-		foreach($filters as $flt) {
37
+		foreach ($filters as $flt) {
38 38
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
39 39
 				if (isset($flt['source'])) {
40
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
40
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
41 41
 				} else {
42
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
42
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
43 43
 				}
44 44
 			}
45 45
 		}
46 46
 		if (isset($filter['source']) && !empty($filter['source'])) {
47
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
47
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
48 48
 		}
49 49
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
50 50
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74 74
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75 75
 		if ($filter_query_where != '') {
76
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
76
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
77 77
 		}
78 78
 		$filter_query = $filter_query_join.$filter_query_where;
79 79
 		return $filter_query;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	* @return Array the spotter information
89 89
 	*
90 90
 	*/
91
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
91
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
92 92
 	{
93 93
 		date_default_timezone_set('UTC');
94 94
 		if (!is_string($query))
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 			$sth = $this->db->prepare($query.$limitQuery);
109 109
 			$sth->execute($params);
110 110
 		} catch (PDOException $e) {
111
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
111
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
112 112
 			exit();
113 113
 		}
114 114
 		
115 115
 		$num_rows = 0;
116 116
 		$spotter_array = array();
117
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
117
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
118 118
 		{
119 119
 			$num_rows++;
120 120
 			$temp_array = array();
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 				{
171 171
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
172 172
 				} else {
173
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
173
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
174 174
 				}
175 175
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
176
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
177
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
176
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
177
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
178 178
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
179 179
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
180 180
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
181 181
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
182
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
183
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
182
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
183
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
184 184
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
185 185
 					}
186 186
 				}
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 		{
218 218
 			$limit_array = explode(",", $limit);
219 219
 			
220
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
221
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
220
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
221
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
222 222
 			
223 223
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
224 224
 			{
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 			$orderby_query = " ORDER BY tracker_output.date DESC";
236 236
 		}
237 237
 
238
-		$query  = $global_query.$filter_query." ".$orderby_query;
238
+		$query = $global_query.$filter_query." ".$orderby_query;
239 239
 
240
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
240
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
241 241
 
242 242
 		return $spotter_array;
243 243
 	}
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 		if ($id == '') return array();
257 257
 		$additional_query = "tracker_output.famtrackid = :id";
258 258
 		$query_values = array(':id' => $id);
259
-		$query  = $global_query." WHERE ".$additional_query." ";
260
-		$spotter_array = $this->getDataFromDB($query,$query_values);
259
+		$query = $global_query." WHERE ".$additional_query." ";
260
+		$spotter_array = $this->getDataFromDB($query, $query_values);
261 261
 		return $spotter_array;
262 262
 	}
263 263
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 		$query_values = array();
277 277
 		$limit_query = '';
278 278
 		$additional_query = '';
279
-		$filter_query = $this->getFilter($filter,true,true);
279
+		$filter_query = $this->getFilter($filter, true, true);
280 280
 		if ($ident != "")
281 281
 		{
282 282
 			if (!is_string($ident))
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 		{
293 293
 			$limit_array = explode(",", $limit);
294 294
 			
295
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
296
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
295
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
296
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
297 297
 			
298 298
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
299 299
 			{
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		return $spotter_array;
318 318
 	}
319 319
 	
320
-	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
320
+	public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array())
321 321
 	{
322 322
 		global $global_query, $globalTimezone, $globalDBdriver;
323 323
 		
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		$limit_query = '';
326 326
 		$additional_query = '';
327 327
 
328
-		$filter_query = $this->getFilter($filter,true,true);
328
+		$filter_query = $this->getFilter($filter, true, true);
329 329
 		
330 330
 		if ($date != "")
331 331
 		{
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
 		{
352 352
 			$limit_array = explode(",", $limit);
353 353
 			
354
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
355
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
354
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
355
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
356 356
 			
357 357
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
358 358
 			{
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
 	* @return Array list of source name
384 384
 	*
385 385
 	*/
386
-	public function getAllSourceName($type = '',$filters = array())
386
+	public function getAllSourceName($type = '', $filters = array())
387 387
 	{
388
-		$filter_query = $this->getFilter($filters,true,true);
388
+		$filter_query = $this->getFilter($filters, true, true);
389 389
 		$query_values = array();
390
-		$query  = "SELECT DISTINCT tracker_output.source_name 
390
+		$query = "SELECT DISTINCT tracker_output.source_name 
391 391
 				FROM tracker_output".$filter_query." tracker_output.source_name <> ''";
392 392
 		if ($type != '') {
393 393
 			$query_values = array(':type' => $type);
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 		$source_array = array();
403 403
 		$temp_array = array();
404 404
 		
405
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
405
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
406 406
 		{
407 407
 			$temp_array['source_name'] = $row['source_name'];
408 408
 			$source_array[] = $temp_array;
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 	*/
420 420
 	public function getAllIdents($filters = array())
421 421
 	{
422
-		$filter_query = $this->getFilter($filters,true,true);
423
-		$query  = "SELECT DISTINCT tracker_output.ident
422
+		$filter_query = $this->getFilter($filters, true, true);
423
+		$query = "SELECT DISTINCT tracker_output.ident
424 424
 								FROM tracker_output".$filter_query." tracker_output.ident <> '' 
425 425
 								ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0";
426 426
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 		$ident_array = array();
431 431
 		$temp_array = array();
432 432
 		
433
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
433
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
434 434
 		{
435 435
 			$temp_array['ident'] = $row['ident'];
436 436
 			$ident_array[] = $temp_array;
@@ -455,12 +455,12 @@  discard block
 block discarded – undo
455 455
 		} else $offset = '+00:00';
456 456
 
457 457
 		if ($globalDBdriver == 'mysql') {
458
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
458
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
459 459
 								FROM tracker_output
460 460
 								WHERE tracker_output.date <> '' 
461 461
 								ORDER BY tracker_output.date ASC LIMIT 0,200";
462 462
 		} else {
463
-			$query  = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
463
+			$query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
464 464
 								FROM tracker_output
465 465
 								WHERE tracker_output.date <> '' 
466 466
 								ORDER BY tracker_output.date ASC LIMIT 0,200";
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 		$date_array = array();
473 473
 		$temp_array = array();
474 474
 		
475
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
475
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
476 476
 		{
477 477
 			$temp_array['date'] = $row['date'];
478 478
 
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
 	* @return String success or false
492 492
 	*
493 493
 	*/	
494
-	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
494
+	public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL)
495 495
 	{
496 496
 
497 497
 		$query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid';
498
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
498
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident);
499 499
 
500 500
 		try {
501 501
 			$sth = $this->db->prepare($query);
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
520 520
 	{
521 521
 		$query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid';
522
-                $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
522
+                $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
523 523
 
524 524
 		try {
525 525
 			$sth = $this->db->prepare($query);
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 	* @param String $verticalrate vertival rate of flight
560 560
 	* @return String success or false
561 561
 	*/
562
-	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
562
+	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '')
563 563
 	{
564 564
 		global $globalURL;
565 565
 		
@@ -627,21 +627,21 @@  discard block
 block discarded – undo
627 627
 		}
628 628
 
629 629
     
630
-		if ($date == "" || strtotime($date) < time()-20*60)
630
+		if ($date == "" || strtotime($date) < time() - 20*60)
631 631
 		{
632 632
 			$date = date("Y-m-d H:i:s", time());
633 633
 		}
634 634
 
635
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
636
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
637
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
638
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
639
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
640
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
641
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
642
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
643
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
644
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
635
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
636
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
637
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
638
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
639
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
640
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
641
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
642
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
643
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
644
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
645 645
 	
646 646
                 if ($latitude == '' && $longitude == '') {
647 647
             		$latitude = 0;
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
             	}
650 650
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
651 651
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
652
-                $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
652
+                $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
653 653
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
654 654
 
655
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
655
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type);
656 656
 
657 657
 		try {
658 658
 		        
@@ -678,13 +678,13 @@  discard block
 block discarded – undo
678 678
 	{
679 679
 		global $globalDBdriver, $globalTimezone;
680 680
 		if ($globalDBdriver == 'mysql') {
681
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
681
+			$query = "SELECT tracker_output.ident FROM tracker_output 
682 682
 								WHERE tracker_output.ident = :ident 
683 683
 								AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
684 684
 								AND tracker_output.date < UTC_TIMESTAMP()";
685 685
 			$query_data = array(':ident' => $ident);
686 686
 		} else {
687
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
687
+			$query = "SELECT tracker_output.ident FROM tracker_output 
688 688
 								WHERE tracker_output.ident = :ident 
689 689
 								AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
690 690
 								AND tracker_output.date < now() AT TIME ZONE 'UTC'";
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 		
694 694
 		$sth = $this->db->prepare($query);
695 695
 		$sth->execute($query_data);
696
-    		$ident_result='';
697
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
696
+    		$ident_result = '';
697
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
698 698
 		{
699 699
 			$ident_result = $row['ident'];
700 700
 		}
@@ -720,8 +720,8 @@  discard block
 block discarded – undo
720 720
 				return false;
721 721
 			} else {
722 722
 				$q_array = explode(" ", $q);
723
-				foreach ($q_array as $q_item){
724
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
723
+				foreach ($q_array as $q_item) {
724
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
725 725
 					$additional_query .= " AND (";
726 726
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%')";
727 727
 					$additional_query .= ")";
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
 			}
730 730
 		}
731 731
 		if ($globalDBdriver == 'mysql') {
732
-			$query  = "SELECT tracker_output.* FROM tracker_output 
732
+			$query = "SELECT tracker_output.* FROM tracker_output 
733 733
 				WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
734 734
 				AND tracker_output.date < UTC_TIMESTAMP()";
735 735
 		} else {
736
-			$query  = "SELECT tracker_output.* FROM tracker_output 
736
+			$query = "SELECT tracker_output.* FROM tracker_output 
737 737
 				WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
738 738
 				AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
739 739
 		}
@@ -806,11 +806,11 @@  discard block
 block discarded – undo
806 806
 	* @return Array the callsign list
807 807
 	*
808 808
 	*/
809
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
809
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
810 810
 	{
811 811
 		global $globalDBdriver;
812
-		$filter_query = $this->getFilter($filters,true,true);
813
-		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
812
+		$filter_query = $this->getFilter($filters, true, true);
813
+		$query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
814 814
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
815 815
 		 if ($olderthanmonths > 0) {
816 816
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -824,28 +824,28 @@  discard block
 block discarded – undo
824 824
 		if ($year != '') {
825 825
 			if ($globalDBdriver == 'mysql') {
826 826
 				$query .= " AND YEAR(tracker_output.date) = :year";
827
-				$query_values = array_merge($query_values,array(':year' => $year));
827
+				$query_values = array_merge($query_values, array(':year' => $year));
828 828
 			} else {
829 829
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
830
-				$query_values = array_merge($query_values,array(':year' => $year));
830
+				$query_values = array_merge($query_values, array(':year' => $year));
831 831
 			}
832 832
 		}
833 833
 		if ($month != '') {
834 834
 			if ($globalDBdriver == 'mysql') {
835 835
 				$query .= " AND MONTH(tracker_output.date) = :month";
836
-				$query_values = array_merge($query_values,array(':month' => $month));
836
+				$query_values = array_merge($query_values, array(':month' => $month));
837 837
 			} else {
838 838
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
839
-				$query_values = array_merge($query_values,array(':month' => $month));
839
+				$query_values = array_merge($query_values, array(':month' => $month));
840 840
 			}
841 841
 		}
842 842
 		if ($day != '') {
843 843
 			if ($globalDBdriver == 'mysql') {
844 844
 				$query .= " AND DAY(tracker_output.date) = :day";
845
-				$query_values = array_merge($query_values,array(':day' => $day));
845
+				$query_values = array_merge($query_values, array(':day' => $day));
846 846
 			} else {
847 847
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
848
-				$query_values = array_merge($query_values,array(':day' => $day));
848
+				$query_values = array_merge($query_values, array(':day' => $day));
849 849
 			}
850 850
 		}
851 851
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 		$callsign_array = array();
858 858
 		$temp_array = array();
859 859
         
860
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
860
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
861 861
 		{
862 862
 			$temp_array['callsign_icao'] = $row['ident'];
863 863
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 		$date_array = array();
910 910
 		$temp_array = array();
911 911
         
912
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
912
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
913 913
 		{
914 914
 			$temp_array['date_name'] = $row['date_name'];
915 915
 			$temp_array['date_count'] = $row['date_count'];
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 			$datetime = new DateTime();
936 936
 			$offset = $datetime->format('P');
937 937
 		} else $offset = '+00:00';
938
-		$filter_query = $this->getFilter($filters,true,true);
938
+		$filter_query = $this->getFilter($filters, true, true);
939 939
 		if ($globalDBdriver == 'mysql') {
940 940
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
941 941
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
 		$date_array = array();
957 957
 		$temp_array = array();
958 958
         
959
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
959
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
960 960
 		{
961 961
 			$temp_array['date_name'] = $row['date_name'];
962 962
 			$temp_array['date_count'] = $row['date_count'];
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 			$datetime = new DateTime();
982 982
 			$offset = $datetime->format('P');
983 983
 		} else $offset = '+00:00';
984
-		$filter_query = $this->getFilter($filters,true,true);
984
+		$filter_query = $this->getFilter($filters, true, true);
985 985
 		if ($globalDBdriver == 'mysql') {
986 986
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
987 987
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 		$date_array = array();
1003 1003
 		$temp_array = array();
1004 1004
         
1005
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1005
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1006 1006
 		{
1007 1007
 			$temp_array['date_name'] = $row['date_name'];
1008 1008
 			$temp_array['date_count'] = $row['date_count'];
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 		$date_array = array();
1050 1050
 		$temp_array = array();
1051 1051
         
1052
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1052
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1053 1053
 		{
1054 1054
 			$temp_array['month_name'] = $row['month_name'];
1055 1055
 			$temp_array['year_name'] = $row['year_name'];
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 			$datetime = new DateTime();
1079 1079
 			$offset = $datetime->format('P');
1080 1080
 		} else $offset = '+00:00';
1081
-		$filter_query = $this->getFilter($filters,true,true);
1081
+		$filter_query = $this->getFilter($filters, true, true);
1082 1082
 		if ($globalDBdriver == 'mysql') {
1083 1083
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1084 1084
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 		$date_array = array();
1100 1100
 		$temp_array = array();
1101 1101
         
1102
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1102
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1103 1103
 		{
1104 1104
 			$temp_array['year_name'] = $row['year_name'];
1105 1105
 			$temp_array['month_name'] = $row['month_name'];
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 	* @return Array the hour list
1120 1120
 	*
1121 1121
 	*/
1122
-	public function countAllHours($orderby,$filters = array())
1122
+	public function countAllHours($orderby, $filters = array())
1123 1123
 	{
1124 1124
 		global $globalTimezone, $globalDBdriver;
1125 1125
 		if ($globalTimezone != '') {
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 		$hour_array = array();
1168 1168
 		$temp_array = array();
1169 1169
         
1170
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1170
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1171 1171
 		{
1172 1172
 			$temp_array['hour_name'] = $row['hour_name'];
1173 1173
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1189,8 +1189,8 @@  discard block
 block discarded – undo
1189 1189
 	public function countAllHoursByDate($date, $filters = array())
1190 1190
 	{
1191 1191
 		global $globalTimezone, $globalDBdriver;
1192
-		$filter_query = $this->getFilter($filters,true,true);
1193
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1192
+		$filter_query = $this->getFilter($filters, true, true);
1193
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1194 1194
 		if ($globalTimezone != '') {
1195 1195
 			date_default_timezone_set($globalTimezone);
1196 1196
 			$datetime = new DateTime($date);
@@ -1198,12 +1198,12 @@  discard block
 block discarded – undo
1198 1198
 		} else $offset = '+00:00';
1199 1199
 
1200 1200
 		if ($globalDBdriver == 'mysql') {
1201
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1201
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1202 1202
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date
1203 1203
 								GROUP BY hour_name 
1204 1204
 								ORDER BY hour_name ASC";
1205 1205
 		} else {
1206
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1206
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1207 1207
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1208 1208
 								GROUP BY hour_name 
1209 1209
 								ORDER BY hour_name ASC";
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
 		$hour_array = array();
1216 1216
 		$temp_array = array();
1217 1217
         
1218
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1218
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1219 1219
 		{
1220 1220
 			$temp_array['hour_name'] = $row['hour_name'];
1221 1221
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1237,8 +1237,8 @@  discard block
 block discarded – undo
1237 1237
 	public function countAllHoursByIdent($ident, $filters = array())
1238 1238
 	{
1239 1239
 		global $globalTimezone, $globalDBdriver;
1240
-		$filter_query = $this->getFilter($filters,true,true);
1241
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1240
+		$filter_query = $this->getFilter($filters, true, true);
1241
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1242 1242
 		if ($globalTimezone != '') {
1243 1243
 			date_default_timezone_set($globalTimezone);
1244 1244
 			$datetime = new DateTime();
@@ -1246,12 +1246,12 @@  discard block
 block discarded – undo
1246 1246
 		} else $offset = '+00:00';
1247 1247
 
1248 1248
 		if ($globalDBdriver == 'mysql') {
1249
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1249
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1250 1250
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1251 1251
 								GROUP BY hour_name 
1252 1252
 								ORDER BY hour_name ASC";
1253 1253
 		} else {
1254
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1254
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1255 1255
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1256 1256
 								GROUP BY hour_name 
1257 1257
 								ORDER BY hour_name ASC";
@@ -1259,12 +1259,12 @@  discard block
 block discarded – undo
1259 1259
       
1260 1260
 		
1261 1261
 		$sth = $this->db->prepare($query);
1262
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1262
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1263 1263
       
1264 1264
 		$hour_array = array();
1265 1265
 		$temp_array = array();
1266 1266
         
1267
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1267
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1268 1268
 		{
1269 1269
 			$temp_array['hour_name'] = $row['hour_name'];
1270 1270
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1283,32 +1283,32 @@  discard block
 block discarded – undo
1283 1283
 	* @return Integer the number of flights
1284 1284
 	*
1285 1285
 	*/
1286
-	public function countOverallTracked($filters = array(),$year = '',$month = '')
1286
+	public function countOverallTracked($filters = array(), $year = '', $month = '')
1287 1287
 	{
1288 1288
 		global $globalDBdriver;
1289
-		$queryi  = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output";
1289
+		$queryi = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output";
1290 1290
 		$query_values = array();
1291 1291
 		$query = '';
1292 1292
 		if ($year != '') {
1293 1293
 			if ($globalDBdriver == 'mysql') {
1294 1294
 				$query .= " AND YEAR(tracker_output.date) = :year";
1295
-				$query_values = array_merge($query_values,array(':year' => $year));
1295
+				$query_values = array_merge($query_values, array(':year' => $year));
1296 1296
 			} else {
1297 1297
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1298
-				$query_values = array_merge($query_values,array(':year' => $year));
1298
+				$query_values = array_merge($query_values, array(':year' => $year));
1299 1299
 			}
1300 1300
 		}
1301 1301
 		if ($month != '') {
1302 1302
 			if ($globalDBdriver == 'mysql') {
1303 1303
 				$query .= " AND MONTH(tracker_output.date) = :month";
1304
-				$query_values = array_merge($query_values,array(':month' => $month));
1304
+				$query_values = array_merge($query_values, array(':month' => $month));
1305 1305
 			} else {
1306 1306
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1307
-				$query_values = array_merge($query_values,array(':month' => $month));
1307
+				$query_values = array_merge($query_values, array(':month' => $month));
1308 1308
 			}
1309 1309
 		}
1310 1310
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1311
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1311
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1312 1312
 		
1313 1313
 		$sth = $this->db->prepare($queryi);
1314 1314
 		$sth->execute($query_values);
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 	public function countAllHoursFromToday($filters = array())
1326 1326
 	{
1327 1327
 		global $globalTimezone, $globalDBdriver;
1328
-		$filter_query = $this->getFilter($filters,true,true);
1328
+		$filter_query = $this->getFilter($filters, true, true);
1329 1329
 		if ($globalTimezone != '') {
1330 1330
 			date_default_timezone_set($globalTimezone);
1331 1331
 			$datetime = new DateTime();
@@ -1333,12 +1333,12 @@  discard block
 block discarded – undo
1333 1333
 		} else $offset = '+00:00';
1334 1334
 
1335 1335
 		if ($globalDBdriver == 'mysql') {
1336
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1336
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1337 1337
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE()
1338 1338
 								GROUP BY hour_name 
1339 1339
 								ORDER BY hour_name ASC";
1340 1340
 		} else {
1341
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1341
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1342 1342
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1343 1343
 								GROUP BY hour_name 
1344 1344
 								ORDER BY hour_name ASC";
@@ -1350,7 +1350,7 @@  discard block
 block discarded – undo
1350 1350
 		$hour_array = array();
1351 1351
 		$temp_array = array();
1352 1352
         
1353
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1353
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1354 1354
 		{
1355 1355
 			$temp_array['hour_name'] = $row['hour_name'];
1356 1356
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1369,9 +1369,9 @@  discard block
 block discarded – undo
1369 1369
 	*/
1370 1370
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1371 1371
 	{
1372
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
1372
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
1373 1373
 
1374
-		$query  = "SELECT tracker_output.tracker_id
1374
+		$query = "SELECT tracker_output.tracker_id
1375 1375
 				FROM tracker_output 
1376 1376
 				WHERE tracker_output.famtrackid = '".$famtrackid."'";
1377 1377
         
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
 		$sth = $this->db->prepare($query);
1380 1380
 		$sth->execute();
1381 1381
 
1382
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1382
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1383 1383
 		{
1384 1384
 			return $row['tracker_id'];
1385 1385
 		}
@@ -1404,23 +1404,23 @@  discard block
 block discarded – undo
1404 1404
 		}
1405 1405
 		
1406 1406
 		$current_date = date("Y-m-d H:i:s");
1407
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1407
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1408 1408
 		
1409 1409
 		$diff = abs(strtotime($current_date) - strtotime($date));
1410 1410
 
1411
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1411
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1412 1412
 		$years = $time_array['years'];
1413 1413
 		
1414
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1414
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1415 1415
 		$months = $time_array['months'];
1416 1416
 		
1417
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1417
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1418 1418
 		$days = $time_array['days'];
1419
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1419
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1420 1420
 		$hours = $time_array['hours'];
1421
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1421
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1422 1422
 		$minutes = $time_array['minutes'];
1423
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1423
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1424 1424
 		
1425 1425
 		return $time_array;
1426 1426
 	}
@@ -1443,63 +1443,63 @@  discard block
 block discarded – undo
1443 1443
 			$temp_array['direction_degree'] = $direction;
1444 1444
 			$temp_array['direction_shortname'] = "N";
1445 1445
 			$temp_array['direction_fullname'] = "North";
1446
-		} elseif ($direction >= 22.5 && $direction < 45){
1446
+		} elseif ($direction >= 22.5 && $direction < 45) {
1447 1447
 			$temp_array['direction_degree'] = $direction;
1448 1448
 			$temp_array['direction_shortname'] = "NNE";
1449 1449
 			$temp_array['direction_fullname'] = "North-Northeast";
1450
-		} elseif ($direction >= 45 && $direction < 67.5){
1450
+		} elseif ($direction >= 45 && $direction < 67.5) {
1451 1451
 			$temp_array['direction_degree'] = $direction;
1452 1452
 			$temp_array['direction_shortname'] = "NE";
1453 1453
 			$temp_array['direction_fullname'] = "Northeast";
1454
-		} elseif ($direction >= 67.5 && $direction < 90){
1454
+		} elseif ($direction >= 67.5 && $direction < 90) {
1455 1455
 			$temp_array['direction_degree'] = $direction;
1456 1456
 			$temp_array['direction_shortname'] = "ENE";
1457 1457
 			$temp_array['direction_fullname'] = "East-Northeast";
1458
-		} elseif ($direction >= 90 && $direction < 112.5){
1458
+		} elseif ($direction >= 90 && $direction < 112.5) {
1459 1459
 			$temp_array['direction_degree'] = $direction;
1460 1460
 			$temp_array['direction_shortname'] = "E";
1461 1461
 			$temp_array['direction_fullname'] = "East";
1462
-		} elseif ($direction >= 112.5 && $direction < 135){
1462
+		} elseif ($direction >= 112.5 && $direction < 135) {
1463 1463
 			$temp_array['direction_degree'] = $direction;
1464 1464
 			$temp_array['direction_shortname'] = "ESE";
1465 1465
 			$temp_array['direction_fullname'] = "East-Southeast";
1466
-		} elseif ($direction >= 135 && $direction < 157.5){
1466
+		} elseif ($direction >= 135 && $direction < 157.5) {
1467 1467
 			$temp_array['direction_degree'] = $direction;
1468 1468
 			$temp_array['direction_shortname'] = "SE";
1469 1469
 			$temp_array['direction_fullname'] = "Southeast";
1470
-		} elseif ($direction >= 157.5 && $direction < 180){
1470
+		} elseif ($direction >= 157.5 && $direction < 180) {
1471 1471
 			$temp_array['direction_degree'] = $direction;
1472 1472
 			$temp_array['direction_shortname'] = "SSE";
1473 1473
 			$temp_array['direction_fullname'] = "South-Southeast";
1474
-		} elseif ($direction >= 180 && $direction < 202.5){
1474
+		} elseif ($direction >= 180 && $direction < 202.5) {
1475 1475
 			$temp_array['direction_degree'] = $direction;
1476 1476
 			$temp_array['direction_shortname'] = "S";
1477 1477
 			$temp_array['direction_fullname'] = "South";
1478
-		} elseif ($direction >= 202.5 && $direction < 225){
1478
+		} elseif ($direction >= 202.5 && $direction < 225) {
1479 1479
 			$temp_array['direction_degree'] = $direction;
1480 1480
 			$temp_array['direction_shortname'] = "SSW";
1481 1481
 			$temp_array['direction_fullname'] = "South-Southwest";
1482
-		} elseif ($direction >= 225 && $direction < 247.5){
1482
+		} elseif ($direction >= 225 && $direction < 247.5) {
1483 1483
 			$temp_array['direction_degree'] = $direction;
1484 1484
 			$temp_array['direction_shortname'] = "SW";
1485 1485
 			$temp_array['direction_fullname'] = "Southwest";
1486
-		} elseif ($direction >= 247.5 && $direction < 270){
1486
+		} elseif ($direction >= 247.5 && $direction < 270) {
1487 1487
 			$temp_array['direction_degree'] = $direction;
1488 1488
 			$temp_array['direction_shortname'] = "WSW";
1489 1489
 			$temp_array['direction_fullname'] = "West-Southwest";
1490
-		} elseif ($direction >= 270 && $direction < 292.5){
1490
+		} elseif ($direction >= 270 && $direction < 292.5) {
1491 1491
 			$temp_array['direction_degree'] = $direction;
1492 1492
 			$temp_array['direction_shortname'] = "W";
1493 1493
 			$temp_array['direction_fullname'] = "West";
1494
-		} elseif ($direction >= 292.5 && $direction < 315){
1494
+		} elseif ($direction >= 292.5 && $direction < 315) {
1495 1495
 			$temp_array['direction_degree'] = $direction;
1496 1496
 			$temp_array['direction_shortname'] = "WNW";
1497 1497
 			$temp_array['direction_fullname'] = "West-Northwest";
1498
-		} elseif ($direction >= 315 && $direction < 337.5){
1498
+		} elseif ($direction >= 315 && $direction < 337.5) {
1499 1499
 			$temp_array['direction_degree'] = $direction;
1500 1500
 			$temp_array['direction_shortname'] = "NW";
1501 1501
 			$temp_array['direction_fullname'] = "Northwest";
1502
-		} elseif ($direction >= 337.5 && $direction < 360){
1502
+		} elseif ($direction >= 337.5 && $direction < 360) {
1503 1503
 			$temp_array['direction_degree'] = $direction;
1504 1504
 			$temp_array['direction_shortname'] = "NNW";
1505 1505
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1516,11 +1516,11 @@  discard block
 block discarded – undo
1516 1516
 	* @param Float $longitude longitute of the flight
1517 1517
 	* @return String the countrie
1518 1518
 	*/
1519
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1519
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1520 1520
 	{
1521 1521
 		global $globalDBdriver, $globalDebug;
1522
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1523
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1522
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1523
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1524 1524
 	
1525 1525
 		$Connection = new Connection($this->db);
1526 1526
 		if (!$Connection->tableExists('countries')) return '';
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
 	public function getCountryFromISO2($iso2)
1561 1561
 	{
1562 1562
 		global $globalDBdriver, $globalDebug;
1563
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1563
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1564 1564
 	
1565 1565
 		$Connection = new Connection($this->db);
1566 1566
 		if (!$Connection->tableExists('countries')) return '';
@@ -1608,7 +1608,7 @@  discard block
 block discarded – undo
1608 1608
 		
1609 1609
 		$bitly_data = json_decode($bitly_data);
1610 1610
 		$bitly_url = '';
1611
-		if ($bitly_data->status_txt = "OK"){
1611
+		if ($bitly_data->status_txt = "OK") {
1612 1612
 			$bitly_url = $bitly_data->data->url;
1613 1613
 		}
1614 1614
 
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
 
1619 1619
 	public function getOrderBy()
1620 1620
 	{
1621
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_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"));
1621
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_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"));
1622 1622
 		
1623 1623
 		return $orderby;
1624 1624
 		
Please login to merge, or discard this patch.
require/class.TrackerLive.php 2 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;
@@ -759,10 +759,6 @@  discard block
 block discarded – undo
759 759
 	*
760 760
 	* @param String $famtrackid the ID from flightaware
761 761
 	* @param String $ident the flight ident
762
-	* @param String $aircraft_icao the aircraft type
763
-	* @param String $departure_airport_icao the departure airport
764
-	* @param String $arrival_airport_icao the arrival airport
765
-	* @return String success or false
766 762
 	*
767 763
 	*/
768 764
 	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 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 famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
38
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
40
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
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 tracker_output.date) = '".$filter['day']."'";
72 72
 				}
73 73
 			}
74
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
74
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
75 75
 		}
76 76
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
77
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
78 78
 		}
79 79
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80 80
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81 81
 		if ($filter_query_where != '') {
82
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
82
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
83 83
 		}
84 84
 		$filter_query = $filter_query_join.$filter_query_where;
85 85
 		return $filter_query;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		if ($limit != '')
103 103
 		{
104 104
 			$limit_array = explode(',', $limit);
105
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
106
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
105
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
107 107
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
108 108
 			{
109 109
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		} else {
127 127
 			$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query;
128 128
 		}
129
-		$spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true);
129
+		$spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true);
130 130
 
131 131
 		return $spotter_array;
132 132
 	}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		global $globalDBdriver, $globalLiveInterval;
143 143
 		date_default_timezone_set('UTC');
144 144
 
145
-		$filter_query = $this->getFilter($filter,true,true);
145
+		$filter_query = $this->getFilter($filter, true, true);
146 146
 
147 147
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
148 148
 		if ($globalDBdriver == 'mysql') {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		try {
161 161
 			$sth = $this->db->prepare($query);
162 162
 			$sth->execute();
163
-		} catch(PDOException $e) {
163
+		} catch (PDOException $e) {
164 164
 			echo $e->getMessage();
165 165
 			die;
166 166
 		}
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 		global $globalDBdriver, $globalLiveInterval;
181 181
 		date_default_timezone_set('UTC');
182 182
 
183
-		$filter_query = $this->getFilter($filter,true,true);
183
+		$filter_query = $this->getFilter($filter, true, true);
184 184
 
185 185
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
186 186
 		if ($globalDBdriver == 'mysql') {
187
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
187
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
188 188
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
189 189
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
190 190
                 } else {
191
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
191
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
192 192
 			FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
193 193
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
194 194
 		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     		try {
197 197
 			$sth = $this->db->prepare($query);
198 198
 			$sth->execute();
199
-		} catch(PDOException $e) {
199
+		} catch (PDOException $e) {
200 200
 			echo $e->getMessage();
201 201
 			die;
202 202
 		}
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	public function getLiveTrackerCount($filter = array())
214 214
 	{
215 215
 		global $globalDBdriver, $globalLiveInterval;
216
-		$filter_query = $this->getFilter($filter,true,true);
216
+		$filter_query = $this->getFilter($filter, true, true);
217 217
 
218 218
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
219 219
 		if ($globalDBdriver == 'mysql') {
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		try {
225 225
 			$sth = $this->db->prepare($query);
226 226
 			$sth->execute();
227
-		} catch(PDOException $e) {
227
+		} catch (PDOException $e) {
228 228
 			echo $e->getMessage();
229 229
 			die;
230 230
 		}
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 		$filter_query = $this->getFilter($filter);
248 248
 
249 249
 		if (is_array($coord)) {
250
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
251
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
252
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
253
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
251
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
252
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
253
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
254 254
 		} else return array();
255 255
 		if ($globalDBdriver == 'mysql') {
256 256
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                 if ($interval == '1m')
303 303
                 {
304 304
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
305
-                } else if ($interval == '15m'){
305
+                } else if ($interval == '15m') {
306 306
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
307 307
                 } 
308 308
             }
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
311 311
         }
312 312
 
313
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
313
+                $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
314 314
                    WHERE tracker_live.latitude <> '' 
315 315
                                    AND tracker_live.longitude <> '' 
316 316
                    ".$additional_query."
317 317
                    HAVING distance < :radius  
318 318
                                    ORDER BY distance";
319 319
 
320
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
320
+                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
321 321
 
322 322
                 return $spotter_array;
323 323
         }
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
 		date_default_timezone_set('UTC');
336 336
 
337 337
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
338
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
338
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
339 339
 
340
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
340
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true);
341 341
 
342 342
 		return $spotter_array;
343 343
 	}
@@ -348,16 +348,16 @@  discard block
 block discarded – undo
348 348
 	* @return Array the spotter information
349 349
 	*
350 350
 	*/
351
-	public function getDateLiveTrackerDataByIdent($ident,$date)
351
+	public function getDateLiveTrackerDataByIdent($ident, $date)
352 352
 	{
353 353
 		$Tracker = new Tracker($this->db);
354 354
 		date_default_timezone_set('UTC');
355 355
 
356 356
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
357
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
357
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
358 358
 
359
-                $date = date('c',$date);
360
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
359
+                $date = date('c', $date);
360
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
361 361
 
362 362
 		return $spotter_array;
363 363
 	}
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
 		date_default_timezone_set('UTC');
375 375
 
376 376
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
377
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
377
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
378 378
 
379
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
379
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true);
380 380
 
381 381
 		return $spotter_array;
382 382
 	}
@@ -387,15 +387,15 @@  discard block
 block discarded – undo
387 387
 	* @return Array the spotter information
388 388
 	*
389 389
 	*/
390
-	public function getDateLiveTrackerDataById($id,$date)
390
+	public function getDateLiveTrackerDataById($id, $date)
391 391
 	{
392 392
 		$Tracker = new Tracker($this->db);
393 393
 		date_default_timezone_set('UTC');
394 394
 
395 395
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
396
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
397
-                $date = date('c',$date);
398
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
396
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
397
+                $date = date('c', $date);
398
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
399 399
 
400 400
 		return $spotter_array;
401 401
 	}
@@ -412,13 +412,13 @@  discard block
 block discarded – undo
412 412
 		date_default_timezone_set('UTC');
413 413
 
414 414
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
415
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
415
+                $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
416 416
 
417 417
     		try {
418 418
 			
419 419
 			$sth = $this->db->prepare($query);
420 420
 			$sth->execute(array(':ident' => $ident));
421
-		} catch(PDOException $e) {
421
+		} catch (PDOException $e) {
422 422
 			echo $e->getMessage();
423 423
 			die;
424 424
 		}
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	* @return Array the spotter information
434 434
 	*
435 435
 	*/
436
-	public function getAllLiveTrackerDataById($id,$liveinterval = false)
436
+	public function getAllLiveTrackerDataById($id, $liveinterval = false)
437 437
 	{
438 438
 		global $globalDBdriver, $globalLiveInterval;
439 439
 		date_default_timezone_set('UTC');
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 		try {
453 453
 			$sth = $this->db->prepare($query);
454 454
 			$sth->execute(array(':id' => $id));
455
-		} catch(PDOException $e) {
455
+		} catch (PDOException $e) {
456 456
 			echo $e->getMessage();
457 457
 			die;
458 458
 		}
@@ -470,12 +470,12 @@  discard block
 block discarded – undo
470 470
 	{
471 471
 		date_default_timezone_set('UTC');
472 472
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
473
-		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
473
+		$query = self::$global_query.' WHERE tracker_live.ident = :ident';
474 474
     		try {
475 475
 			
476 476
 			$sth = $this->db->prepare($query);
477 477
 			$sth->execute(array(':ident' => $ident));
478
-		} catch(PDOException $e) {
478
+		} catch (PDOException $e) {
479 479
 			echo $e->getMessage();
480 480
 			die;
481 481
 		}
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 			
506 506
 			$sth = $this->db->prepare($query);
507 507
 			$sth->execute();
508
-		} catch(PDOException $e) {
508
+		} catch (PDOException $e) {
509 509
 			return "error";
510 510
 		}
511 511
 
@@ -528,14 +528,14 @@  discard block
 block discarded – undo
528 528
 				
529 529
 				$sth = $this->db->prepare($query);
530 530
 				$sth->execute();
531
-			} catch(PDOException $e) {
531
+			} catch (PDOException $e) {
532 532
 				return "error";
533 533
 			}
534 534
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
535 535
                         $i = 0;
536
-                        $j =0;
536
+                        $j = 0;
537 537
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
538
-			foreach($all as $row)
538
+			foreach ($all as $row)
539 539
 			{
540 540
 				$i++;
541 541
 				$j++;
@@ -543,9 +543,9 @@  discard block
 block discarded – undo
543 543
 					if ($globalDebug) echo ".";
544 544
 				    	try {
545 545
 						
546
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
546
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
547 547
 						$sth->execute();
548
-					} catch(PDOException $e) {
548
+					} catch (PDOException $e) {
549 549
 						return "error";
550 550
 					}
551 551
                                 	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
@@ -556,9 +556,9 @@  discard block
 block discarded – undo
556 556
 			if ($i > 0) {
557 557
     				try {
558 558
 					
559
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
559
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
560 560
 					$sth->execute();
561
-				} catch(PDOException $e) {
561
+				} catch (PDOException $e) {
562 562
 					return "error";
563 563
 				}
564 564
 			}
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 				
572 572
 				$sth = $this->db->prepare($query);
573 573
 				$sth->execute();
574
-			} catch(PDOException $e) {
574
+			} catch (PDOException $e) {
575 575
 				return "error";
576 576
 			}
577 577
 /*			$query_delete = "DELETE FROM tracker_live WHERE famtrackid IN (";
@@ -619,13 +619,13 @@  discard block
 block discarded – undo
619 619
 	public function deleteLiveTrackerDataByIdent($ident)
620 620
 	{
621 621
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
622
-		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
622
+		$query = 'DELETE FROM tracker_live WHERE ident = :ident';
623 623
         
624 624
     		try {
625 625
 			
626 626
 			$sth = $this->db->prepare($query);
627 627
 			$sth->execute(array(':ident' => $ident));
628
-		} catch(PDOException $e) {
628
+		} catch (PDOException $e) {
629 629
 			return "error";
630 630
 		}
631 631
 
@@ -641,13 +641,13 @@  discard block
 block discarded – undo
641 641
 	public function deleteLiveTrackerDataById($id)
642 642
 	{
643 643
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
644
-		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
644
+		$query = 'DELETE FROM tracker_live WHERE famtrackid = :id';
645 645
         
646 646
     		try {
647 647
 			
648 648
 			$sth = $this->db->prepare($query);
649 649
 			$sth->execute(array(':id' => $id));
650
-		} catch(PDOException $e) {
650
+		} catch (PDOException $e) {
651 651
 			return "error";
652 652
 		}
653 653
 
@@ -665,13 +665,13 @@  discard block
 block discarded – undo
665 665
 	{
666 666
 		global $globalDBdriver, $globalTimezone;
667 667
 		if ($globalDBdriver == 'mysql') {
668
-			$query  = 'SELECT tracker_live.ident FROM tracker_live 
668
+			$query = 'SELECT tracker_live.ident FROM tracker_live 
669 669
 				WHERE tracker_live.ident = :ident 
670 670
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
671 671
 				AND tracker_live.date < UTC_TIMESTAMP()';
672 672
 			$query_data = array(':ident' => $ident);
673 673
 		} else {
674
-			$query  = "SELECT tracker_live.ident FROM tracker_live 
674
+			$query = "SELECT tracker_live.ident FROM tracker_live 
675 675
 				WHERE tracker_live.ident = :ident 
676 676
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
677 677
 				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -680,8 +680,8 @@  discard block
 block discarded – undo
680 680
 		
681 681
 		$sth = $this->db->prepare($query);
682 682
 		$sth->execute($query_data);
683
-		$ident_result='';
684
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
683
+		$ident_result = '';
684
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
685 685
 		{
686 686
 			$ident_result = $row['ident'];
687 687
 		}
@@ -698,13 +698,13 @@  discard block
 block discarded – undo
698 698
 	{
699 699
 		global $globalDBdriver, $globalTimezone;
700 700
 		if ($globalDBdriver == 'mysql') {
701
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
701
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
702 702
 				WHERE tracker_live.ident = :ident 
703 703
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
704 704
 //				AND tracker_live.date < UTC_TIMESTAMP()";
705 705
 			$query_data = array(':ident' => $ident);
706 706
 		} else {
707
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
707
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
708 708
 				WHERE tracker_live.ident = :ident 
709 709
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
710 710
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 		
714 714
 		$sth = $this->db->prepare($query);
715 715
 		$sth->execute($query_data);
716
-		$ident_result='';
717
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
716
+		$ident_result = '';
717
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
718 718
 		{
719 719
 			$ident_result = $row['famtrackid'];
720 720
 		}
@@ -731,13 +731,13 @@  discard block
 block discarded – undo
731 731
 	{
732 732
 		global $globalDBdriver, $globalTimezone;
733 733
 		if ($globalDBdriver == 'mysql') {
734
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
734
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
735 735
 				WHERE tracker_live.famtrackid = :id 
736 736
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
737 737
 //				AND tracker_live.date < UTC_TIMESTAMP()";
738 738
 			$query_data = array(':id' => $id);
739 739
 		} else {
740
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
740
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
741 741
 				WHERE tracker_live.famtrackid = :id 
742 742
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
743 743
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -746,8 +746,8 @@  discard block
 block discarded – undo
746 746
 		
747 747
 		$sth = $this->db->prepare($query);
748 748
 		$sth->execute($query_data);
749
-		$ident_result='';
750
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
749
+		$ident_result = '';
750
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
751 751
 		{
752 752
 			$ident_result = $row['famtrackid'];
753 753
 		}
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 	* @return String success or false
766 766
 	*
767 767
 	*/
768
-	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
768
+	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
769 769
 	{
770 770
 		global $globalURL, $globalArchive, $globalDebug;
771 771
 		$Common = new Common();
@@ -824,31 +824,31 @@  discard block
 block discarded – undo
824 824
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
825 825
 
826 826
         
827
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
828
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
829
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
830
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
831
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
832
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
833
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
834
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
835
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
836
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
837
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
838
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
839
-
840
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
841
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
827
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
828
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
829
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
830
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
831
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
832
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
833
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
834
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
835
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
836
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
837
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
838
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
839
+
840
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
841
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
842 842
             	
843
-		$query  = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
843
+		$query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
844 844
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
845 845
 
846
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type);
846
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type);
847 847
 		try {
848 848
 			
849 849
 			$sth = $this->db->prepare($query);
850 850
 			$sth->execute($query_values);
851
-                } catch(PDOException $e) {
851
+                } catch (PDOException $e) {
852 852
                 	return "error : ".$e->getMessage();
853 853
                 }
854 854
 		/*
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 
866 866
 	public function getOrderBy()
867 867
 	{
868
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
868
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
869 869
 		return $orderby;
870 870
 	}
871 871
 
Please login to merge, or discard this patch.
js/map-marine.3d.js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,5 +131,5 @@
 block discarded – undo
131 131
 } else {
132 132
 	var clockViewModel = new Cesium.ClockViewModel(viewer.clock);
133 133
 	var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);
134
-	$(".archivebox").html('<h4><?php echo str_replace("'","\'",_("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
134
+	$(".archivebox").html('<h4><?php echo str_replace("'", "\'", _("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
135 135
 }
Please login to merge, or discard this patch.
js/map-aircraft.2d.js.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 if (!isset($globalJsonCompress)) $compress = true;
7 7
 else $compress = $globalJsonCompress;
8 8
 
9
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
10
-if (isset($_GET['flightaware_id'])) $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
9
+if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
10
+if (isset($_GET['flightaware_id'])) $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
11 11
 ?>
12 12
 
13 13
 
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 	};
177 177
 	archive.update = function (props) {
178 178
 		if (typeof props != 'undefined') {
179
-			//this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
180
-			this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>';
179
+			//this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
180
+			this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>';
181 181
 		} else {
182
-			this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
182
+			this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
183 183
 		}
184 184
 
185 185
 	};
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 <?php
341 341
 		} else {
342 342
 ?>
343
-					var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
343
+					var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
344 344
 					return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
345 345
 <?php
346 346
 		}
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 							/*
357 357
 							shadowUrl: iconURLShadowpath,
358 358
 							shadowSize: [<?php print $globalAircraftSize; ?>, <?php print $globalAircraftSize; ?>],
359
-							shadowAnchor: [<?php print ($globalAircraftSize/2)+1; ?>, <?php print $globalAircraftSize; ?>]
359
+							shadowAnchor: [<?php print ($globalAircraftSize/2) + 1; ?>, <?php print $globalAircraftSize; ?>]
360 360
 							*/
361 361
 						})
362 362
 					})
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 <?php
383 383
 		} else {
384 384
 ?>
385
-						var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
385
+						var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
386 386
 						return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
387 387
 <?php
388 388
 		}
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 <?php
423 423
 		} else {
424 424
 ?>
425
-							var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
425
+							var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
426 426
 							return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
427 427
 <?php
428 428
 		}
Please login to merge, or discard this patch.
js/map-tracker.3d.js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,5 +131,5 @@
 block discarded – undo
131 131
 } else {
132 132
 	var clockViewModel = new Cesium.ClockViewModel(viewer.clock);
133 133
 	var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);
134
-	$(".archivebox").html('<h4><?php echo str_replace("'","\'",_("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
134
+	$(".archivebox").html('<h4><?php echo str_replace("'", "\'", _("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
135 135
 }
Please login to merge, or discard this patch.